Jump to content
  • Advertisement
Sign in to follow this  
Ritti

Bounding Sphere Position

This topic is 2641 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 have a problem with calculating the position of a boundingsphere for an animated mesh (.x file)

With D3DXFrameCalculateBoundingSphere( g_pFrameRoot[0], &g_vObjectCenter, &g_fObjectRadius ) ;

I can calculate the center every frame, but I think the center is referred to the mesh (and not to the world), so it won't change if I move the mesh with D3DXMatrixTranslation.

So my question is: How do I calculate the x,y,z coordinates of the Sphere/Box?

Btw: to recalculate the sphere every frame seems a little inefficient, so how can I make this less CPU intensive?

I hope somebody can help me.

Thanks in advance

Ritti

Share this post


Link to post
Share on other sites
Advertisement
I think you have answered your own question twice in your post :)

In order to move the bounding sphere around in the world coordinates, you apply the same transformations to the bounding sphere that you do to your mesh. This more or less equates to translating the center of the sphere the same amount as your mesh is translated.

As far as doing it every frame - if the function returns the object space bounding box, and your geometry isn't changing every frame, then you can trivially save a copy of the bounding sphere data at startup. Then you just transform that data every frame to find the new bounding sphere location in world space.

Share this post


Link to post
Share on other sites
Well, yes I really answered my own question but I didn't realize it ^^

Thank you for you help you saved me a lot of time =)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!