2

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.

Miru302
  • 43
  • 1
  • 7

1 Answers1

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.

silent_sight
  • 492
  • 1
  • 8
  • 16
  • Thanks for reply! Fortunately scale's xyz are equal. If you think the solution I outlined will work, then I guess I need to open new question about how do I store Parent-child hierarchy dependency before I break everything apart and freeze scale transform, and then reparent them the same way it was before. Any Idea how it can be done? – Miru302 Aug 18 '17 at 17:16
  • Sure thing - you could store it in a dict where each key is a parent and the value is a list of it's children `{'parent_node1':['child1', 'child2'], 'parent_node2': ['child3', 'child4']}` It's a little hard to guess without an idea of what your hierarchy is actually like. `children = maya.cmds.listRelatives('parent_node', c=True)` should get you what you need from each parent. How many parent nodes do you need to do this to, and do you need to do it recursively? – silent_sight Aug 19 '17 at 04:11
  • just a note - I made a response to your new question. Please upvote if anything has been helpful! – silent_sight Aug 19 '17 at 05:18
  • Your comment can be considered as accepted answer in the question Ive opened recently! https://stackoverflow.com/q/45764093/8483714 There is still a thing I didn't get. I can see how using dict I can store 1 level hierarchy, but what to do with deeper trees? Root _parent1 __child1 __child2 ___grandChild1 _parent2 __child3 ___grandChild2 ____grandgrandChild1 in your example key 'parent_node1' have values 'child1','child2'. What if child2 have a grandchild in it? Ideally, I want to write a script that can process different parent-child hierarchies tnx for your time @silent_sight – Miru302 Aug 19 '17 at 05:36
  • Haha, I'm late to give you a note about my question =) Thank you. – Miru302 Aug 19 '17 at 05:39
  • yeah, in these notes, the answer isn't very detailed... I wasn't sure if you needed the whole hierarchy, or if you were just doing specific nodes more surgically - take a look at my answer to your other question since it should get the whole hierarchy – silent_sight Aug 19 '17 at 05:54