Freeze scale transform on a parent object with animated child (MAYA MEL/Python script)

两盒软妹~` 提交于 2019-12-12 20:38:09

问题


I have hierarchy of objects with animation on translation and rotation, the scale xyz are equal and static but not 1. When I freeze scale on a parent mesh it's children's animation goes wild. Is there any way to prevent this from happening?


I have found a workaround, but it's not perfect yet. Let's say we have simple setup like this: parentObject=>childObject

  1. I put childObject in a group "childObjectGroup"
  2. parent childObjectGroup to the world and zero out it's transforms excluding scale.
  3. Bake childObject's trasformations to the world so we don't need a group anymore. (found a good script for that)
  4. Freeze scale transforms on parentObject and childObject
  5. Reparent them back

It works for simple hierarchies like that, but not sure how to apply it for more complicated ones with deep tree and several brunches. Probably I'm missing something and there is really simple solution to that.


回答1:


Any time you change the scale of a parent node, the translation for it's children is going to change - at least, if you're measuring in world space units. So, moving 10 units under a parent scaled to 0.5 will actually move 5 world space units (for example).

I'm pretty sure your rotations should be fine since scale doesn't really change how rotation around a pivot works; however, if you're rotating something from a pivot that is not in the center of the object and you have non-uniform scaling (xyz are not all equal) the rotation inside of the squashed space will feel more like an oval than a circle.

If that's not a problem, the main thing to worry about is the translation positions - you basically need to get the world space positions of each object at each key, 'fix' the scale, then go through the keys and set the world space position again (I would use the xform command for that since you can query and set position with world space values). So, the steps you outlined will probably be the best bet...

If you have non-uniform scales though, you may not actually be able to get the rotations to work out in a way that gives you the same results (just depending on positions/pivots and consecutive descendant positions/pivots). If the parent's scale isn't actually hurting anything and isn't supposed to be keyed/animated, it might be ok to just lock and hide it without any adverse effects.



来源:https://stackoverflow.com/questions/45757754/freeze-scale-transform-on-a-parent-object-with-animated-child-maya-mel-python-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!