View Full Version : zoomWithRespect to model center point.

11-30-2011, 06:30 AM
Dear Friends
Currently I am implementing zooming in orthographic projection. and I am scaling sa below.


But it's zooming with respect to (0,0,0) point. so my when zooming its not proper for visualization.
How can I zoom the model with respect to its center point.
e.g if the center point is (cx,cy,cz) then how can scale the model with respect to this point.
Any help would be highly appreciated. Thanks Sujan

11-30-2011, 09:19 AM

You can try this:

Say the model is at (Wx, Wy, Wz) in world coordinates, bring the model to the origin. So, do a translate of (-Wx, -Wy, -Wz). Scale it, then translate back.

So, your order in gl calls would be:

glTranslatef(Wx, Wy, Wz);
glTranslatef(-Wx, -Wy, -Wz);
// Draw model here.

PS: (Wx, Wy, Wz) is the point about which you wish to scale.

11-30-2011, 09:36 AM
Thats a great help dear Mukund. I'll try this way. Thanks a lot. Sujan

11-30-2011, 08:13 PM
Its working MuKund Thanks a lot. Sujan