PDA

View Full Version : zoomWithRespect to model center point.



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


glScalef(zoomFactor,zoomFactor,zoomFactor);

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

Mukund
11-30-2011, 10:19 AM
Hello,

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);
glScalef(zoomFactor,zoomFactor,zoomFactor);
glTranslatef(-Wx, -Wy, -Wz);
// Draw model here.



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

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

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