Sign in to follow this  

D3DXComputeBoundingBox

This topic is 4661 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. I would normally just do a search for this on the website but since it is broken right now I have to ask myself. I am not sure how to work this function.... I don't understand what the function wants for the first parameter pFirstPosition.... is it looking for the position of the first vertex of the mesh or the position of the mesh or what? In either case I am also not sure how to go about aquiring this information.... are there any DirectX functions for getting the location of a mesh (or its vertices) in Worldspace or do you have to figure it out yourself? Thanks in advance.

Share this post


Link to post
Share on other sites
D3DXComputeBoundingBox takes as its first argument a pointer to a bunch of D3DXVECTOR3's. So yes, this means that it needs a pointer to the actual vertices of your mesh. You get this pointer by locking your vertex buffer. If you're using objects of ID3DXMesh, then you can call ID3DXMesh::LockVertexBuffer to get this pointer.

The vertices of your mesh do not have to be in world space. The reason for this is that D3DXComputeBoundingBox is just computing general bounding box. The bounding box will be computed in whatever space the vertices of your mesh are stored.

If you want the bounding box in world space, there are two options. The first option is to manually transform each and every single vertex of your mesh into world space and pass this data to D3DXComputeBoundingBox. This is NOT what you want to do. The second option is to compute your bounding box in whatever space your mesh is defined in and then when you need your bounding box in world space, transform just your bounding box into world space using the same matrix you use to transform your mesh into world space. Since a bounding box is simply made up of two vertices, transforming these two vertices manually is much less expensive than the first option.

Hope this helps,
neneboricua

Share this post


Link to post
Share on other sites

This topic is 4661 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this