[Closed] Rotate a bone in hierarhy and then rotate it back
hello,
I have a skeleton for which I made a script to rotate some of its bones. I’ve bind it to ms button and by the ‘rightclick’ on it I want to rotate bones to *(-1)
so I’ve a made a function out of this script. and have two case on single button ‘pressed’ and ‘rightclick’
surprisingly ‘righclick’ doesn’t correctly rotate the bones back but with slight deflection
how to rotate bones and then rotate them back into same position?
the method I use is:
bnNames = #($j_shoulder_ri, $j_shoulder_le)
for o in bnNames do o.transform = (rotateXmatrix -20) * o.transform
you probably have to rotate them in ‘parent’ coordinate system …
the simplest way is:
in coordsys parent rotate <bones> (eulerangles <x> <y> <z>)
thanks. but I already setup all the angles. how can I use this data with ‘coordsys parent’?
btw I have local rotations for bones, like X=-20, Y=5, Z=-35
is it possible to translate this (?):
bnNames = #($j_shoulder_ri, $j_shoulder_le)
for o in bnNames do o.transform = (rotateXmatrix -20) * o.transform
for o in bnNames do o.transform = (rotateYmatrix 5) * o.transform
for o in bnNames do o.transform = (rotateZmatrix -35) * o.transform
into this:
bnNames = #($j_shoulder_ri, $j_shoulder_le)
in coordsys parent rotate bnNames (eulerangles -20 5 -35)
when I do it straight the result is not correct.
obj.transform = (rotateXmatrix -20) * obj.transform
obj.transform = (rotateYmatrix 5) * obj.transform
obj.transform = (rotateZmatrix -35) * obj.transform
is the same as:
obj.transform = (rotateXmatrix -20) * (rotateYmatrix 5) * (rotateZmatrix -35) * obj.transform
-- or
obj.transform = (eulerAngles -20 5 -35) as matrix3 * obj.transform
-- or
rotate obj (eulerAngles -20 5 -35)
in case of rotate it has to be
in coordsys world about pivot rotate obj (eulerAngles -20 5 -35)
but for any hierarchical system you should use transformations in the parent coordinate system.
only root of whole hierarchy might be transformed in world
thanks for the tips, denis! that’s usefull
however – as I mentioned – I already rotated bones (in their local coord). the number of bones is huge, it also been done not for only a single skeleton.
you gave a good advice on to rotate them parentally, but how to convert these data I have for ‘local’ rorations into ‘parent’?
you have your data not probably in local… you rotate now as i can see in absolute coordinate space
what makes you think that?
how I rorate: make coord. system Local then choose bones and rotate
my bad… yes, you rotate in local. and it’s OK if you want to offset rotation from some previous value.
but in animation usually we need to set a value (not offset). if so we need to do it parent coordinate system .
the question is – do you want to offset or set the rotation?
Well I have a character in pose that doesn’t fit my needs. I simply rotate some bones localy.
I can do it straight with the code I posted. But what I additionally what is to have possibility to rotate bones into initial pose.
the animations (that I already have) will be added later and – in my opinion – they should take any pose I do.
yes, I want offset! and thing is I already have those offset values but can’t use it cirrectly for the back rotations