• Advertisement

Archived

This topic is now archived and is closed to further replies.

Problems with camera

This topic is 5785 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

I have following code to update the camera:
	D3DXMATRIX temp;
	D3DXMatrixTranslation(&matrix,position.x,position.y,position.z);
	D3DXQuaternionRotationYawPitchRoll(&rotate,angley,anglex,0.0f);
	D3DXMatrixRotationQuaternion(&temp,&rotate);
	D3DXMatrixMultiply(&matrix,&matrix,&temp);
	device->SetTransform(D3DTS_VIEW,&matrix);
 
Everything seems to be ok, but when I turn around near angley==PI, it will "invert" with x axis (when I go up it goes down, with angley==0 it behave normally) Does anybody has an idea what can be wrong?

Share this post


Link to post
Share on other sites
Advertisement
Are you continually increasing angley beyond 360 degrees (2 pi)? Try making your angley reset itself to zero when you pass 360 degrees.

Share this post


Link to post
Share on other sites
No it didn''t help.

I changed my update method to:

D3DXMATRIX temp;
D3DXMatrixIdentity(&temp);
device->SetTransform(D3DTS_WORLD,&temp);
D3DXQuaternionRotationYawPitchRoll(&rotate,angley,2.0f*D3DX_PI-anglex,0.0f);
D3DXMatrixAffineTransformation(&matrix,1.0f,NULL,&rotate,&position);
D3DXMatrixInverse(&matrix,NULL,&matrix);
device->SetTransform(D3DTS_VIEW,&matrix);

and I had to change nearly every method using move or rotate camera and now its ok

Share this post


Link to post
Share on other sites
No it didn''t help.

I changed my update method to:

D3DXMATRIX temp;
D3DXMatrixIdentity(&temp);
device->SetTransform(D3DTS_WORLD,&temp);
D3DXQuaternionRotationYawPitchRoll(&rotate,angley,2.0f*D3DX_PI-anglex,0.0f);
D3DXMatrixAffineTransformation(&matrix,1.0f,NULL,&rotate,&position);
D3DXMatrixInverse(&matrix,NULL,&matrix);
device->SetTransform(D3DTS_VIEW,&matrix);

and I had to change nearly every method using move or rotate camera and now its ok

Share this post


Link to post
Share on other sites
sounds like gimbal lock...



Laurent - http://www.lafaqmfc.com/
My little game: http://www.lafaqmfc.com/home/play_starshooter.htm

Share this post


Link to post
Share on other sites

  • Advertisement