Results 1 to 3 of 3

Thread: a problem about ROTATION, thanks.

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    China
    Posts
    9

    a problem about ROTATION, thanks.

    I want image rotation controled by hand.
    For example if i press left key then image rotate horizontally,
    I want to control the image in 6 direction(left ,right ,up ,down ,outside and inside according to the screen).
    At first I use glRotatef(X.XX,1.0,0.0,0.0);glRotatef(X.XX,0.0,1.0 ,0.0);glRotatef(X.XX,0.0,0.0,1.0);
    But it can't rotate according to screen, later rotate axis was affected by the former rotation.if have a example code will be the best.

    thanks a lot, help me please.
    my e-mail: arjie_yes@hotmail.com

  2. #2

    Re: a problem about ROTATION, thanks.

    If I understand right you only want the rotation to work once for each axis at a time...

    EG... Pressing UP/DOWN will only rotate the object on the y axis and leaves the x and z axis alone... similar for LEFT/RIGHT for x and +/- for z

    If so then I would suggest that you use 3 live variables xRot,yRot and zRot and 3 stored variables oldx,oldy,oldz and do something like the following:

    Scene
    FirstPartOfScene();
    glPushMatrix();
    glRotatef(xRot,1,0,0);
    glRotatef(yRot,0,1,0);
    glRotatef(zRot,0,0,1);
    DrawObject();
    glPopMatrix();
    RestOfScene();

    Keys
    if (key == UP) yRot++;
    if (key == DN) yRot--;
    if (key == LT) xRot++;
    if (key == RT) xRot--;
    if (key == '+') zRot++;
    if (key == '-') zRot--;

    Something like this would keep the history of the rotation angles but would only rotate the angles on the next scene draw if the appropriate button was drawn otherwise the last angle used when be kept and thus no rotation.

    Theoretically anyway... I did a quick test with one of my programs and this theory worked... just remember the Pop and Push Matrix to make sure that the object rotates on its own axis.

    Hope this helps somewhat..

    Tina
    Learning OpenGL while working on sourceforge projects:
    https://sourceforge.net/projects/simulant/ and
    https://sourceforge.net/projects/projectnova/

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    China
    Posts
    9

    Re: a problem about ROTATION, thanks.

    thanks for tina.
    I do as your think at first,but I need continuesly change the rotation angle.And later I use glMultMatrixf(float &a);It can rotate at each own asix.But It can't rotate according to the screen(in another word, rotate in a fixed coordinate, image rotate the rotate asix didn't rotate).

Similar Threads

  1. Rotation problem.
    By Joshhua5 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-18-2011, 05:31 AM
  2. problem with rotation
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-08-2005, 07:25 PM
  3. need help with this rotation problem
    By imported_spooky in forum OpenGL: General
    Replies: 1
    Last Post: 04-15-2004, 11:08 PM
  4. rotation problem
    By hoganh in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-28-2003, 08:02 AM
  5. Rotation problem, i even do a WEB page to let you see my problem
    By sicklab in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-19-2000, 12:47 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