The SCNNode take a rotation using a SCNVector4
, which has an angle (w) and a magnitude how that angle applies to each axis (x, y, z). For example, to rotate 45
Do you ask for rotation matrix or how to simply rotate in general? If the second is correct then for example:
[node runAction:[SCNAction rotateByX:0 y:M_PI z:0 duration:0]];
You'll need to generate an SCNVector4 for each of the rotations, and then multiply them. Note that the order of operations matters!
http://www.cprogramming.com/tutorial/3d/rotationMatrices.html has a pretty good writeup of the math. Any OpenGL reference that deals with rotation matrices is worth a look too.
Instead of rotation
property, use eulerAngles
and specify angle for each axis
If you're not animating the rotation, it might be cleaner to just set the transform matrix directly, like:
node.transform = CATransform3DRotate(CATransform3DRotate(CATransform3DRotate(node.transform, xAngle, 1, 0, 0), yAngle, 0, 1, 0), zAngle, 0, 0, 1);