Home   Help Search Login Register  

Author Topic: Test if position is inside bounds of BoundingBox  (Read 2802 times)

0 Members and 1 Guest are viewing this topic.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Test if position is inside bounds of BoundingBox
« 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
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Test if position is inside bounds of BoundingBox
« Reply #1 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...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Test if position is inside bounds of BoundingBox
« Reply #2 on: 15 Dec 2008, 10:51:24 »
Yes sir, I meant arma.   Sry about that, and thanks for moving it!
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Test if position is inside bounds of BoundingBox
« Reply #3 on: 15 Dec 2008, 12:06:15 »
Smells like collusion detection. If so, it could probably be done with intersect quite easily.

May I ask what do you want to do with this function?
try { return true; } finally { return false; }

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Test if position is inside bounds of BoundingBox
« Reply #4 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, if you want to take a peek.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Test if position is inside bounds of BoundingBox
« Reply #5 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. 
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Test if position is inside bounds of BoundingBox
« Reply #6 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.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)