Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: zoomWithRespect to model center point.

  1. #1
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Posts
    111

    zoomWithRespect to model center point.

    Dear Friends
    Currently I am implementing zooming in orthographic projection. and I am scaling sa below.
    Code :
    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

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2010
    Posts
    209

    Re: zoomWithRespect to model center point.

    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:

    Code :
    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.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Posts
    111

    Re: zoomWithRespect to model center point.

    Thats a great help dear Mukund. I'll try this way. Thanks a lot. Sujan

  4. #4
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Posts
    111

    Re: zoomWithRespect to model center point.

    Its working MuKund Thanks a lot. Sujan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •