The Actor class must be imported before any loading or manipulation of actors.
from direct.actor import Actor
|
Once the module is loaded, the actor object must be constructed, and the model and animations must be loaded:
nodePath = Actor.Actor()
nodePath.loadModel(‘Model Path’>
nodePath.loadAnims({‘Arbitrary Name1’:’Animation Path 1’})
nodePath.loadAnims({‘Arbitrary Name2’:’Animation Path 2’})
|
Loading each animation requires a tuple: the name one is giving the animation and the path to the animation. This entire process can be shortened to a single command:
nodePath = Actor.Actor('Model Path', {
'Animation Name 1':'Animation Path 1',
'Animation Name 2':'Animation Path 2',
})
|
Animations may also be unloaded using the same tuple used in creating them.
nodePath.unloadAnims({'Animation Name':'Animation Path'})
|
Although this is a rarely-used technique, it is possible to assemble a
character model out of several separate pieces (separate models). If
this is the case, then the pieces must contain bones that can be attached
to each other. For example, if you have a robot consisting of a set
of legs and a swappable torso, and if you want to glue them together at
the waist, then the legs model should contain a bone "waist", and the torso model should also contain a bone "waist". You can then attach them together:
nodePath = Actor.Actor({
'legs':'RobotLegs.egg',
'torso':'RobotTorso1.egg',
},{'dance':'RobotDance.egg'})
nodePath.attach('legs','torso','waist')
|
|