Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

TipTup

Bounding Boxes?

This topic is 6621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Well a bounding box is just an invisible structure that fits around your object (irregaurdless of if the object is 2d or 3d).

If we were doing 2d collision detection on a 32x32 sprite then you'd do this:

// The rect structure takes in 4 points which creates a
// rectangle. The point order is LEFT(x1),TOP(y1), RIGHT(x2),
// BOTTOM(y2)
RECT BoundingBox = { 0, 0, 32, 32 };

then you'd check for collisions by doing this:

if (BoundingBox.bottom < Source.top || BoundingBox.top > Source.bottom || BoundingBox.right < Source.left || BoundingBox.left > Source.right)
// A collision occurrd and it's time to do something else.
return true;

Now in 3d we have to deal with the z coordinate. So this changes our bounding box into a bounding cube. Though most people still refer to it as a bounding box.

Now figure out how High, wide, and long your model is at it's highest and lowest points. Now what you do is build a invisible cube around your model using the high & low points. Now that your cube is created you need to check for collisions. The collision detection is nothing more than testing the points and seeing if anything falls in between those points. It's quite a large if statement in 3d but once it's done you can re-use it. I'd suggest making a function to test for collisions that way you only have to write it once. Anyway good luck.



Edited by - evaclear on September 1, 2000 11:41:28 PM

Share this post


Link to post
Share on other sites
hi,
bounding boxes can be very powerful and acurate. As i explain in an another thread few days ago, you can build a hierarchical tree of bounding boxes. look at here for a very general idea.


ECLIPSE DE SOLEIL PAR NOTRE LUNE...lunasol

Share this post


Link to post
Share on other sites
I meant bounding boxes which aren''t gigantic and say you have a stick figure instead of having one big box, you have individual ones rotated so they cover the whole figure. (3d)

-TipTup
TipTup.Com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!