Swift Scenekit - Multiple rotations -
i have issue rotating node multiple times. working on game rolling ball, , while can rotate ball along 1 axis, or 2 axis same amount, cannot rotate @ partial angles.
example:
// roll right 90 - scnnode.pivot = scnmatrix4makerotation(float(m_pi_2), 0, 1, 0) // roll right 180 - scnnode.pivot = scnmatrix4makerotation(float(m_pi_2) * 2, 0, 1, 0) // roll 90 - scnnode.pivot = scnmatrix4makerotation(float(m_pi_2), 1, 0, 0) // roll & right 90 - scnnode.pivot = scnmatrix4makerotation(float(m_pi_2), 1, 1, 0)
all of work, if need roll ball right 180 , 90 i'm stuck.
even if there way add vectors me.
any appreciated.
to combine effects of rotation matrices, use matrix multiplication.
to in scenekit, can either:
- create separate rotation matrices , multiply them using
scnmatrix4mult
. - apply rotation directly existing matrix using
scnmatrix4rotate
. (this equivalentscnmatrix4makerotation
+scnmatrix4mult
option; combines steps single function call.)
if order of transformations important app, remember matrix multiplication order reverse of transformation order.
Comments
Post a Comment