问题
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
- I put childObject in a group "childObjectGroup"
- parent childObjectGroup to the world and zero out it's transforms excluding scale.
- Bake childObject's trasformations to the world so we don't need a group anymore. (found a good script for that)
- Freeze scale transforms on parentObject and childObject
- 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