Search - User list
Full Version: How to procedurally set parent for joints?
Root » Rigging » How to procedurally set parent for joints?
fragmentzero
Hello

I would like to parent a lot of joints to specific joint based on point attribs. Can I do that?
I saw somewhere that setting parent attrib to ptnum of parent can work. But its not working on my side, maybe I am missing something there.

Thanks
raincole
Too little information... at which level? SOP Kinefx skeleton? APEX?

its not working on my side

http://www.catb.org/~esr/faqs/smart-questions.html [www.catb.org]
fragmentzero
SOP KineFX skeleton. No APEX.

As shown below, I am looking to parent all floating bones to one bone.
And it needs to be done procedurally as the config of floating bones can change, including count and ptnum.

tamte
you can use Parent Joints SOP, where you can specify joint and parent groups

this offers certain level of proceduralism as the groups can be specified using attribute values
so if you know maximum number of parent bones and its a reasonable number you can use provided UI, however if you need large number of parent bones, you may want to either use additional for loop or have a look inside how it works to rebuild a custom version
fragmentzero
I see.
So its not as simple as just @parent = "ptnum of parent" in Point Wrangle.
I do want to avoid Parent Joints SOP, so I'll try out the 2nd/3rd approaches.

This is my first foray into KineFX tools, which I am pairing with Control Rig in Unreal. So trying to keep both ends as procedural as possible.

Thank you
tamte
no need to avoid it since as I said you can run it in for loop for each unique value of your i@parent attrib

but if you want pure VEX solution, here is something ripped from inside of Parent Joints and adjusted to be able to use your i@parent attribute, just make sure any joint that you dont want to parent has @parent=-1

#include <kinefx_hierarchy.h>

int unparent_on_cycle = chi("unparent_on_cycle");

int joints[] = expandpointgroup( 0, "@parent!=-1" );

int success = 1;
int failed[];

foreach ( int joint; joints ){
    int parent = point( 0, "parent", joint );
    int _success = setparent(0, joint, parent, unparent_on_cycle);
    if(!_success)
        append(failed, joint);
    success &= _success;
}

if(!success)
    warning("One or more parenting operations has failed.\nPoints %d", failed);
fragmentzero
That worked like magic.
Thank you very much.


fragmentzero
Looks like this ended up in a cycle though.
Trying to traverse through the points myself.


tamte
did you check Unparent on Cycle?
edward
I wouldn't expect that code to produce a cycle though unless one of the child points is actually the parent itself. So maybe inside the loop, it just needs to continue/skip if joint == parent.
fragmentzero
This got fixed by running vex in detail.
I guess doing it in point wrangle was causing the cycle issue as its looping over all joints (points) per point.

Its working without an issue now, tested with Rig Pose.

Thank you
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB