Jump to content
  • Advertisement
Sign in to follow this  
ankhd

Having Trouble converting a Rectangle to a AABB

This topic is 3803 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

Hi all, I've looked all over the place all day. I have this RECT {0, 0, 5120, 5120} now to convert this to a AABB is this the right way AABB.min.x = 0; AABB.min.y = 0; AABB.min.z = 0; AABB.max.x = 5120; AABB.max.y = 10; AABB.max.z = 5120; please need help I can Get it to work if I use D3DXCreateBox and then use D3DXComputeBoundingBox with bounds but I cant keep calling this all the time in the render function.

Share this post


Link to post
Share on other sites
Advertisement
(asuming C++ here)

that rect initialisation initialises like so

RECT r = {left, top, right, bottom}
RECT r = {0, 0, 5120, 5120}


(from http://msdn2.microsoft.com/en-us/library/a5ch4fda(VS.71).aspx )

therefore your bounding box should look more like

AABB.min.x = r.left;
AABB.min.y = r.bottom;

AABB.max.x = r.right;
AABB.max.y = r.top

No idea where you're grabbing your z components from, but that's the AABB based on the XY dimensions.

Share this post


Link to post
Share on other sites
Quote:
Original post by Winegums
your bounding box should look more like

AABB.min.x = r.left;
AABB.min.y = r.bottom;

AABB.max.x = r.right;
AABB.max.y = r.top


This will make the AABB's width and height be twice the amount of the RECT. Also, with RECTs, bottom is greater than top (because in screen coordinates, y increases down). So it should be:

AABB.min.x = r.left / 2.0f;
AABB.min.y = r.top / 2.0f;

AABB.max.x = r.right / 2.0f;
AABB.max.y = r.bottom / 2.0f;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!