reparenting joint nodes

perhaps I’m misunderstanding the usage of control joint or just missing something stupid, but I’ve got to ask.

I’m trying to use the code below to attach models to each other and use them like a multi-part actor.


	NodePath character_path = window->load_model(window->get_panda_framework()->get_models(), "models/monster_body.egg");
	NodePath new_leg_1 = window->load_model(window->get_panda_framework()->get_models(), "models/monster_leg_1.egg");


	NodePath bodyNP = character_path.find("**/+Character");      
	PT(Character) bodyCH = DCAST(Character, bodyNP.node()); 

	PT(CharacterJointBundle) bodyBundle = bodyCH->get_bundle(0);
	NodePath hip1NP = character_path.attach_new_node("hip_1_node");
	PT(CharacterJoint) hip1_joint = bodyCH->find_joint("hip_1");

	hip1NP.set_mat(hip1_joint->get_default_value()); 
	bodyBundle->control_joint("hip_1",hip1NP.node());



	NodePath leg1NP = new_leg_1.find("**/+Character"); 
	Character* leg1CH = DCAST(Character, leg1NP.node()); 

	PT(CharacterJointBundle) leg1Bundle = leg1CH->get_bundle(0);
	NodePath leg1NP = hip1NP.attach_new_node("leg_1_node");
	PT(CharacterJoint) leg1_joint = leg1CH->find_joint("leg_2");

	leg1NP.set_mat(hip1_joint->get_default_value());
	leg1Bundle->control_joint("leg_1",leg1NP.node());



	leg1NP.reparent_to(hip1NP);

I have been looking at the actor.py file and searching the forums for the proper way to do this in C++. Currently my models are loading properly and the joints seem to be found but the models are not parenting to each other. Does control joint govern the entire transform of a node?

I’m not sure what you’re asking. You want to stack up the joints together, so that when the bottom model animates, say, his head, then the animated hat perched on the head will inherit the head animation and also play its own animation?

In Python, this isn’t done through the use of control joints. It’s done via exposed joints and normal scene graph inheritance.

There are two ways to bind a joint to a node. You can “expose” it, which means the joint is animated by its animation file, but the computed transform is copied to the node every frame where other things can be parented to it and thus inherit the transform. Or, you can “control” it, which means the joint is no longer animated by its animation file, but instead the transform is copied from the node every frame.

I guess it might work to “control” the root joint of a hierarchy, but that would be a relatively expensive way to inherit animation; and I haven’t tried it anyway, in Python or in C++.

David

What I’m looking for is a stand in for the multi-part actor system. Perhaps I’m over complicating it.

If I load two models, each with their own animation can I flatten them together and still use the seperate animations?

Yes. Flattening does not combine animations; even though the resulting node might be a single GeomNode, the animations are independently controlled.

David

I knew this was a silly thing. It’ll teach me not to experiment with the obvious. :unamused:

Thanks.