3

I am using 3ds max for a long time and I know xyz axis. what I see in xcode in rotation the scnnode what made my mind blowed up is w component of scnvector4.

Can someone explain in detail how to use this method because I searched a lot of time but I can't make my object spin as I desire. anyone can help to make him spin to his back in 180 degree but I will appreciate if someone explain more for further rotations, Knowing that I saw this link but I didn't understand something.

http://www.cprogramming.com/tutorial/3d/rotationMatrices.html

FamousMaxy
  • 686
  • 5
  • 21

2 Answers2

7

I believe that your are trying to rotate nodes (rotation property).

From the documentation :

The four-component rotation vector specifies the direction of the rotation axis in the first three components and the angle of rotation (in radians) in the fourth.

You might find it easier to use eulerAngles :

The node’s orientation, expressed as pitch, yaw, and roll angles, each in radians

mnuages
  • 13,049
  • 2
  • 23
  • 40
1

Use .transform to rotate a node

node.transform = SCNMatrix4Mult(node.transform, SCNMatrix4MakeRotation(angle, x, y, z))

if you want to rotate your node 180 degree by x axis

node.transform = SCNMatrix4Mult(node.transform, SCNMatrix4MakeRotation(Float(M_PI), 1, 0, 0))
mysofacc
  • 11
  • 2
  • How would I make this animated? Am I able to do that? – Amit Kalra Jul 23 '17 at 22:15
  • There's several ways of animating with Scenekit depending on your needs. The most powerful is using animation players (look up SCNAnimationPlayer), but in most realtime scenarios, just wrapping the assignment in an animation transaction will do the trick. ``` SCNTransaction.begin() SCNTransaction.animationDuration = 5 node.transform = SCNMatrix4Mult(node.transform, SCNMatrix4MakeRotation(Float(M_PI), 1, 0, 0)) SCNTransaction.commit() ``` Or just set the duration and nothing else if you want everything to animate all the time – Morten J Mar 31 '22 at 13:32