From d2522509686223a22c4a54e02cc5002a0cd209cc Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 19 Jun 2015 18:46:14 +0800 Subject: [PATCH] quaternion instead of euler angle --- cocos/2d/CCCamera.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index b5eacd7a93..ca8d0dc6d2 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -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