quaternion instead of euler angle

This commit is contained in:
yangxiao 2015-06-19 18:46:14 +08:00
parent 86b6ea702a
commit d252250968
1 changed files with 2 additions and 6 deletions

View File

@ -152,12 +152,8 @@ void Camera::lookAt(const Vec3& lookAtPos, const Vec3& up)
Quaternion quaternion;
Quaternion::createFromRotationMatrix(rotation,&quaternion);
float rotx = atan2f(2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z), 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y));
float roty = asin(clampf(2 * (quaternion.w * quaternion.y - quaternion.z * quaternion.x) , -1.0f , 1.0f));
float rotz = -atan2(2 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y) , 1 - 2 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z));
setRotation3D(Vec3(CC_RADIANS_TO_DEGREES(rotx),CC_RADIANS_TO_DEGREES(roty),CC_RADIANS_TO_DEGREES(rotz)));
quaternion.normalize();
setRotationQuat(quaternion);
}
const Mat4& Camera::getViewProjectionMatrix() const