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 2 of 2

Thread: need help with this rotation problem

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2004
    Posts
    7

    need help with this rotation problem

    Hi i am having real trouble trying to solve this problem

    I have a model loaded into a opengl window

    I want the user to be able to rotate the model around the current upvector by draging the mouse left/right on the window, and around the current right vector, draging the mouse updown.

    Imagine this, default upVector=(0,1,0). If you rotate this 90deg ccw on the yz plane your new up vector will be (0,0,-1). Once the model is in this position any left/right drag of the mouse to uspdate the rotation around the (0,1,0) axis will make it rotate around the old axis, which is now pointing in a wrong direction. At his point when i move the mouse left and right the model should rotate around (0,0,-1) which is the -z axis, not around the old y axis.

    How can i do this, using the glrotate command, specificly how do i find the current up vector, after the model has been rotated from the default, i cant use the default upvector, becasue that now points in a ddifferent location

    any help appreciated

    thanks

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    857

    Re: need help with this rotation problem

    Whenever you rotate your object, apply the inverse rotation to your "up" and "right" vectors. This will keep them properly aligned to the camera.

    Alternatively, the first two columns of the modelview matrix are your world-space right and up vectors, so you can extract them from there directly.

    -- Tom

Posting Permissions

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