Results 1 to 4 of 4

Thread: Camera - Rotation Matrix

  1. #1
    Member Newbie
    Join Date
    Apr 2001

    Camera - Rotation Matrix


    I'm building a camera Class. There, is the private members of the class :

    Code :
    //Camera matrix            
    MATRIX4 CamMatrix;
    // Each axis of the camera
    VECTOR3D CamAxisX; 
    VECTOR3D CamAxisY 
    VECTOR3D CamAxisZ 
    // Direction vector
    VECTOR3D CamView;
    //Position of the camera
    VECTTOR3D CamPos
    So now I will explain what is my problem.
    I want to use my own matrix operation, so I don't want to use glRotated or glTranslated.
    I just need to use a GL command when it time to update the camera so
    glLoadMatrix( CamMatrix )

    Well, now I have no difficulty with translation along an axis. So I can go UP and DOWN, Straf LEFT to RIGHT or move FORWARD and BACKWARD.

    The problem is starting with rotation
    I built a function like this one :

    Camera::Pitch( float Angle )
    // Where Angle could be 15. So add 15
    // to the camera direction (Ex :Look Up)
    // I have/want to update the matrix and the
    // others members of the class.
    // If axis change I need to update it too.
    // I know that I need to apply a rotation
    // (pitch) around the X axis but how ?
    // What I need ? Help please

    A big Thanks

    [This message has been edited by Erakis (edited 06-10-2002).]

  2. #2

    Re: Camera - Rotation Matrix

    If you are going to use glLoadMatrix you might as well store your camera orientation in a matrix ( MATRIX4 CamMatrix) and get rid of those VECTOR3D. A 4x4 matrix is composed of the rotation parts and the position so there is no point storing the info twice.

    If your Matrix4 class is any good it will have all the rotation functions you need otherwise find a class that does have them.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Dec 2001
    Belmont, CA, USA

    Re: Camera - Rotation Matrix

    You will be happy to know that you have lots of redundant data there. In the OpenGL system:

    CamAxisX = (CamMatrix[0],CamMatrix[1],CamMatrix[2])
    CamAxisY = (CamMatrix[4],CamMatrix[5],CamMatrix[6])
    CamAxisZ = (CamMatrix[8],CamMatrix[9],CamMatrix[10])
    CamPos = (CamMatrix[12],CamMatrix[13],CamMatrix[14])
    CamView = -CamAxisZ

    It's relatively easy to create a rotation matrix to rotate around the X, Y, and Z axes -- it should be in any graphics book or any basic info on transformations. Just remember that order is important and you may have to transpose the matrices to account for using a different order.

  4. #4
    Member Newbie
    Join Date
    Apr 2001

    Re: Camera - Rotation Matrix

    First, when I create the rotation matrix :

    Code :
    Camera::Pitch( float Angle )
     // Here I will create a new rotation matrix
     RotationMatrix.RotX( Angle );
    Do I need a rotation matrix for each one (Pitch, Yaw and Roll ) ?

    When those matrix are created, I need to create a new matrix for translation. So

    There, pretend I intercept a keybord key to straf...
    I will do :
    Code :
    TranslationMatrix[12]= -PosX;
    TranslationMatrix[13]= -PosY;
    TranslationMatrix[14]= -PosZ;
    Well, Something is missing or I'm on the right way ?

    On each frame, I update the matrix if it's nessary, with this function :

    Code :
     // I think I need to mult those matrix ?
     // Which order is the best ?
     // Translation * RotationMatrix_X * 
     // RotationMatrix_Y * RotationMatrix_Z; 
    A BIG Thanks again.

    [This message has been edited by Erakis (edited 06-10-2002).]

Similar Threads

  1. Extracting only z rotation matrix from a rotation matrix
    By ssyybbyy in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-06-2014, 05:57 AM
  2. Matrix scale, rotation and translation with repsect to 2D "camera"
    By kevinfishburne in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-17-2012, 02:18 AM
  3. Replies: 1
    Last Post: 04-16-2010, 02:59 PM
  4. camera rotation matrix calculation
    By imported_Kirill in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 01-29-2001, 04:26 AM
  5. camera rotation matrix calculation
    By imported_Kirill in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-29-2001, 12:39 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