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: Local Axis Rotation Problem

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2009
    Location
    Invercargill, Southland, New Zealand
    Posts
    17

    Local Axis Rotation Problem


    Hi. I have a 3d rotation problem that really shows up my lack
    of 3d knowledge lol. I'm trying to move a camera around using
    the arrow keys. Left-right arrow is supposed to rotate about
    local camera z axis, and up-down around local x-axis. But
    this code seems to rotate around the origin. Is it something
    to do with the order of operations?
    Any help greatly appreciated.

    //================================================== ===

    SwitchTo3D(WINDOW_WIDTH, WINDOW_HEIGHT);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    /// Load ship Position Matrix (camera)

    XFORM3D m;
    XForm3D_SetIdentity(&m);
    XForm3D_RotateZLocal(&m, Float_DegToRad(AngleZ));
    XForm3D_RotateXLocal(&m, Float_DegToRad(AngleX));
    XForm3D_SetTranslation(&m, Pos.x, Pos.y, Pos.z);
    glLoadMatrixf((GLfloat *)&m);

    DrawPlanet(Pos);

    //================================================== ===

  2. #2
    Junior Member Regular Contributor
    Join Date
    Apr 2006
    Location
    Kyoto.
    Posts
    126

    Re: Local Axis Rotation Problem

    It's difficult to say without knowing what is going on inside your XForm functions. At a guess I'd say you need to rotate the Pos.x/y/z values by the transpose(?) of the matrix you created in XFORM3D m.

Posting Permissions

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