# Flight Sim With Quaternions

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

## Recommended Posts

Hi, I am trying to rotate my plane model with quaternions and I somehow manage to do it by accident. My code is as follow
void D3DAdapter::MoveObjectQ(int direction)
{

float fRoll, fYaw, fPitch;
fRoll = fYaw = fPitch = 0.0f;

switch(direction)
{
fRoll -= m_speed;
break;

fRoll += m_speed;
break;

fYaw -= m_speed;
break;

fYaw += m_speed;
break;

fPitch -= m_speed;
break;

fPitch += m_speed;
break;
}

D3DXMatrixIdentity(&matTrans);

D3DXVECTOR3 lookAtVt(0.0f, 0.0f, -1.0f);

//D3DXVECTOR3 lookVt(matLocal._21, matLocal._22, matLocal._23);

{
aeroplane.pos.x += m_speed * lookAtVt.x;
aeroplane.pos.y += m_speed * lookAtVt.y;
aeroplane.pos.z += m_speed * lookAtVt.z;
}
{
aeroplane.pos.x -= m_speed * lookAtVt.x;
aeroplane.pos.y -= m_speed * lookAtVt.y;
aeroplane.pos.z -= m_speed * lookAtVt.z;
}

D3DXMatrixTranslation(&matTrans, aeroplane.pos.x, aeroplane.pos.y, aeroplane.pos.z);

}


The question I have is when I didn't inverse the rotation matrix generated from using the quaternion, the rotation didn't work. Anyone knows why?

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 96
• 11
• ### Forum Statistics

• Total Topics
632974
• Total Posts
3009641
• ### Who's Online (See full list)

There are no registered users currently online

×