0

I'm trying to import an animation from a file to Maya, but it gives me odd results between the interpolations:

https://i.imgur.com/cP27Yai.mp4

It was weird because they keyframes looked right at first until i looked at the graph editor.

enter image description here

thought this was at first a gimbal lock, so i used the Euler Filter, but it gave no solution to it. Sometimes, the difference between one key and another is 180, which is why, by just seeing the animation, the keys look fine, but the interpolation makes it do a 180 rotation.

So if i go one by one, and subtract the vaule of the key by 180, and then invert the number (to positive or negative depending on the case), i can make it work by tweaking it a bit.

However this is too much work, specially for being biped animations, it could took me forever.

Is this a common issue or something that happened before to anyone else? Is there any way to fix this? Maybe it's the way i'm applying the euler angles, since they were initially Quaternions, but i did not find a way to apply the quaternions directly:

#Taking a rotation from the QUATERNION Array and converting it to Euler.
arot = anim.AnimRot[index].normal().asEulerRotation()
frot = MEulerRotation(arot.x*180/math.pi, arot.y*180/math.pi, arot.z*180/math.pi) 

cmds.setAttr((obj + ".rotate"), frot.x, frot.y, frot.z) 
cmds.setKeyframe(obj, time=anim.TotalKeys[i])

Is there any way to fix this from the editor or the script? any that fixes it would do me a great favor for importing this biped animation. I believe this is due to euler conversion, but i found no way to apply a quaternion to a bone in the maya API.

Seyren Windsor
  • 115
  • 1
  • 2
  • 12

1 Answers1

0

If the rotations already are quaternions, you might want to simply set the anim curves to quaternion interpolation using something like

cmds.rotationInterpolation( 'pSphere2.rotateX', 'pSphere2.rotateY', 'pSphere2.rotateZ',  c="quaternionSquad")

To be safe I'd set one key, then apply the rotationInterpolation to change the keys to quats, then step through applying your original quaternions. Since you're already in API land you can make an MTransformationMatrix and use its setRotationComponents method to set the quat values so you don't ever convert to eulers.

theodox
  • 12,028
  • 3
  • 23
  • 36