http://content.gpwiki.org/index.php/OpenGL:Tutorials:Using_Quaternions_to_represent_rotation
上面说的不清楚,更直观的是:人的头只能围绕Y转动,不能沿着X转动(人的右边手臂)
void Camera::rotatex(float xrmod)
{
Quaternion nrot(Vector3(1.0f, 0.0f, 0.0f), xrmod * PIOVER180);
rotation = rotation * nrot;
}
void Camera::rotatey(float yrmod)
{
Quaternion nrot(Vector3(0.0f, 1.0f, 0.0f), yrmod * PIOVER180);
rotation = nrot * rotation;
}
void Camera::tick(float seconds)
{
if (xrot != 0.0f) rotatex(xrot * seconds * rotspeed);
if (yrot != 0.0f) rotatey(yrot * seconds * rotspeed);
if (xmov != 0.0f) movex(xmov * seconds * movespeed);
if (ymov != 0.0f) movey(ymov * seconds * movespeed);
if (zmov != 0.0f) movez(zm