Jump to content
Sign in to follow this  
Artkyom

[SOLVED] Building snapping like AOW DLC Gallery ?

Recommended Posts

Hi,

I'm currently making a building in multiple part and i'm wondering how to make the parts automaticaly snap together when you approach them in Eden Editor.

This system is currently used by the Art Of War DLC "Lars Blanken" Gallery (demonstration in the MP4) but i didn't find any other A3 building that do that.

I did find this topic talking about it (i guess) but after trying the "snap-points" technique given at the end, it didn't work at all. Maybe i missed something to add in config ?

 

 

 

AOW Gallery Snapping exemple :

https://i.gyazo.com/b859c6dfe25866e6a7fabb168a678e25.mp4

Share this post


Link to post
Share on other sites

Hi, beside AoW gallery, there are also Military Cargo Platforms (introduced with Contact DLC) which have similar functionality. This whole feature is scripted and it is using Eden event handlers and it doesn't have anything in common with Terrain Builder snap points mentioned in topic linked by you. Below you can find an example how function is plugged in to the object


	class GalleryInterior_01_Base_F : House
	{
		[...]
		class EventHandlers
		{
			dragged3DEN					= "_this call bis_fnc_gallery_01_update;";
		};
	};

 

and then there is function

/*
	bis_fnc_gallery_01_update

	Snap gallery rooms to each other
*/
params["_object"];

// If there is another gallery room nearby then try to snap to it
// First we have to wait till dragging is completed
if(current3DENOperation isEqualTo "")then
{
	private _nearbyObjects = nearestObjects [_object, ["GalleryInterior_01_Base_F"], 50];
	_nearbyObjects = _nearbyObjects - [_object];
	
	if(!(_nearbyObjects isEqualTo []))then
	{
		private _pos			= getposASL _object;
		// Itterate through all nearby objects - this dictated by the fact that gallery objects are fairly large and the closest object from the bound center might not be the right one
		{
			private _nearestObject	= _x;

			// Search for available snap points
			private _snapPointsParent	= [];
			for "_i" from 1 to 3 do
			{
				_snapPoint = (_object modelToWorldVisual (_object selectionPosition format["snap_%1",_i]));
				if(_snapPoint isEqualTo [0,0,0])exitWith{};
				_snapPointsParent pushBack _snapPoint;
			};

			if(!(_snapPointsParent isEqualTo []))then
			{
				for "_i" from 1 to 3 do
				{
					_snapPoint = _nearestObject modelToWorldVisual (_nearestObject selectionPosition format["snap_%1",_i]);
					if(_snapPoint isEqualTo [0,0,0])exitWith{};
					{
						// Continue if snap points are found
						if(_snapPoint distance _x <= 3)exitWith
						{
							// Reconvert to model space due to dir change
							_posModel = _object worldToModel _x;

							// Adjust direction
							_dirTo		= getDir _nearestObject - 360;
							_dirObject	= getDir _object;
							_dir		= _dirTo;

							for "_i" from 0 to 7 do
							{
								_dir = _dirTo + _i * 90;
								if(abs(_dir - _dirObject) < 45)then
								{
									_i = 10;
								};
							};
							_object set3DENAttribute ["rotation",[0,0, _dir]];

							// Recalc position in case direction was changed
							_x = _object modelToWorldVisual _posModel;

							// Transform position
							_pos = _pos vectorDiff (_x vectorDiff _snapPoint);
							_pos = [_pos # 0, _pos # 1, (getposASL (_nearbyObjects # 0)) # 2];
							//systemChat format["pos found %1",_pos];

							// Snap to position
							_object set3DENAttribute ["position",ASLToATL _pos];

							// Exit "for" loop
							_i = 10;
						};
					}forEach _snapPointsParent;
				};
			};
		}forEach _nearbyObjects;
	};
};

As you might see, this function is very specific to the gallery object so you will need to create a new variant for your specific building.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×