Jump to content
  • Advertisement
Sign in to follow this  
Silex

3ds model off-center when rendered with opengl

This topic is 4735 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 load a 3ds file into an opengl app and it seems the center of the model is not where the polygons are, so when I try to trackball around it the results are unsatisfactory. Also I need a fairly high degree of precision with regards to the position and pose of the object, and as it stands I have no idea by what amount the polygons are off from the center of the imported 3ds model. I am not the author of the model. Is there a fairly easy way for me to accurately correct this, perhaps when I import the model, without having to change the model I'm importing? Also, I'm not completely happy with the 3ds format (too complex for my needs, couldn't find a nice import library), so if anyone has any suggestions I'd welcome them. Thanks

Share this post


Link to post
Share on other sites
Advertisement
A dirty solution would be to sum up all the x values of your vertices and devide them by the numer of verices (iow, compute an average) and then repeat it for your y and z values.
These avarages would be your new centre-point
If the model isn't symetric I don't think this is a good solution.

Share this post


Link to post
Share on other sites
It is symetric to some degree, but not really enough for this to be a permanent solution.

Share this post


Link to post
Share on other sites
I haven't tried it, but this should work:

1. Compute the averages of the xyz coordinates of the vertices in your model

2. Substract those averages from your vertices:
vertex.x -= averagex;
vertex.y -= averagey;
vertex.z -= averagez;

3. Continue happily

Share this post


Link to post
Share on other sites
Rather than averaging all the points, couldn't you just average the two farthest away from each other for each axis? So then it would be exactly in the middle, without a bias depending on how many points there are on either side.

kevin

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!