in addition to some of the problems I mentioned before, some have just come up to this bottom line: centering an object at the origin. What are some techniques I could use to attain that goal? I appreciate your effort.
You can find the position of your object then translate it to the negative of the position you found.
example: object.x=5, object.y=1, object.z=0;
glTranslatef(-object.x, -object.y, -object.z);
this will place the object at 0,0,0
This doesn’t seem to work for the perspective view… :\
find the center of your object and
glTranslatef( - center_object.x, -center_object.y, -center_object.z)
Originally posted by ThunderSoul:
This doesn’t seem to work for the perspective view… :[/b]
The modelview matrix is independent of the projection matrix. When you do a translation, the coordinate system goes to the new position regardless of the current projection definitions.Then the projection matrix is applied to clip the objects.Maybe you are clipping the center of your coordinate system.
I should complete my previous post.In perspective mode, we should adjust the znear plane to the value that is greater than 0. As the camera position has been inserted in the point(0,0,0), so we clip this point in the perspective mode. So if you move your object to the point (0,0,0), part of it cannot be seen.
Another issue is about the meaning of the center. 1.default center or 2.the center of the current cordinate system? Obviouslym when you transform the current coordinate system, objects that are drawn after this transformation, use from the new coordinate system.Assum that what does happen when you use from the glVertex*(center_x,center_y,center_z) to draw that object. In this case if we use from the this formula: glTranslatef(-center_x,-center_y,-center_z) we are moving the object to the center of the transformed coordinate system. So the rule that i said in the previous reply about the clipping isn’t correct. But if you mean the DEFAULT (0,0,0)positon, the previous rule about the clipping is correct.
Actually if you want to move the object to the default center of the world coordinate system, you should consider all the transformations–Remember that the scaling transformation changes the units
Thank you very much for your replies… It helped me with my work.