Author Message

amilmand

00
Posts: 259

Location: ---
Occupation:
Age:
V$:
#135595   2018-01-13 01:54          
I see, well I see two ways you can implement that for the hackish way you can approximate the box with some smaller triggers with smaller radius (replacing the faces of the box maybe) but this sounds very hackish I would only consider this because multithreading in slrr is very very (very very) dangerous and can easily result in silent crashes,
the other would involve manually checking each like 5 frames (from another script thread) whether the car is in an arbitrary 3D box, your best bet in this case is defining the box in terms of its width height and depth and also two transformations a translation and a YawPitchRoll if you have the box like that you can inverse transform the point(with built in functions Vector3.rotate) you want to check (you will get the point in the boxes space(where the box is centered in (0,0,0) and its rotation is (0,0,0))) and you can use the trivial axisaligned origin centered box case (6 conditionals (whether its x < width/2 && x > -width/2 ... )))

Added 22 minutes later:

That check would look something like this: (I didnt test this thou)
public static int PointInBox(Vector3 boxSize, Vector3 boxPosition, Ypr boxYpr, Vector3 point)
{
	Vector3 p = new Vector3(point);
	p.sub(boxPosition);
	p.rotate(new Ypr(0,0,-boxYpr.r));
	p.rotate(new Ypr(0,-boxYpr.p,0));
	p.rotate(new Ypr(-boxYpr.y,0,0));
	
	if(p.x > -boxSize.x/2.0 && p.x < boxSize.x/2.0 && 
		 p.y > -boxSize.y/2.0 && p.y < boxSize.y/2.0 && 
		 p.z > -boxSize.z/2.0 && p.z < boxSize.z/2.0)
	{
		return 1;
	}
	return 0;
}
Mind you the point above we give as the position of the box is its center.

This post was edited by amilmand (2018-01-13 02:16, ago)