Archived

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

gotG

Camera

Recommended Posts

I dont know why my Camera class is not working the numbers outpus are correct but the movements on screen dont match up when i rotate the camera by 180 degrees the moveforward would make me go backward, and infact all the controls are reversed, its like the more i rotate off the orignal direction the more off is the movement vectors until like i said 180 which causes everything to reverse, Does anyone have ever had this problem? does is have anything to do with the way D3D builds the view transformation???

Share this post


Link to post
Share on other sites
Actually, what it seems like you forgot is that the x, and y coords do not move with your camera. I actually had this problem before, and here's how I solved it:

//CENTER_(etc) - In my program, the main character
//X/Y - Variables which control the rotation on the X/Y axis
//Zoom - The zoom variable
//sin(), and cos() require including , you can look them up on microsoft's MSDN

D3DXMATRIX matView;
D3DXMatrixLookAtLH( &matView,
&D3DXVECTOR3( sin(Y)*(Zoom-(Zoom*X))+CENTER_X, X*Zoom, cos(Y)*(Zoom-(Zoom*X))+CENTER_Z ),
&D3DXVECTOR3( CENTER_X, CENTER_Y+1, CENTER_Z ),
&D3DXVECTOR3( 0, 1, 0 ) );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

Btw, I swapped my 'z' coord with my 'y'.

[edited by - hello2k1 on April 28, 2002 11:05:04 PM]

Share this post


Link to post
Share on other sites