using the datagraph to drive movement


I’ve been looking at Panda’s datagraph classes and wondering if they would provide a good solution to a problem I’m facing.

I need to drive the position and orientation of a nodepath from the position and orientation of a joint. However, for certain reasons I can not parent this node path to the joint.

I could use a task to constantly update the position and orientation but say I wanted to do this to several or many joint/nodepath pairs. I was thinking using the datagraph might be a more efficient and elegant solution.

Does anyone have any experience using the datagraph for things outside device input? One thing I’m curious about is how establishing the inputs and outputs is done.

Or maybe someone has a better idea how to achieve this effect?

Thanks for any input!

The data graph is designed to be extensible at the C++ level, but not at the Python level. To use the data graph for the purpose you describe would require writing a number of new C++ classes and compiling them into Panda.

But you don’t need to do this. Just do something like:

actor.exposeJoint(myNodePath, "modelRoot", "myJointName")

You can make this call repeatedly to apply the transform from a joint simultaneously to as many different NodePaths as you want. If you want only the local transform of the joint itself, and not the accumulated transform of the joint and all of its parent joints, then include localTransform = True on the parameter list.

The NodePaths do not have to be within the actor’s hierarchy, although that helps. If they are not, you may find it necessary to spawn a task to call actor.update() every frame, to ensure that the NodePaths are kept up-to-date automatically before they are rendered.