Original Post
whats the equation for moving the player forward,backward with respects to the camera and the one for moving left,right. i used to know but i have forgoten.
void CCamera::MoveForewards( float fDistance )
{
D3DXMATRIX mat;
// Our foreward vector
D3DXVECTOR3 vForwards( 0.0f, 0.0f, 1.0f );
// Get camera rotation/orientation matrix from
// the quaternion (my camera class uses them)
D3DXMatrixRotationQuaternion( &mat, &m_qRotation );
// Here we transpose the matrix in order to
// transform the vForewards vector correctly
D3DXMatrixTranspose( &mat, &mat );
// Now transform the vForewards vector by
// the transposed matrix
D3DXVec3TransformCoord( &vForwards, &vForwards, &mat );
// Just add the this vector to the camera position
// and there we have our new position
m_vPosition += vForwards * fDistance;
// A flag indicating that we need to calculate the
// camera(view) matrix
m_bNeedsUpdate = TRUE;
}
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more