Panda3D Manual: Multi-Part Actors
<<prev | top | next>> |
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')
You can let each part have it's own animation by supplying an animation dictionary:
myactor = Actor(
       # part dictionary
       {"head":"char/dogMM/dogMM_Shorts-head-mod",
        "torso":"char/dogMM/dogMM_Shorts-torso-mod",
        "legs":"char/dogMM/dogMM_Shorts-legs-mod"},
       # dictionary of anim dictionaries
       {"head":{"walk":"char/dogMM/dogMM_Shorts-head-walk",
                "run":"char/dogMM/dogMM_Shorts-head-run"},
        "torso":{"walk":"char/dogMM/dogMM_Shorts-torso-walk",
                 "run":"char/dogMM/dogMM_Shorts-torso-run"},
        "legs":{"walk":"char/dogMM/dogMM_Shorts-legs-walk",
                "run":"char/dogMM/dogMM_Shorts-legs-run"}
        })
In addition multipart actor parts need to be connected together in a meaningful fashion:
myactor.attach("head", "torso", "joint-head") myactor.attach("torso", "legs", "joint-hips")
## Animation You can animate the parts as normal animations, but you need to supply the partname, like this:
myactor.play('Animation Name', 'Part Name')
If you want to use AnimControl, as explained in this section, you must supply the partname as second parameter in getAnimControl():
    #you can see you just need to call actor.getAnimControl('Animation Name','Part Name') to get access to the AnimControl of that part.
    ac=actor.getAnimControl('Animation Name','Part Name')
    ac.isPlaying() #returns a boolean whether the animation is playing or not
    ac.getFrame() #returns the current frame number
    ac.getFrameRate() #returns the speed of the animation, in frames per second
    ac.getFullFframe() #returns a floating-point frame number. Note: This number keeps counting and may exceed the total number of frames.
    ac.getFullFrame() #returns an integer frame number. Note: This number keeps counting and may exceed the total number of frames.
    ac.getNextFrame() #returns the number of the next frame on the queue.
    ac.getNumFrames() #returns the total number of frames
    ac.getPlayRate() #returns the playrate. explained further below
    ac.loop() #starts playing the animation in a loop
    ac.play() #starts playing the animation
    ac.pose(frame) #poses at frame frame
    ac.setPlayRate(rate) #sets the playrate.  explained further below
    ac.stop() #stops the animation
<<prev | top | next>> |