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

1. 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. Really? No-one can help with this?

Posting Permissions

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