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

Thread: successive rotation

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    4

    Exclamation successive rotation

    hello,
    i am kind of new to openGL,and i faced this biiig probleme

    so let's say i rotate my cube arround X , when i rotate again on Y it ends up rotating arround Z
    i did some research andi found out that glrotatef rotate evrything including the axis


    so basically what i want is a way to rotate arround a specific axis all the time (world axis in my case since i need to make a model for rubik's cube 3X3X3 )

    thanks in advance

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    4
    is my question more than beginner level or what???????????

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882
    You need to do some basic reading on how coordinate frame transforms work. They are applied to the local (then-current) coordinate frame, not any given global coordinate frame.

    The OpenGL Programming Guide has a good description of how to think about successive modeling transforms, among others.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    4
    thank you for responding,but it would be helpfull if you give me more direct information or reading matrial
    (btw I can have axess to almost any book so don't feel restrained when giving recomondation)

  5. #5
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882
    thank you for responding,but it would be helpfull if you give me more direct information or reading matrial
    Sure thing.

    • OpenGL Programming Guide: "Viewing" chapter (Chapter 3 in my old 4th ed) -- focus particularly on the "Thinking about Transformations" section (A quick google will turn this up on-line. For instance here)

    If you have any other transformation-related questions, look for the answers in there.

    For a good on-line quick ref guide to OpenGL transforms:


    Googling around, looks like:


    but don't have it handy here to read so I can't vouch for it.
    Last edited by Dark Photon; 07-15-2012 at 01:05 PM.

  6. #6
    Intern Contributor
    Join Date
    Apr 2012
    Posts
    90
    Quote Originally Posted by flashcs5 View Post
    ...i rotate my cube arround X , when i rotate again on Y it ends up rotating arround Z
    This is a very common problem encountered by people new to OpenGL or computer graphics in general.
    The easiest way to code up rotations is to do something like ..
    Code :
    glRotatef (xrot, 1,0,0);
    glRotatef (yrot, 0,1,0);
    glRotatef (zrot, 0,0,1);
     
    Draw_Objects ();
    This results in an Euler rotation sequence, where the successive rotations are not necessarily around body axes or world axes. Most of the time this is o.k., but in special cases (which yours seems to be), you may have to resort to something more involved. With the help of another contributor, I posted some OpenGL code that shows a way to do both world or object space rotations. If you take the time to look at it, you'll see that it is quite a bit more involved than the code above. Good luck ...

    http://www.mfwerner.addr.com/OpenGL/...tions/Source.c

  7. #7
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    4
    thankx the both of you Carmine and Dark Photom
    sound like i have alot of reading to do,and the code is exactly what i want to do (the screen space rotate part )

Posting Permissions

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