Sign in to follow this  

Centering Geometry in 3D

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

I'm working on a tool that displays and edit 3D models. I'm trying to center the 3D model in the viewport such that it's bounding box in window space appears centered to the viewer and at the same time the model is guaranteed to be within the near and far clipping planes. Translating the model based on it's AABB center in 3D did not work well because the object will not be perfectly centered in viewport if it has parts of it sticking out toward the viewer - closer to the viewer in z direction. Any ideas?

Share this post


Link to post
Share on other sites
You don't want to calculate the bounding box, but bounding _sphere_, I think? This way, when you rotate the object, it will still stay between near and far clipping plane.

This is some code where I did just that: http://github.com/funkybit/objloader/blob/master/StaticMesh.cpp#L325

Share this post


Link to post
Share on other sites

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