Results 1 to 2 of 2

Thread: Camera Moving the Wrong Way Along X-Axis?

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2014
    Posts
    10

    Camera Moving the Wrong Way Along X-Axis?

    Hi All,

    I've implemented a first-person camera using OpenGL and GLM, however I'm having some issues with translation along the x-axis. When I press A for example (expecting to go to the left) the camera goes to the right, vice versa for D and going right.

    Here's the camera setup code, spawn position and look vector, so we start off looking down the positive Z axis, which should be into the screen (I'm using left-handed coordinates here):
    Code :
    gCamera.Setup( glm::vec3( 15.5f, 0.4f, 6.8f ), glm::vec3( 0.f, 0.f, 1.f ) );

    Some setup in the camera constructor:
    Code :
    mPos		= pos;
    mForward	= forward;
    mUp		= glm::vec3( 0.f, 1.f, 0.f );
    mRight	= glm::cross( mUp, mForward );

    Then the translation code from the game:
    Code :
    if( mKeyboard.IsKeyDown( KEYBOARD::A ) )
    		gGameEvents.push( PlayerMovedEvent( glm::vec3( -0.001f, 0.f, 0.f ) ) );
     
    if( mKeyboard.IsKeyDown( KEYBOARD::D ) ) 
    		gGameEvents.push( PlayerMovedEvent( glm::vec3( 0.001f, 0.f, 0.f ) ) );

    Finally, the translation code from the camera class:
    Code :
    void FirstPersonCamera::Translate( float x, float y, float z ) {
    	glm::vec3 translation( x, y, z );
     
    	translation = glm::mat3( glm::rotate( mYaw, glm::vec3( 0.f,1.f,0.f ) ) ) * translation;
    	translation = glm::mat3( glm::rotate( mPitch, mRight ) ) * translation;
     
    	mPos += translation;
    }

    I'd really appreciate some help with this.

    Thanks

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2014
    Posts
    10
    Really? No-one can help with this?

Similar Threads

  1. Why is my camera moving forward in the negative Z axis?
    By hashbrown in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 09-08-2016, 11:42 AM
  2. Moving Object along axis
    By Lachu in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-08-2013, 06:03 PM
  3. HELP: MOVING CAMERA IN THE Y AXIS
    By jakes in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-10-2009, 06:52 AM
  4. Moving on the Z axis
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-17-2003, 12:23 PM
  5. Moving on the z-axis
    By nix in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-19-2001, 03:16 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