Is it possible to "collapse" stacked animated xforms?

   1065   3   3
User Avatar
Member
109 posts
Joined: Aug. 2017
Offline
What I mean is, transfer animation from multiple nested Xform parents onto the leaf primitive. And get rid of those Xforms.

I'd like to turn this:
xform_animCTRL_1
  └─xform_animCTRL_2
      └─xform_animCTRL_3
          └─RubberToy
Into this:
RubberToy
And keep the animation resulting from all these different pivots, translations, and rotations.

If it's possible, what are some ways to do this? I'm good with Vex and Python.
Edited by alexmajewski - Jan. 10, 2025 08:35:01
User Avatar
Member
109 posts
Joined: Aug. 2017
Offline
I ended up copying xform attributes from parents to my leaf primitive using Vex in a wrangle.

string path = "/CTRL_MAIN/CTRL_2/CTRL_3/rubbertoy";
string parents[] = split(path, "/");

string current_path = "";

for (int i=0; i<len(parents)-1; i++) {
    current_path += "/" + parents[i];
    
    matrix locXform = usd_localtransform(0, current_path);
    usd_addtransform(0, path, "transform"+itoa(i), locXform);
}

And then reparenting my leaf primitive and removing the parents.
Edited by alexmajewski - Jan. 13, 2025 11:41:39
User Avatar
Staff
593 posts
Joined: June 2020
Offline
Is it important to keep the individual xform ops? If you're okay with collapsing them all into a single op, the Graft Branches LOP (with "Keep Position" enabled) might be worth considering as well.

Attachments:
xformCollapse.hip (109.4 KB)

User Avatar
Member
109 posts
Joined: Aug. 2017
Offline
@robp_sidefx This is exactly what I was hoping for. Thank you!

Edit: actually, now I see how my previous solution could still be valid if we wanted to just collapse it up to a certain point, and not the whole thing.
Edited by alexmajewski - Jan. 14, 2025 07:47:04
  • Quick Links