Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / Bounding Boxes in DirectX9 Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

April 21, 2005, 02:47 PM

hi guys
i have created a bounding Box around a Mesh in directX9.
The problem is that this box is not following the car while it moves, rotate etc...
anybody know if there is a function for that, or got an idea to make it work all the time whatever movement i ask the car to do.


April 21, 2005, 03:45 PM

As long as you transform your bounding box the same way you transform the mesh, it should follow it perfectly. Make sure that you transform, rotate, and scale the bounding box every time you do the same to the mesh.


April 21, 2005, 04:59 PM

If it's an axis-oriented bounding box, you will have to recalculate it when the mesh changes its transformation. You can calculate a world-space bounding box from the transformed corners of the object space bounding box, though calculating it from the actual world space vertices would give a more accurate fit.


April 22, 2005, 06:39 AM

thanks guys for your replies
the bounding box is giving me a 0 related coordinate:
ex: car position(0,0,-19)
bounding box min(-2.5,0,-6.5)
max (2.5, 4,5.5)

i manage to rotate the Bounding box
it's only 90 degrees rotations :-)
now it seems that depending the position of the car, the bounding box is not accurate.
instead of having a left down corner and rigth up corner
after a rotation and in the direction of the axis x negative
i sometimes get to a Left top corner and right down corner
in the case of a Z coordinate positive

what do you think, should i make special cases depending if the value on the axis are negative or positive. i find that weird and i am affraid this is not a good solution.
i don't know if it is clear enough.
thanks all in advance


April 22, 2005, 05:02 PM

Use the local bounding box of the car's mesh. Calulate this centered at 0, so it's just a bounding box of the mesh itself, in objects space, the space of the mesh, not world space. Then just transform this local bounding box the same as you do the mesh. This will create a box that follows the mesh, including orientation and position. That also means you never have to recalculate anything, you're just using a single bounding box with the current transformation matrix.

This thread contains 5 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.