Sign in to follow this  
emre2345

Problem with programming virtual camera

Recommended Posts

Hi everyone. I am studying programming a virtual camera. I used quaternions but still trapped with gimbal lock. below there are my yaw, pitch functions and section of setting view matrix. What is wrong with it? void Camera::yaw( const float &angle ) { Quat yawQuat; float ang = D3DXToRadian(angle); D3DXQuaternionRotationAxis(&yawQuat, &Vec3(0, 1, 0), ang); D3DXQuaternionMultiply(&_orientation, &yawQuat, &_orientation); } void Camera::pitch( const float &angle ) { Quat pitchQuat; float ang = D3DXToRadian(angle); D3DXQuaternionRotationAxis(&pitchQuat, &Vec3(1, 0, 0), ang); D3DXQuaternionMultiply(&_orientation, &pitchQuat, &_orientation); } *------------------------------------------------------------------------* D3DXMATRIX viewMat; D3DXVECTOR3 tempVec(_cam->getPosition().x, 0, 0); _cam->transformVector(&tempVec, Vec3(0, 0, 1), _cam->getOrientation()); tempVec = _cam->getPosition() + tempVec; D3DXMatrixLookAtLH(&viewMat, &(_cam->getPosition()), &tempVec, &_cam->getUpVector()); _device->SetTransform(D3DTS_VIEW, &viewMat);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this