Jump to content
HazJ

boundingBoxReal + speed (moving vehicle)

Recommended Posts

There is an offset when speeding fast in vehicles. Also when drifting left or right. As the video shows. I am looking for a fix. I guess I need some kind of formula of vehicle's speed or something? I am using drawLine3D with onEachFrame command.

http://killzonekid.com/arma-3-bounding-box-utility/

 

Share this post


Link to post
Share on other sites

I suspect what you're seeing there is the draw of the box is lagging more than the draw of the vehicle.

Share this post


Link to post
Share on other sites

Yeah, I guess so. As I said I use onEachFrame but the vehicle is going so fast, it can't catch up. Hm... Hopefully someone has a fix.

@Larrow

:smileee:

Share this post


Link to post
Share on other sites

There used to be this phenomenon on helicopters when some modders were trying to draw points relative to the model.  Maybe it's related, maybe not, but it looks similar.

 

They were using "helicopterX" simulation but when they reverted to "helicopter" the issue disappeared.  Obv, that wasn't a "fix" but demonstrated that it was something to do with the new physx modelling.

 

 

Share this post


Link to post
Share on other sites

As Das says I would of imagined just from looking at your video that its a difference between render time and simulation time, although from my tests I do not see the same behaviour. How are you calculating your line positions? Can you show me your code.

Spoiler

Just some quick code to see if there is any difference between draw3D and EachFrame and whether or not calculating the bounds on each event makes any difference.



TAG_fnc_addDrawEvent = {
	addMissionEventHandler [ "Draw3D", {
		[ car1, TAG_vehicleBounds, [ 0, 1, 0, 1 ] ] call TAG_fnc_drawLines;
		[ car1, car1 call TAG_fnc_getBounds, [ 1, 0, 0, 1 ] ] call TAG_fnc_drawLines;
	}];
	addMissionEventHandler [ "EachFrame", {
		[ car1, TAG_vehicleBounds, [ 0, 0, 1, 1 ] ] call TAG_fnc_drawLines;
		[ car1, car1 call TAG_fnc_getBounds, [ 1, 1, 1, 1 ] ] call TAG_fnc_drawLines;
	}];
};

TAG_fnc_drawLines = {
	params[ "_vehicle", "_points", "_color" ];
	
	_points params[ "_mins", "_maxs" ];
	_mins params[ "_minX", "_minY", "_minZ" ];
	_maxs params[ "_maxX", "_maxY", "_maxZ" ];
	
	
	drawLine3D[ _vehicle modelToWorldVisual[ _minX, _minY, _minZ ], _vehicle modelToWorldVisual[ _minX, _minY, _maxZ ], _color ];
	drawLine3D[ _vehicle modelToWorldVisual[ _minX, _maxY, _minZ ], _vehicle modelToWorldVisual[ _minX, _maxY, _maxZ ], _color ];
	drawLine3D[ _vehicle modelToWorldVisual[ _maxX, _maxY, _minZ ], _vehicle modelToWorldVisual[ _maxX, _maxY, _maxZ ], _color ];
	drawLine3D[ _vehicle modelToWorldVisual[ _maxX, _minY, _minZ ], _vehicle modelToWorldVisual[ _maxX, _minY, _maxZ ], _color ];
	
	
	drawLine3D[ _vehicle modelToWorldVisual[ _minX, _minY, _minZ ], _vehicle modelToWorldVisual[ _minX, _maxY, _minZ ], _color ];
	drawLine3D[ _vehicle modelToWorldVisual[ _minX, _maxY, _minZ ], _vehicle modelToWorldVisual[ _maxX, _maxY, _minZ ], _color ];
	drawLine3D[ _vehicle modelToWorldVisual[ _maxX, _maxY, _minZ ], _vehicle modelToWorldVisual[ _maxX, _minY, _minZ ], _color ];
	drawLine3D[ _vehicle modelToWorldVisual[ _maxX, _minY, _minZ ], _vehicle modelToWorldVisual[ _minX, _minY, _minZ ], _color ];
	
	
	drawLine3D[ _vehicle modelToWorldVisual[ _minX, _minY, _maxZ ], _vehicle modelToWorldVisual[ _minX, _maxY, _maxZ ], _color ];
	drawLine3D[ _vehicle modelToWorldVisual[ _minX, _maxY, _maxZ ], _vehicle modelToWorldVisual[ _maxX, _maxY, _maxZ ], _color ];
	drawLine3D[ _vehicle modelToWorldVisual[ _maxX, _maxY, _maxZ ], _vehicle modelToWorldVisual[ _maxX, _minY, _maxZ ], _color ];
	drawLine3D[ _vehicle modelToWorldVisual[ _maxX, _minY, _maxZ ], _vehicle modelToWorldVisual[ _minX, _minY, _maxZ ], _color ];
};

TAG_fnc_getBounds = {
	params[ "_vehicle" ];
	
	boundingBoxReal _vehicle;
};

TAG_vehicleBounds = this call TAG_fnc_getBounds;
[] call TAG_fnc_addDrawEvent;

All lines seem ok(all drawn the same) and I see no weird offset from physical model in game(unlike your video).

 

 

 

  • Like 3

Share this post


Link to post
Share on other sites
[] spawn
{
	onEachFrame
	{
		car1 call
		{
			private _obj = _this;
			_bb =
			{
				_bbx = [_this select 0 select 0, _this select 1 select 0];
				_bby = [_this select 0 select 1, _this select 1 select 1];
				_bbz = [_this select 0 select 2, _this select 1 select 2];
				_arr = [];
				0 =
				{
					_y = _x;
					0 =
					{
						_z = _x;
						0 =
						{
							0 = _arr pushBack (_obj modelToWorld [_x, _y, _z]);
						} count _bbx;
					} count _bbz;
					reverse _bbz;
				} count _bby;
				_arr pushBack (_arr select 0);
				_arr pushBack (_arr select 1);
				_arr
			};
			bboxr = boundingBoxReal _obj call _bb;
			for "_i" from 0 to 7 step 2 do
			{
				drawLine3D
				[
					bboxr select _i,
					bboxr select (_i + 2),
					[0, 1, 0, 1]
				];
				drawLine3D
				[
					bboxr select (_i + 2),
					bboxr select (_i + 3),
					[0, 1, 0, 1]
				];
				drawLine3D
				[
					bboxr select (_i + 3),
					bboxr select (_i + 1),
					[0, 1, 0, 1]
				];
			};
		};
	};
};

Slightly tweaked code from KillzoneKid.

http://killzonekid.com/arma-3-bounding-box-utility/

 

Will use your code above. Looks great, in the video. I notice you are using modelToWorldVisual instead of modelToWorld commnad. Your draw line function is very simple compared to the one I linked as well.

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

×