Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: What is the correct way to pan, zoom and rotate?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Canada
    Posts
    173

    What is the correct way to pan, zoom and rotate?

    Hello,

    I would like o know what is the correct way to pan, zoom and rotate an object:

    1. Use only gluLookAt
    2. Use glTranslate (to pan), glRotate (rotate) and glScale (to zoom)
    3. Use glTranslate (to pan), glRotate (rotate) and change the projection matrix (to zoom).
    4. Use glTranslate (to pan and zoom), glRotate (rotate).

    Thanks in advance.

    Billy. http://planeta.clix.pt/billy/
    Billy

  2. #2
    Member Contributor nemesis's Avatar
    Join Date
    Nov 2001
    Posts
    80

    Re: What is the correct way to pan, zoom and rotate?

    Hi billy,

    I think there is no absolut correct way to do that, it depends. What exactly do you want to do?

    -nemesis-

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Blacksburg, VA, USA
    Posts
    9

    Re: What is the correct way to pan, zoom and rotate?

    I would most definitely use #4. I'm not totally sure what you mean by zoom an object, because if I were to have a 'zoom' feature, I would say that you should decrease your field of view for the duration of the zoom, but that's for scene zooming, not object zooming.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Augsburg, Germany
    Posts
    334

    Re: What is the correct way to pan, zoom and rotate?

    I never use glRotate because of the gimble lock. Build up a rotation matrix and multiply it with the actual rotation position (glGet on the actual matrix).

    But it depends on the purpose of course.


    Kilam.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Canada
    Posts
    173

    Re: What is the correct way to pan, zoom and rotate?

    This is for a CAD program. Every CAD package has a pan, zoom and rotate. This is to view a single object.

    I have a orthographic projection.

    The pan works quite well with glTranslate, I am finding out that glRotate is not the best to rotate object. I agree with you kilam. Maybe I can find a better solution using my own matrix.

    Do you think I should use glScale to zoom?
    Billy

  6. #6
    Senior Member Regular Contributor
    Join Date
    Apr 2011
    Posts
    288

    Re: What is the correct way to pan, zoom and rotate?

    I use glOrtho to zoom.

  7. #7
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Augsburg, Germany
    Posts
    334

    Re: What is the correct way to pan, zoom and rotate?

    I'm working on a CAD package too Here's how I do it:

    Rotation:
    I hold my own rotation matrix. When starting, it's a identity matrix. Every time the user rotates I calculate a rotation matrix from the user rotation. Then I multiply this onto the viewing matrix.

    Zooming in ortho:
    Do _not_ use glScale. This scales the normal vectors also! I always adjust the zoom by calling glOrtho with the extents of my scene translated to 2D.

    Kilam.

  8. #8
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Austria
    Posts
    21

    Re: What is the correct way to pan, zoom and rotate?

    Originally posted by billy:

    1. Use only gluLookAt
    2. Use glTranslate (to pan), glRotate (rotate) and glScale (to zoom)
    3. Use glTranslate (to pan), glRotate (rotate) and change the projection matrix (to zoom).
    4. Use glTranslate (to pan and zoom), glRotate (rotate).

    2.
    As far as I know the only Problem of glScale is that the light appears more bright. If you need lightening then I think you can enable GL_RESCALE_NORMALS for correct lightening because every vertex has to be scaled by the same value.
    Another way (but I haven't tried this) is to divide the light by the scalefactor.

    Correct me if I'm wrong.

  9. #9
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Canada
    Posts
    173

    Re: What is the correct way to pan, zoom and rotate?

    Yes, I have noticed that when I use glScale, the render changes. This is because I am scaling the object but the light remains in the same position, right?
    Billy

  10. #10
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Augsburg, Germany
    Posts
    334

    Re: What is the correct way to pan, zoom and rotate?

    The brightness change is because the brightness is the scalar product of the reversed light vector and the normal of the vertex. This vectors have to have length 1. As glScale scales normal vector, the brightness changes too.

    Automatic normalization of OpenGL is not good, as it is awful slow. It has to normalize all normals of the object each frame. And this involves a square root...


    Kilam.

Page 1 of 2 12 LastLast

Similar Threads

  1. How to pan, rotate, zoom object in 3D in glOrtho() view?
    By avstenit in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-06-2013, 05:58 AM
  2. rotate, zoom and panning in ogl steps
    By ahuarte in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 02-11-2002, 10:31 PM
  3. rotate, zoom and panning
    By ahuarte in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-07-2002, 09:00 AM
  4. rotate, zoom, pan
    By arung in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-03-2001, 06:22 PM
  5. how to rotate and zoom at the same time ?
    By arnott in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-29-2000, 07:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean