[Closed] Set and get rotation of node as eulerAngles
So I have code looking like this:
$.rotation=r1
r2=$.rotation as eulerAngles
r1 is eulerAngles value but r2 has a diferent value. Is there a way to get the corect rotation value?
probably because theres more than one “solution” to the net rotation e.g.
rotation xyz gives the same net result as rotation uvw even though they have different values
Try using quatToEuler2 instead of as EulerAngles. It may give more predictable results.
You could also try getting and setting the curve values instead of converting and avoid the issue.
Unfortunatelly this quatToEuler2 is of no use for me, since it´s not worcking with older max versions.
What you mean by getting and setting the curve values instead of converting? I have the rotation values stored as EulerAngles in a file and would like to store the rotations of the nodes back in same format.
How old do you need? quatToEuler2 was added in Max 2008 and the AVGUARD extension package is still available on ScriptSpot back to Discreet’s 3ds Max v4 released in 2000. I’m not sure the code below will work previous to Max v4 either.
It’s more verbose than your example above, but it seems to work.
(
--PRETENED THIS COMES FROM A FILE
r1 = (eulerAngles 90 -90 45)
--SET THE VALUE OF THE SUBANIMS IN RADIANS
$.rotation.controller[1].value = degToRad r1.x
$.rotation.controller[2].value = degToRad r1.y
$.rotation.controller[3].value = degToRad r1.z
--GET THE VALUES BACK IN DEGREES
r2 = (EulerAngles 0 0 0)
r2.x = radToDeg $.rotation.controller[1].value
r2.y = radToDeg $.rotation.controller[2].value
r2.z = radToDeg $.rotation.controller[3].value
--CHECK IF THEY ARE EQUAL
r1 == r2
--YES THEY ARE
--true
)
I am normally 1 version under 2008, which is max 9. However everithing under max 6 is to old even for me.