well, if it works for one axis at a time, then it''s on the right tracks. you have to remember that, when you rotate the ship with one axis, you need to update the ship''s orientation as well, so the next rotation can be performed using the current X axis or Y axis.
anyway, I''ve tried it, as I said in a previous post, and Here is the code
Vector xShipPos(0, 0, 0);Vector xShipSide(-1, 0, 0);Vector xShipUp(0, 1, 0);Vector xShipDir(0, 0, 1);float fShipSpeed = 0.0f;;float fShipPitch = 0.0f;float fShipYaw = 0.0f;float fShipRoll = 0.0f;void ShipMove(float dt){ xShipPos += xShipDir * fShipSpeed * dt; if (xShipPos.y < 10.0f) xShipPos.y = 10.0f; if (xShipPos.y > 1000.0f) xShipPos.y = 1000.0f;}void ShipPitch(float dt){ Quaternion Q; Q.FromRotation(xShipSide, fShipPitch * dt); xShipUp = xShipUp * Q; xShipDir = xShipDir * Q;}void ShipYaw(float dt){ Quaternion Q; Q.FromRotation(xShipUp, fShipYaw * dt); xShipSide = xShipSide * Q; xShipDir = xShipDir * Q;}void ShipRoll(float dt){ Quaternion Q; Q.FromRotation(xShipDir, fShipRoll * dt); xShipSide = xShipSide * Q; xShipUp = xShipUp * Q;}void GameUpdate(float dt){ xShipSide = xShipUp.Cross(xShipDir); float fAccel = KeyPressed(''W'') - KeyPressed(''S''); float fPitch = (mousey - 0.5f) * 2.0f; float fYaw = KeyPressed(''A'') - KeyPressed(''D''); float fRoll = (mousex - 0.5f) * 2.0f; fShipSpeed = Clamp(fShipSpeed + fAccel * 0.04f, -20.0f, 20.0f); fShipPitch = fPitch * 0.4f; fShipYaw = fYaw * 0.2f; fShipRoll = fRoll * 0.6f; ShipPitch(dt); ShipYaw (dt); ShipRoll (dt); ShipMove (dt); xShipUp.Normalise(); xShipSide = xShipUp.Cross(xShipDir); xShipSide.Normalise(); xShipDir = xShipSide.Cross(xShipUp); xShipDir.Normalise();}void GameRender(void){ GLfloat fog[] = { 0.2f, 0.2f, 0.2f, 0.2f }; glClearColor (fog[0], fog[1], fog[2], fog[3]); glFogi (GL_FOG_MODE, GL_LINEAR); glFogfv (GL_FOG_COLOR, fog); glFogf (GL_FOG_DENSITY, 0.75f); glHint (GL_FOG_HINT, GL_FASTEST); glFogf (GL_FOG_START, 10.0f); glFogf (GL_FOG_END, 200.0f); glEnable (GL_FOG); Vector xEye = xShipPos; Vector xUp = xShipUp; Vector xTarget = xShipPos + xShipDir * 10.0f; gluLookAt(xEye.x, xEye.y, xEye.z, xTarget.x, xTarget.y, xTarget.z, xUp.x, xUp.y, xUp.z); GameRenderStartfield(xEye); GameRenderTerrain(xEye); glDisable(GL_FOG); GameRenderStats();}
if you want the demo, mail me.
also, I''m slightly concerened about you doing "new" all other the place. do you actually delete as well?
And is it necessary?