opengl旋转次序理解(1)

来源:互联网 发布:sqlplus执行sql文件 -c 编辑:程序博客网 时间:2024/06/11 04:33

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(zmov * seconds * movespeed);}

void Camera::movex(float xmmod) // 做火车,X为火车方向,目光的方向不变{pos += rotation * Vector3(xmmod, 0.0f, 0.0f);} void Camera::movey(float ymmod)// 坐电梯,目光方向不变{pos.y -= ymmod;} void Camera::movez(float zmmod)// 移动zmmod Camera等效于移动物体 -zmmod{pos += rotation * Vector3(0.0f, 0.0f, -zmmod);}


原创粉丝点击