3ds model off-center when rendered with opengl

Started by
3 comments, last by kman12 18 years, 10 months ago
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
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.
It is symetric to some degree, but not really enough for this to be a permanent solution.
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
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

This topic is closed to new replies.

Advertisement