Results 1 to 6 of 6

Thread: How to use glTranslate to do "pan"?

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2003
    Posts
    5

    How to use glTranslate to do "pan"?

    I post this on Math and Algorithms yesterday. However, no one gave any suggestion. Perhaps I post it on a wrong place. I post it here and hope someone can help me. Thank you very much and sorry for the cross post.

    I draw some object and would like to do "pan". I have some trouble to reach what I want. Here is what I want: when I move my mouse, I hope the object I draw can follow my mouse point.

    I tried 2 ways:
    Way 1
    1) LoadIdentity; 2) Rotate; 3) Translate; 4) Draw Object
    The object move along the rotated coordinate system instead of the original coordinate system;

    Way 2)
    1) LoadIdentity; 2) Translate; 3) Rotate; 4) Draw Object
    The object moves fine. However, when I try to rotate the object, I want to rotate it around the original coordinate system, not the local one, or the translated one.

    How can I solve my problem? Thank you very much.

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    6

    Re: How to use glTranslate to do "pan"?

    What do you mean by the "original" system? A picture would clear this out very much. I guess a glRotated(angle1); glTranslated(pos); glRotated(-angle1); glRotated(angle2); is what you are looking for. Here angle2 means the one you already have, angle1 is the other rotation.

    But I'm still very confused, I'd say the original coordinate system _is_ the local one (that's what you get with glLoadIdentity()).

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2003
    Posts
    5

    Re: How to use glTranslate to do "pan"?

    When I said "original" system, I mean the one that I get with glLoadIdentity(), or the fixed screen coordinate system. When I do "pan" operation with my mouse, I want the object to move in the screen coordinate system. After that, if I would like to rotate the object, I want it rotate around the screen coordinate system, or the center of the screen, instead of the translated one. Did I make it clear? Thank you very much for your reply. Any suggestion?

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    6

    Re: How to use glTranslate to do "pan"?

    Might be my English which isn't too good but I still don't get the idea

    So, what would you like to rotate the object around. The origin, the objects center or some other point; should the object move because of the rotation or stay put but just turn?

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2009
    Posts
    22

    Re: How to use glTranslate to do "pan"?

    gardener,

    gluUnProject() may be helpful to you:

    http://www.opengl.org/documentation/...unproject.html

    In the simplest case, you can pass the resulting objX, objY, objZ values into a glTransform() call. Note, though, that the Z value you get back will depend on the value of winZ that you pass in. You can pass in 1.0 for winZ and then ignore the outputting objZ, replacing it with your own Z position, if you like.

    - Sean



  6. #6
    Junior Member Newbie
    Join Date
    Sep 2003
    Posts
    5

    Re: How to use glTranslate to do "pan"?

    Thank you for your reply. When I send a "rotate" command, I want the object to rotate around the axes of the coordinate system after glLoadIdentity(), not the coordinate system attached to the object. When I do glTranslate, I also want the object to move along the the axes of the coordinate system after glLoadIdentity(), not the coordinate system attached to the object. In this case, no matter what is the state of the local coordinate system(object coordiate system), when I do "pan" operation, my object will follow my mouse to move left/right or up/down, instead of moving along the coordinate system attached to the object. Hope you understand my problem.

Similar Threads

  1. Switching between "arcball" and "fps-style" camera rotation
    By bsabiston in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-31-2017, 12:37 PM
  2. egl gles2 "function is no-op" "Mesa: User error"
    By unixmania in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-17-2013, 05:30 AM
  3. Replies: 1
    Last Post: 10-26-2012, 02:19 AM
  4. opengl & linux -- "GLTools.h"&"GLShaderManager.h"
    By ggeo1 in forum OpenGL: Linux
    Replies: 1
    Last Post: 03-07-2011, 08:39 AM
  5. "best" linux dist for a "Gelato" render farm?
    By ArtificialArtOfficial in forum OpenGL: Linux
    Replies: 10
    Last Post: 12-23-2007, 01:02 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