OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: johnnyboy on 15 Dec 2008, 01:29:34

Title: Test if position is inside bounds of BoundingBox
Post by: johnnyboy on 15 Dec 2008, 01:29:34
Howdy gents.  I am totally weak at math, and could use a little help here.

Does anyone know of an existing script/function that can check if a 3D position is inside of a BoundingBox (3D Box)? 

If no existing function, what would the logic psuedo-code be, so I could write my own?

Any help would be appreciated.  Thanks.

Here's the link to the wiki boundingBox function:

http://community.bistudio.com/wiki/boundingBox
Title: Re: Test if position is inside bounds of BoundingBox
Post by: h- on 15 Dec 2008, 09:44:05
Did you by any change mean to post in the ArmA section of the forums (if so, I'll move this there)?
Because boundingbox command doesn't exist in OFP...
Title: Re: Test if position is inside bounds of BoundingBox
Post by: johnnyboy on 15 Dec 2008, 10:51:24
Yes sir, I meant arma.   Sry about that, and thanks for moving it!
Title: Re: Test if position is inside bounds of BoundingBox
Post by: Worldeater on 15 Dec 2008, 12:06:15
Smells like collusion detection. If so, it could probably be done with intersect (http://community.bistudio.com/wiki/intersect) quite easily.

May I ask what do you want to do with this function?
Title: Re: Test if position is inside bounds of BoundingBox
Post by: Spooner on 15 Dec 2008, 12:12:01
Intersect only detects named selections for some reason known to BIS. Since only infantry are fully named, intersect only works for infantry (not vehicles, objects, buildings, etc).

I do both sorts of "collision detection" in SPON LOS (http://www.ofpec.com/forum/index.php?topic=32025), if you want to take a peek.
Title: Re: Test if position is inside bounds of BoundingBox
Post by: johnnyboy on 15 Dec 2008, 21:24:18
@Worldeater:  Thanks.  I'll take a look at intersect.  I'm not really looking for collision detection.  I would like to know if a unit is close to a fence or wall, or close to the outside of a building, etc.  Distance to a near object doesn't work because it's to the center of the object, not the nearest surface of the object.  So if you have a long rectangular object like a building, the unit might be standing inches from a building wall, but the distance to the building center would return meters.

I'm thinking if I take an object's bounding box, expand the box coordinates in all directions by 1/2 meter, I would then have a box that I could test if a unit was within it.  That test is likely simple geometry of a point being within an area.  My problem is I don't understand that math.  Obviously, ARMA trigger detection of units does this math in 2D space.

@Spooner:  Thanks dude.  I'll take a look at SPON LOS.  It may not be what I need, but I know I will learn something cool.  BTW, that holo map is wild. 
Title: Re: Test if position is inside bounds of BoundingBox
Post by: Spooner on 15 Dec 2008, 22:32:57
As I said, intersect only works on infantry, not on buildings or vehicles, so I don't think it will be useful for you.

Well, if you just want to know if a point is inside a boundingBox, then the maths isn't too complex. But as you suggest, if you assume a soldier is 1m across and you increase the boundingBox by 0.5m and treat the soldier as a point, you are sorted.

If you want to know if two boundingBoxes collide in absolute terms, it would be more involved.

Just running the SPON LOS demo should give you a good idea of bounding box dimensions, since it shows you graphically where all the boxes are (there is a screenshot if you don't want to run the demo itself)! Some are significantly larger than they need to be, for example.