Seeing Double: reusing Models and Actors in Panda3D

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.

Advertisement

0 Responses to “Seeing Double: reusing Models and Actors in Panda3D”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s





Follow

Get every new post delivered to your Inbox.