Panda3D makes an essential distinction between nodepaths and nodes.
The easiest (and most useful) way to understand this is to consider that each node in your rendering graph (a PandaNode instance) is encapsulated within a NodePath instance.
Incidentally, this allows sharing nodes. The sample code below will assign an instance of a loaded actor to a new nodepath. This process (‘instantiation‘ – according to the manual) can be repeated to share your actor.
actor = Actor.Actor(FILE_PATH, ...) # nodePath is the path to the node you are attaching # your new instance to, # e.g. the scene-graph root, render, is actually a NodePath instancePath = nodePath.attachNewNode(NAME) actor.instanceTo(instancePath)
Since nodes can be shared, it’s not always possible to get the nodepath knowing the node, so it’s important to keep track of nodepath references.
Note that, if you play an animation on your actor, the same animation will play for every nodepath the actor is attached to. So this would be more useful to duplicate inanimate objects, or sync-ed animated objects.
0 Responses to “Seeing Double: reusing Models and Actors in Panda3D”