1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
[...]
Quaternion key_quat, // quaternion from key press
temp_quat; // temp quaternion
key_quat.FromEuler((float)-m_Anglex, 0.0f, -(float)m_Angley);
temp_quat = m_CameraQuat; // sauvegarde l'ancien quaternion globale
m_CameraQuat = temp_quat * key_quat; //calcul le nouveau quaternion
CAxe3D axis; // temp axis angle representation
double angle;
m_CameraQuat.GetAxisAngle(axis, angle); // recupere l'angle et les axes de rotation a partir du quaternion global
float ax, ay, az;
// recupere les valeurs de l'Axe3D
ax = axis.getX();
ay = axis.getY();
az = axis.getZ();
angle = angle *180/M_PI;
double deltaX = m_CentreRotation.getX() - m_CameraPosition.getX();
double deltaY = m_CentreRotation.getY() - m_CameraPosition.getY();
double deltaZ = m_CentreRotation.getZ() - m_CameraPosition.getZ();
//glTranslatef(-(GLfloat)m_CameraPosition.getX(),-(GLfloat)m_CameraPosition.getY(),-(GLfloat)m_CameraPosition.getZ());
glTranslatef((GLfloat)m_CameraPosition.getX() + m_CentreRotation.getX(),(GLfloat) m_CentreRotation.getY() + m_CameraPosition.getY(),(GLfloat)m_CentreRotation.getZ() + m_CameraPosition.getZ());
glRotatef((GLfloat)angle, (GLfloat) ax, (GLfloat) ay, (GLfloat) az); // Appel la methode de rotaion d'openGL
glTranslatef(-(GLfloat)m_CameraPosition.getX() - m_CentreRotation.getX(), -(GLfloat)m_CameraPosition.getY() - m_CentreRotation.getY(), -(GLfloat)m_CameraPosition.getZ() - m_CentreRotation.getZ());
// Translation qui recadre la camera pour le zoom si il y en a un
glTranslatef((GLfloat)m_CameraPosition.getX(),(GLfloat)m_CameraPosition.getY(),(GLfloat)m_CameraPosition.getZ()); |
Partager