Testing 2 Object Orientated Bounding Boxes
Heya,
I read a lot about bounding spheres and axis aligned bounding boxes, but didn''t really find information on Object Orientated bounding boxes.
In my game, I have several objects including the player (third person). At startup I calculate the bounding boxes. I get 8 Vertices for each box. When the player rotates, I also rotate it''s boundingbox (the 8 vertices). I can''t use a sphere cause the player is a rather complex spaceship and I won''t need the speed effort of first testing a sphere.
So, how can I test these 8 vertices against other (same kind) boundingboxes efficiently?
Also, since the player and the objects can move rather fast should I make a second boundingbox of the way the object and the player have travelled? Like a bbox with the front 4 vertices of the previous bounding box as the backside and the back 4 vertices of the new bbox as the frontside?
Thanks in advance!
Gr,
BoRReL
The point of an axis alligned bounding box, is that you only have to have two verticies. You don''t rotate it, you either calculate a new BBox every time you rotate your model, or find the smallest BBox that the model can freely rotate within. For the latter, the bounding box is simply a cube 2X the distance of the furthest point from the center per side, centered on the same point as your model. For the former, as you rotate just keep track of the minimum and maximum x,y,z as you rotate.
For moving objects, you simply test the smallest BBoxes that enclose the moving BBox. Here min.x = min(min.x,min.x+d.x), etc.
Again, this gives you a quick way to find that objects _DO NOT_ collide, but it probably is not close enough to say that they DO. Lot''s of false alarms with this one.
For moving objects, you simply test the smallest BBoxes that enclose the moving BBox. Here min.x = min(min.x,min.x+d.x), etc.
Again, this gives you a quick way to find that objects _DO NOT_ collide, but it probably is not close enough to say that they DO. Lot''s of false alarms with this one.
Heya,
Thanks! Still I think it''s faster to rotate 8 points than calculating a new axis aligned bbox.
So what I need is just a good implementation of the function
int testCollision(bbox a, bbox b);
with bbox = Vector3D[8];
Won''t the minimum of the minima result in the biggest bbox?
So will I need the max of max.x, max.x+d.x??
Thanks again!
Gr,
BoRReL
Thanks! Still I think it''s faster to rotate 8 points than calculating a new axis aligned bbox.
So what I need is just a good implementation of the function
int testCollision(bbox a, bbox b);
with bbox = Vector3D[8];
quote:
For moving objects, you simply test the smallest BBoxes that enclose the moving BBox. Here min.x = min(min.x,min.x+d.x), etc.
Won''t the minimum of the minima result in the biggest bbox?
So will I need the max of max.x, max.x+d.x??
Thanks again!
Gr,
BoRReL
quote:
Original post by BoRReL
Thanks! Still I think it''s faster to rotate 8 points than calculating a new axis aligned bbox.
Depends on your accuracy needs, and how you are rotating the model, but I found an interesting page that kindof agrees with you. The RAPID collision detection library uses OBB''s, rather than Axis alligned. It''s probably overkill, and aparently a bit of a memory pig, but it looks like what you want. The license is non-commertal only, but it should give you ideas.
HTH.
Just something without much of a meaning. I''m ''working'' on a similiar game and thought i''d try bounding boxes instead of bounding spheres. its something of a mix, i''m using 8 vertices for the corner and transform them, storing the min and max x,y,z. i think thats faster than recalculating the bb for complex objects, though i''m ''wasting'' 10 additional vertices.
results have been (for moving the ships and checking for collision):
#ships bs bb
1 50% 100% (meaning time in percent of the slower one)
25 100% 100%
200 100% 33%
in other words: for just a few ships bounding spheres are faster for a lot of ships bounding boxes save a lot of time (for me at least, probably depending on a million small things *g*)
f@dz
http://festini.device-zero.de
results have been (for moving the ships and checking for collision):
#ships bs bb
1 50% 100% (meaning time in percent of the slower one)
25 100% 100%
200 100% 33%
in other words: for just a few ships bounding spheres are faster for a lot of ships bounding boxes save a lot of time (for me at least, probably depending on a million small things *g*)
f@dz
http://festini.device-zero.de
f@dzhttp://festini.device-zero.de
August 23, 2001 04:18 PM
Thanks!
But hey, I need a bounding box! Since the ship is not quite round, a sphere won''t fit at all and a box could be just good enough.
So how do I test them?
Check if there is a point in box A witch is IN box B?
With IN:
pointA > minB
pointA < maxB,
for x,y and z?
But since my boxes are not axis aligned I have no min and max, but 8 vertices!
Please Help!
Gr,
BoRReL
But hey, I need a bounding box! Since the ship is not quite round, a sphere won''t fit at all and a box could be just good enough.
So how do I test them?
Check if there is a point in box A witch is IN box B?
With IN:
pointA > minB
pointA < maxB,
for x,y and z?
But since my boxes are not axis aligned I have no min and max, but 8 vertices!
Please Help!
Gr,
BoRReL
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement