Rotate 3D (Quaternion, EulerAngle, Matrix)?

Rotate 3D (Quaternion, EulerAngle, Matrix)?
0

How to rotate a 3D sprite using an axis and an angle?

An example in Unity3d: http://docs.unity3d.com/ScriptReference/Quaternion.AngleAxis.html

currently, we use a really simple model, just call `node::setRotation(vec3(x,y,z));`

it rotates relative to the local space of the object, I need to rotate relative to the global axis without gimbal lock.

I noticed that cocos2d has a quaternion class, but have no method to convert the quaternion to Euler angle found.
I need to rotate an object with the touch, but he must make the correct rotation taking into consideration the rotation already applied, he’s always rotating in your local space, any idea or example?

by translate

someone
…up

We don’t have quaternion yet, however if you know what you are doing, you could use this function from node

``````void setAdditionalTransform(kmMat4* additionalTransform);
``````

Hi allanolivei, did you manage to solve it?

The version 3.4 has the quaternion class. We can multiply quaternion to get the sum of rotations, see an example:

``````Quaternion q = ball->getRotationQuat();
q *= Quaternion(ball->getWorldToNodeTransform() * (horizontal ? Vec3::UNIT_Y : Vec3::UNIT_X), 4.0f*dt);
ball->setRotationQuat(q);``````

thanks! allanolivel