Jump to content
  • Advertisement
Sign in to follow this  

Problem with programming virtual camera

This topic is 3351 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!