Results 1 to 3 of 3

Thread: Independent Rotation Problems

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Oak Flats, NSW, AUS
    Posts
    3

    Independent Rotation Problems

    I'm probably going to be seriously flamed as some kind of uber-newbie here, but I am having difficulty getting my axes of rotation to work independantly.

    Eg. I store three values, H, R and B for each object in the scene. These are supposed to reflect axes of rotation BASED ON THE DIRECTION IN WHICH THE OBJECT IS FACING. So, as an example, if I increase 'H', the 'front' of the object should always raise up, regardless of other rotations.

    The following code makes 'R' an independant axis (it is not effected by the others), simply because it is 'first'...

    glRotated(B,0,0,1);
    glRotated(H,1,0,0);
    glRotated(R,0,1,0);

    I can make 'H' an independant axis by compensating for 'R'

    glRotated(R,0,1,0);
    glRotated(H,1,0,0);
    glRotated(-R,0,1,0);

    But this then throws 'R' out, making it effected by 'H'.

    I know there is a way to do this. I know it is probably incredibly simple. I also know that I an having a great deal of trouble figuring out how the @*$& it is done! Can someone give me a little help please?

    Thanks.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Greece
    Posts
    477

    Re: Independent Rotation Problems

    I can't say I can positively answer that question but maybe I can help out a bit.Those BHR angles you're reffering to are more commonly called Euler angles or yaw,roll and pitch.Now what you want to do is represent an object's orientation.Euler angles are a way to do this(no the best),so are matrices and quaternions.I suggest some google research with the terms I've mentioned to see if you can find anything useful.Be careful though that although quats or matrices might look cool you'd better stick with more simple things first if they do the job(you won't be doing any slerp yet will ya?).Also I've read in some docs I had lying around(the matrix and quaternion faq,you'll propably come across it in your search.Read it,at least the matrix portion to begin with) that the usual way to combine these roations is x-axis first then y then z,but I can't guarantee it will work for you.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Independent Rotation Problems

    Very simple by using glPush/PopMatrix commands.

    The clock program on my website is an good example: http://www.angelfire.com/linux/nexusone/

    Here is a simple usage:
    glRotatef(rot, 1, 0, 0); // rotate

    glPushMatrix()// save matrix
    glRotate(rot_a,0,0,1); // Rotate object a only
    draw_object_a() // Note this object is still effected by the rotate that was done before the push.
    glPopMatrix() // load saved matrix
    // Note now matrix is back to where is was before operations inside the push/pop, only objects inside the push/pop matrix are effected.

    glPushMatrix()
    glRotate(rot_b,0,0,1);
    draw_object_b() // Also this object is effected by the rotate done before any push/pop
    glPopMatrix()


    Originally posted by IgnoranceIsBliss:
    I'm probably going to be seriously flamed as some kind of uber-newbie here, but I am having difficulty getting my axes of rotation to work independantly.

    Eg. I store three values, H, R and B for each object in the scene. These are supposed to reflect axes of rotation BASED ON THE DIRECTION IN WHICH THE OBJECT IS FACING. So, as an example, if I increase 'H', the 'front' of the object should always raise up, regardless of other rotations.

    The following code makes 'R' an independant axis (it is not effected by the others), simply because it is 'first'...

    glRotated(B,0,0,1);
    glRotated(H,1,0,0);
    glRotated(R,0,1,0);

    I can make 'H' an independant axis by compensating for 'R'

    glRotated(R,0,1,0);
    glRotated(H,1,0,0);
    glRotated(-R,0,1,0);

    But this then throws 'R' out, making it effected by 'H'.

    I know there is a way to do this. I know it is probably incredibly simple. I also know that I an having a great deal of trouble figuring out how the @*$& it is done! Can someone give me a little help please?

    Thanks.

Similar Threads

  1. Rotation problems
    By l33tz in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-20-2011, 08:37 PM
  2. Transformations: scene/object independent rotation
    By OglNewb in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-18-2010, 04:07 AM
  3. order independent transparency problems in NVIDIA 8XXX GPUs
    By yalmar in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 07-10-2007, 08:46 AM
  4. Independent Rotation
    By fanousz in forum OpenGL: Basic Coding
    Replies: 15
    Last Post: 05-23-2005, 07:25 AM
  5. Rotation Problems
    By atubular in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-30-2000, 08:33 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