I am trying to make a jet game, and am having a difficult time with making the jet's forward vector change based on the roll. Basically, I can roll the aircraft however I want, but only the yaw will affect the angle at which it pitches. I suspect I need to use my up vector somehow (or possibly my right vector) to help rectify the situation.
//apply the yaw and pitch to get the forward vector
m_d3dForwardVector.x = -siny * cosp;
m_d3dForwardVector.y = sinp;
m_d3dForwardVector.z = -cosy * cosp;
////apply the yaw and pitch to get the right vector
m_d3dRightVector.x = -cosy;
m_d3dRightVector.y = -siny * cosp;
m_d3dRightVector.z = siny;
////Use the cross product to get the up vector
m_d3dUpVector = CrossProduct(m_d3dForwardVector, m_d3dRightVector);
and change my jet's position based on the forward vector:
Ok, so I found a way to update my Up and Right Vectors properly, but it didn't fix the problem of the airplane not "pitching" correctly, I know I need to add the logic on how to rotate the forward vector towards the up vector of the airplane, but I am at a loss of how to do this.
Here is my updated find vector function:
void CJet::FindForwardVector(float fYaw, float fPitch, float fRoll)
{
//apply yaw, pitch and rotation to a rotation matrix
D3DXMATRIX matRot;
D3DXMatrixRotationYawPitchRoll(&matRot, fYaw, fPitch, fRoll);
//apply the yaw and pitch to get the forward vector
m_d3dForwardVector.x = -matRot._31;
m_d3dForwardVector.y = -matRot._32;
m_d3dForwardVector.z = -matRot._33;
//apply the yaw and pitch to get the right vector
m_d3dRightVector.x = -matRot._11;
m_d3dRightVector.y = -matRot._12;
m_d3dRightVector.z = -matRot._13;
//Use the cross product to get the up vector
m_d3dUpVector = CrossProduct(m_d3dForwardVector, m_d3dRightVector);
}