[Closed] Help with Rotations
Hmm,
Rotations seem to be a bit complicated. Hopefully what I’m doing is simple!
I am basically trying to create a snaphot of a rotation to position some hands.
Basically I want to set an objects rotation.
I use this code
(EulerAngles 0 0 90) as Matrix3
However, everytime I run it it seems to jump a little? I am after something similar to the pos attribuite, where i can feed some values in and it moves to that exact spot.
What am I missing here?
Thanks!
Im not really sure I understand exactly what your trying to do. But I think your trying to take one objects rotation and apply that to something else.
--grab the rotational value of the selected object and store it
R1=$.rotation
--the object you want to move
OldRot = $YourObject
OldRot.rotation = R1
If you are trying to do:
Object.rotation = (EulerAngles 0 0 90) as Matrix3
Then your object is going to jump in position, you need to tell it to rotate in reference to a specific coordinate system. Also the code above will return a Matrix with position [0,0,0] which is not needed. I think maybe you meant to use (eulertoquat (EulerAngles 0 0 90)) ?
Try this:
rotate in coordsys local Object.rotation = (EulerAngles 0 0 90)
This is also not the only way to properly rotate an object, but it is the way I usually use it
Hey Viro,
Thanks so much for your answer! I did try that and unfortunately it does not give me the same result everytime, for some reason when I switch back to the old rotation its a little off centre?
What I’m doing is, I have a biped, and for quick hand posing, I want to rotate the fingers a certain way. I thought I could do this by copying rotations. I know that there is a copy/clone tool, but it seems to take awhile. And I’m learning to script so this was one of the things I wanted to add to my script to be able to change hand poses quickly.
Why does it go off centre everytime I put the stored rotations back?
Thanks Pepe, didn’t see your reply till after I posted!
Would this mean also that I can store positions this way?
So like Viro’s example
R1 = Object.rotation
And then restore it as
Object.rotation in local cord sys = R1
Thanks!
I'm really interested to get my head around rotations.
If you want to store the pose of the fingers then the best way to go is with storing the rotation values from the controller not the world space rotations.
here is how you do it… (given that your controllers have a rotation list on them).
-- Store the values:
-- get the active controller
activeCon = myObject.rotation.controller[myObject.rotation.controller.active]
-- Store the rotation values
storeRot = [activeCon.x_rotation,activeCon.y_rotation,activeCon.z_rotation]
-- This is how we load:
-- get the active controller
activeCon = myObject.rotation.controller[myObject.rotation.controller.active]
-- Load the values by converting them to quat and applying them directly to the active controller rather then one by one.
activeCon.value = (eulerToQuat (eulerAngles storeRot.x storeRot.y storeRot.z))
There are other ways to do it.
You could also buy:
http://paulneale.com/scripts/poseSaver/