Results 1 to 5 of 5

Thread: Rotating on each of the axies

  1. #1
    Member Newbie
    Join Date
    Mar 2001
    Posts
    48

    Rotating on each of the axies

    I am having problems with rotating on each of the axies independently.

    I want to attach the up and down arrow keys to rotate on one axis and the left and right arrows to another. However when I do this, I have one rotating on one axis and the other rotating clockwise/counter-clockwise in respect with the screen.

    I would be happy if I could have it rotate along the x and y axis independently of each other or having the object rotate in respect with the screen in both rotating directions.

    this is my code so far
    Code :
    ...
    rotate3f(rotatex, 1.0, 0.0, 0.0);
    rotate3f(rotatey, 0.0, 1.0, 0.0);
    ...
     
    Entire another function written in psudeo-code/C++
     
    if (UP    pressed ){rotatex+= 1;}
    if (DOWN  pressed ){rotatex-= 1;}
    if (RIGHT pressed ){rotatey+= 1;}
    if (LEFT  pressed ){rotatey-= 1;}
    Is there something simple that I am missing.

  2. #2
    Junior Member Newbie
    Join Date
    May 2001
    Location
    France
    Posts
    23

    Re: Rotating on each of the axies

    Hi,

    I don't really understand what is your problem but using rotations as you use them is not good. In fact, when you make a glRotate(AngleX, 1.0, 0.0, 0.0) , you change the modelView matrix. So when you make the second glRotate(AngleY, 0.0, 1.0, 0.0) the axis isn't anymore the original Y axis but the new one: the one after you make the rotation on X axis.

    I hope it was your problem.
    TORNIERI Christophe
    Ecole Supérieure en Sciences Informatiques

  3. #3
    Member Newbie
    Join Date
    Dec 2000
    Location
    Donetsk, Ukraine
    Posts
    48

    Re: Rotating on each of the axies

    Try such thing. First, I suggest you to make MATRIX variable, which contains rotation matrix for your cursor. Then, when you need to change it, you should get all your axis rotation matrix independently, transpose them and RIGHTMULTIPLY your MATRIX by these matrices. Excuse me for no code, but I lack time for it.

  4. #4
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    Re: Rotating on each of the axies

    i couldnt really understand your post
    r u seeing 'gimbal lock'?
    have a search on the net for the term + u should find info as to what it is + hopefully info to a solution

  5. #5
    Member Newbie
    Join Date
    Mar 2001
    Posts
    48

    Re: Rotating on each of the axies

    Thanks,

    I got it to work with polar coordinates. I used the UP and DOWN arrows to inc. and dec. the angle phi and LEFT and RIGHT to inc. and dec. the angle theta. With the angles of phi and theta, I calculated where the camera should be placed while looking at the center of the object.

    Why didn't I think of this earlier. No wonder hind site is 20/20.

Similar Threads

  1. Rotating Objects - Light Rotating not expected
    By SparkyNZ in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 08-12-2015, 07:52 PM
  2. Rotating around a point and Rotating across own axis
    By Mighty in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-10-2004, 10:15 PM
  3. rotating and object without rotating its axis
    By scam in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 12-17-2003, 08:30 AM
  4. Local Axies?
    By davekerr in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 01-19-2003, 07:52 AM
  5. Problem rotating parent then rotating children
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-04-2002, 11:15 AM

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