Panda3D
Classes | Functions | Variables

Package actor.Actor

Classes

class  Actor

Functions

def actorInterval
def addLOD
 sortedKeys = self.switches.keys() sortedKeys.sort() for eachLod in sortedKeys: index = sortedKeys.index(eachLod) self.__LODNode.node().setSwitch(index, self.switches[eachLod][0], self.switches[eachLod][1])
def animPanel
def attach
def bindAllAnims
def bindAnim
def clearLODAnimation
def controlJoint
def disableBlend
def drawInFront
def enableBlend
def exposeJoint
def faceAwayFromViewer
def faceTowardsViewer
def fixBounds
def fixBounds_old
def freezeJoint
def getAnimBlends
def getAnimControl
def getAnimControls
def getAnimFilename
def getBaseFrameRate
def getCurrentAnim
def getCurrentFrame
def getDuration
def getFrameRate
def getFrameTime
def getJoints
def getJointTransform
def getLOD
def getLODIndex
 sortedKeys = self.switches.keys() sortedKeys.sort()
def getNumFrames
def getOverlappingJoints
def getPart
def getPartBundle
def getPlayRate
def getSubpartsComplete
def hasLOD
def hideAllBounds
def hidePart
def initAnimsOnAllLODs
def instance
def loadAnims
def loadAnimsOnAllLODs
def loadModel
def loop
def makeSubpart
def osdAnimBlends
def pingpong
def play
def pose
def postFlatten
def printAnimBlends
def printLOD
def releaseJoint
def removePart
def renamePartBundles
def resetLOD
def setBlend
def setCenter
def setControlEffect
def setLOD
def setLODAnimation
def setPlayRate
def setSubpartsComplete
def showAllBounds
def showAllParts
def showPart
def stop
def stopJoint
def unloadAnims
def update
def verifySubpartsComplete
def waitPending

Variables

list __all__ = ['Actor']
 __commonBundleHandles
 __LODAnimation
 __LODCenter
 __subpartDict
 __subpartsComplete
tuple child = self.__LODNode.find(str(lodName))
 sortedKeys = self.switches.keys() sortedKeys.sort()
 gotName
tuple index = self.__LODNode.node()
 sortedKeys = self.__sortedLODNames
 sortedKeys = self.switches.keys() sortedKeys.sort()
tuple switchNum = self.__LODNode.node()

Detailed Description

Actor module: contains the Actor class

Function Documentation

def actor.Actor.actorInterval (   self,
  args,
  kw 
)
def actor.Actor.addLOD (   self,
  lodName,
  inDist = 0,
  outDist = 0,
  center = None 
)

sortedKeys = self.switches.keys() sortedKeys.sort() for eachLod in sortedKeys: index = sortedKeys.index(eachLod) self.__LODNode.node().setSwitch(index, self.switches[eachLod][0], self.switches[eachLod][1])

addLOD(self, string)
Add a named node under the LODNode to parent all geometry
of a specific LOD under.
def actor.Actor.animPanel (   self)
def actor.Actor.attach (   self,
  partName,
  anotherPartName,
  jointName,
  lodName = "lodRoot" 
)
attach(self, string, string, string, key="lodRoot")
Attach one actor part to another at a joint called jointName
def actor.Actor.bindAllAnims (   self,
  allowAsyncBind = False 
)
Loads and binds all animations that have been defined for
the Actor. 
def actor.Actor.bindAnim (   self,
  animName,
  partName = None,
  lodName = None,
  allowAsyncBind = False 
)
Binds the named animation to the named part and/or lod.  If
allowAsyncBind is False, this guarantees that the animation is
bound immediately--the animation is never bound in a
sub-thread; it will be loaded and bound in the main thread, so
it will be available by the time this method returns.

The parameters are the same as that for getAnimControls().  In
fact, this method is a thin wrapper around that other method.

Use this method if you need to ensure that an animation is
available before you start to play it, and you don't mind
holding up the render for a frame or two until the animation
is available.
def actor.Actor.clearLODAnimation (   self)
Description: Undoes the effect of a recent call to
set_lod_animation().  Henceforth, the character will animate
every frame, regardless of its distance from the camera.
def actor.Actor.controlJoint (   self,
  node,
  partName,
  jointName,
  lodName = "lodRoot" 
)
The converse of exposeJoint: this associates the joint with
the indicated node, so that the joint transform will be copied
from the node to the joint each frame.  This can be used for
programmer animation of a particular joint at runtime.

The parameter node should be the NodePath for the node whose
transform will animate the joint.  If node is None, a new node
will automatically be created and loaded with the joint's
initial transform.  In either case, the node used will be
returned.

It used to be necessary to call this before any animations
have been loaded and bound, but that is no longer so.
def actor.Actor.disableBlend (   self,
  partName = None 
)
Restores normal one-animation-at-a-time operation after a
previous call to enableBlend().

This method is deprecated.  You should use setBlend() instead.
def actor.Actor.drawInFront (   self,
  frontPartName,
  backPartName,
  mode,
  root = None,
  lodName = None 
)
drawInFront(self, string, int, string=None, key=None)

Arrange geometry so the frontPart(s) are drawn in front of
backPart.

If mode == -1, the geometry is simply arranged to be drawn in
the correct order, assuming it is already under a
direct-render scene graph (like the DirectGui system).  That
is, frontPart is reparented to backPart, and backPart is
reordered to appear first among its siblings.

If mode == -2, the geometry is arranged to be drawn in the
correct order, and depth test/write is turned off for
frontPart.

If mode == -3, frontPart is drawn as a decal onto backPart.
This assumes that frontPart is mostly coplanar with and does
not extend beyond backPart, and that backPart is mostly flat
(not self-occluding).

If mode > 0, the frontPart geometry is placed in the 'fixed'
bin, with the indicated drawing order.  This will cause it to
be drawn after almost all other geometry.  In this case, the
backPartName is actually unused.

Takes an optional argument root as the start of the search for the
given parts. Also takes optional lod name to refine search for the
named parts. If root and lod are defined, we search for the given
root under the given lod.
def actor.Actor.enableBlend (   self,
  blendType = PartBundle.BTNormalizedLinear,
  partName = None 
)
Enables blending of multiple animations simultaneously.
After this is called, you may call play(), loop(), or pose()
on multiple animations and have all of them contribute to the
final pose each frame.

With blending in effect, starting a particular animation with
play(), loop(), or pose() does not implicitly make the
animation visible; you must also call setControlEffect() for
each animation you wish to use to indicate how much each
animation contributes to the final pose.

This method is deprecated.  You should use setBlend() instead.
def actor.Actor.exposeJoint (   self,
  node,
  partName,
  jointName,
  lodName = "lodRoot",
  localTransform = 0 
)
exposeJoint(self, NodePath, string, string, key="lodRoot")
Starts the joint animating the indicated node.  As the joint
animates, it will transform the node by the corresponding
amount.  This will replace whatever matrix is on the node each
frame.  The default is to expose the net transform from the root,
but if localTransform is true, only the node's local transform
from its parent is exposed.
def actor.Actor.faceAwayFromViewer (   self)
def actor.Actor.faceTowardsViewer (   self)
def actor.Actor.fixBounds (   self,
  partName = None 
)
def actor.Actor.fixBounds_old (   self,
  part = None 
)
fixBounds(self, nodePath=None)
Force recomputation of bounding spheres for all geoms
in a given part. If no part specified, fix all geoms
in this actor
def actor.Actor.freezeJoint (   self,
  partName,
  jointName,
  transform = None,
  pos = Vec3(0,0,
  hpr = Vec3(0,0,
  scale = Vec3(1,1 
)
Similar to controlJoint, but the transform assigned is
static, and may not be animated at runtime (without another
subsequent call to freezeJoint).  This is slightly more
optimal than controlJoint() for cases in which the transform
is not intended to be animated during the lifetime of the
Actor. 
def actor.Actor.getAnimBlends (   self,
  animName = None,
  partName = None,
  lodName = None 
)
Returns a list of the form:

[ (lodName, [(animName, [(partName, effect), (partName, effect), ...]),
             (animName, [(partName, effect), (partName, effect), ...]),
             ...]),
  (lodName, [(animName, [(partName, effect), (partName, effect), ...]),
             (animName, [(partName, effect), (partName, effect), ...]),
             ...]),
   ... ]

This list reports the non-zero control effects for each
partName within a particular animation and LOD. 
def actor.Actor.getAnimControl (   self,
  animName,
  partName = None,
  lodName = None,
  allowAsyncBind = True 
)
getAnimControl(self, string, string, string="lodRoot")
Search the animControl dictionary indicated by lodName for
a given anim and part. If none specified, try the first part and lod.
Return the animControl if present, or None otherwise.
def actor.Actor.getAnimControls (   self,
  animName = None,
  partName = None,
  lodName = None,
  allowAsyncBind = True 
)
getAnimControls(self, string, string=None, string=None)

Returns a list of the AnimControls that represent the given
animation for the given part and the given lod.

If animName is None or omitted, the currently-playing
animation (or all currently-playing animations) is returned.
If animName is True, all animations are returned.  If animName
is a single string name, that particular animation is
returned.  If animName is a list of string names, all of the
names animations are returned.

If partName is None or omitted, all parts are returned (or
possibly the one overall Actor part, according to the
subpartsComplete flag).

If lodName is None or omitted, all LOD's are returned.
def actor.Actor.getAnimFilename (   self,
  animName,
  partName = 'modelRoot' 
)
getAnimFilename(self, animName)
return the animFilename given the animName
def actor.Actor.getBaseFrameRate (   self,
  animName = None,
  partName = None 
)
getBaseFrameRate(self, string, string=None)
Return frame rate of given anim name and given part, unmodified
by any play rate in effect.
def actor.Actor.getCurrentAnim (   self,
  partName = None 
)
Return the anim currently playing on the actor. If part not
specified return current anim of an arbitrary part in dictionary.
NOTE: only returns info for an arbitrary LOD
def actor.Actor.getCurrentFrame (   self,
  animName = None,
  partName = None 
)
Return the current frame number of the named anim, or if no
anim is specified, then the anim current playing on the
actor. If part not specified return current anim of first part
in dictionary.  NOTE: only returns info for an arbitrary LOD
def actor.Actor.getDuration (   self,
  animName = None,
  partName = None,
  fromFrame = None,
  toFrame = None 
)
Return duration of given anim name and given part.
If no anim specified, use the currently playing anim.
If no part specified, return anim duration of first part.
NOTE: returns info for arbitrary LOD
def actor.Actor.getFrameRate (   self,
  animName = None,
  partName = None 
)
getFrameRate(self, string, string=None)
Return actual frame rate of given anim name and given part.
If no anim specified, use the currently playing anim.
If no part specified, return anim durations of first part.
NOTE: returns info only for an arbitrary LOD
def actor.Actor.getFrameTime (   self,
  anim,
  frame,
  partName = None 
)
def actor.Actor.getJoints (   self,
  partName = None,
  jointName = '*',
  lodName = None 
)
Returns the list of all joints, from the named part or
from all parts, that match the indicated jointName.  The
jointName may include pattern characters like *. 
def actor.Actor.getJointTransform (   self,
  partName,
  jointName,
  lodName = 'lodRoot' 
)
def actor.Actor.getLOD (   self,
  lodName 
)
getLOD(self, string)
Get the named node under the LOD to which we parent all LOD
specific geometry to. Returns 'None' if not found
def actor.Actor.getLODIndex (   self,
  lodName 
)

sortedKeys = self.switches.keys() sortedKeys.sort()

getLODIndex(self)
safe method (but expensive) for retrieving the child index
def actor.Actor.getNumFrames (   self,
  animName = None,
  partName = None 
)
def actor.Actor.getOverlappingJoints (   self,
  partNameA,
  partNameB,
  jointName = '*',
  lodName = None 
)
Returns the set of joints, matching jointName, that are
shared between partNameA and partNameB. 
def actor.Actor.getPart (   self,
  partName,
  lodName = "lodRoot" 
)
Find the named part in the optional named lod and return it, or
return None if not present
def actor.Actor.getPartBundle (   self,
  partName,
  lodName = "lodRoot" 
)
Find the named part in the optional named lod and return its
associated PartBundle, or return None if not present
def actor.Actor.getPlayRate (   self,
  animName = None,
  partName = None 
)
Return the play rate of given anim for a given part.
If no part is given, assume first part in dictionary.
If no anim is given, find the current anim for the part.
NOTE: Returns info only for an arbitrary LOD
def actor.Actor.getSubpartsComplete (   self)
See setSubpartsComplete().
def actor.Actor.hasLOD (   self)
Return 1 if the actor has LODs, 0 otherwise
def actor.Actor.hideAllBounds (   self)
Hide the bounds of all actor geoms
def actor.Actor.hidePart (   self,
  partName,
  lodName = "lodRoot" 
)
Make the given part of the optionally given lod not render,
even though still in the tree.
NOTE: this will affect child geometry
def actor.Actor.initAnimsOnAllLODs (   self,
  partNames 
)
def actor.Actor.instance (   self,
  path,
  partName,
  jointName,
  lodName = "lodRoot" 
)
instance(self, NodePath, string, string, key="lodRoot")
Instance a nodePath to an actor part at a joint called jointName
def actor.Actor.loadAnims (   self,
  anims,
  partName = "modelRoot",
  lodName = "lodRoot" 
)
loadAnims(self, string:string{}, string='modelRoot',
string='lodRoot')
Actor anim loader. Takes an optional partName (defaults to
'modelRoot' for non-multipart actors) and lodName (defaults
to 'lodRoot' for non-LOD actors) and dict of corresponding
anims in the form animName:animPath{}
def actor.Actor.loadAnimsOnAllLODs (   self,
  anims,
  partName = "modelRoot" 
)
loadAnims(self, string:string{}, string='modelRoot',
string='lodRoot')
Actor anim loader. Takes an optional partName (defaults to
'modelRoot' for non-multipart actors) and lodName (defaults
to 'lodRoot' for non-LOD actors) and dict of corresponding
anims in the form animName:animPath{}
def actor.Actor.loadModel (   self,
  modelPath,
  partName = "modelRoot",
  lodName = "lodRoot",
  copy = True,
  okMissing = None,
  autoBindAnims = True 
)
Actor model loader. Takes a model name (ie file path), a part
name(defaults to "modelRoot") and an lod name(defaults to "lodRoot").
def actor.Actor.loop (   self,
  animName,
  restart = 1,
  partName = None,
  fromFrame = None,
  toFrame = None 
)
loop(self, string, int=1, string=None)
Loop the given animation on the given part of the actor,
restarting at zero frame if requested. If no part name
is given then try to loop on all parts. NOTE: loops on
all LOD's
def actor.Actor.makeSubpart (   self,
  partName,
  includeJoints,
  excludeJoints = [],
  parent = "modelRoot",
  overlapping = False 
)
Defines a new "part" of the Actor that corresponds to the
same geometry as the named parent part, but animates only a
certain subset of the joints.  This can be used for
partial-body animations, for instance to animate a hand waving
while the rest of the body continues to play its walking
animation.

includeJoints is a list of joint names that are to be animated
by the subpart.  Each name can include globbing characters
like '?' or '*', which will match one or any number of
characters, respectively.  Including a joint by naming it in
includeJoints implicitly includes all of the descendents of
that joint as well, except for excludeJoints, below.

excludeJoints is a list of joint names that are *not* to be
animated by the subpart.  As in includeJoints, each name can
include globbing characters.  If a joint is named by
excludeJoints, it will not be included (and neither will any
of its descendents), even if a parent joint was named by
includeJoints.

if overlapping is False, an error is raised (in the dev build)
if this subpart shares joints with any other subparts.  If
overlapping is True, no such error is raised.

parent is the actual partName that this subpart is based
on.
def actor.Actor.osdAnimBlends (   self,
  animName = None,
  partName = None,
  lodName = None 
)
def actor.Actor.pingpong (   self,
  animName,
  restart = 1,
  partName = None,
  fromFrame = None,
  toFrame = None 
)
pingpong(self, string, int=1, string=None)
Loop the given animation on the given part of the actor,
restarting at zero frame if requested. If no part name
is given then try to loop on all parts. NOTE: loops on
all LOD's
def actor.Actor.play (   self,
  animName,
  partName = None,
  fromFrame = None,
  toFrame = None 
)
play(self, string, string=None)
Play the given animation on the given part of the actor.
If no part is specified, try to play on all parts. NOTE:
plays over ALL LODs
def actor.Actor.pose (   self,
  animName,
  frame,
  partName = None,
  lodName = None 
)
pose(self, string, int, string=None)
Pose the actor in position found at given frame in the specified
animation for the specified part. If no part is specified attempt
to apply pose to all parts.
def actor.Actor.postFlatten (   self)
Call this after performing an aggressive flatten operation,
such as flattenStrong(), that involves the Actor.  This is
especially necessary when mergeLODBundles is true, since this
kind of actor may be broken after a flatten operation; this
method should restore proper Actor functionality. 
def actor.Actor.printAnimBlends (   self,
  animName = None,
  partName = None,
  lodName = None 
)
def actor.Actor.printLOD (   self)
def actor.Actor.releaseJoint (   self,
  partName,
  jointName 
)
Undoes a previous call to controlJoint() or freezeJoint()
and restores the named joint to its normal animation. 
def actor.Actor.removePart (   self,
  partName,
  lodName = "lodRoot" 
)
Remove the geometry and animations of the named part of the
optional named lod if present.
NOTE: this will remove child geometry also!
def actor.Actor.renamePartBundles (   self,
  partName,
  newBundleName 
)
def actor.Actor.resetLOD (   self)
Restore all switch distance info (usually after a useLOD call)
def actor.Actor.setBlend (   self,
  animBlend = None,
  frameBlend = None,
  blendType = None,
  partName = None 
)
Changes the way the Actor handles blending of multiple
different animations, and/or interpolation between consecutive
frames.

The animBlend and frameBlend parameters are boolean flags.
You may set either or both to True or False.  If you do not
specify them, they do not change from the previous value.

When animBlend is True, multiple different animations may
simultaneously be playing on the Actor.  This means you may
call play(), loop(), or pose() on multiple animations and have
all of them contribute to the final pose each frame.

In this mode (that is, when animBlend is True), starting a
particular animation with play(), loop(), or pose() does not
implicitly make the animation visible; you must also call
setControlEffect() for each animation you wish to use to
indicate how much each animation contributes to the final
pose.

The frameBlend flag is unrelated to playing multiple
animations.  It controls whether the Actor smoothly
interpolates between consecutive frames of its animation (when
the flag is True) or holds each frame until the next one is
ready (when the flag is False).  The default value of
frameBlend is controlled by the interpolate-frames Config.prc
variable.

In either case, you may also specify blendType, which controls
the precise algorithm used to blend two or more different
matrix values into a final result.  Different skeleton
hierarchies may benefit from different algorithms.  The
default blendType is controlled by the anim-blend-type
Config.prc variable.
def actor.Actor.setCenter (   self,
  center 
)
def actor.Actor.setControlEffect (   self,
  animName,
  effect,
  partName = None,
  lodName = None 
)
Sets the amount by which the named animation contributes to
the overall pose.  This controls blending of multiple
animations; it only makes sense to call this after a previous
call to setBlend(animBlend = True).
def actor.Actor.setLOD (   self,
  lodName,
  inDist = 0,
  outDist = 0 
)
setLOD(self, string)
Set the switch distance for given LOD
def actor.Actor.setLODAnimation (   self,
  farDistance,
  nearDistance,
  delayFactor 
)
Activates a special mode in which the Actor animates less
frequently as it gets further from the camera.  This is
intended as a simple optimization to minimize the effort of
computing animation for lots of characters that may not
necessarily be very important to animate every frame.

If the character is closer to the camera than near_distance,
then it is animated its normal rate, every frame.  If the
character is exactly far_distance away, it is animated only
every delay_factor seconds (which should be a number greater
than 0).  If the character is between near_distance and
far_distance, its animation rate is linearly interpolated
according to its distance between the two.  The interpolation
function continues beyond far_distance, so that the character
is animated increasingly less frequently as it gets farther
away. 
def actor.Actor.setPlayRate (   self,
  rate,
  animName,
  partName = None 
)
setPlayRate(self, float, string, string=None)
Set the play rate of given anim for a given part.
If no part is given, set for all parts in dictionary.

It used to be legal to let the animName default to the
currently-playing anim, but this was confusing and could lead
to the wrong anim's play rate getting set.  Better to insist
on this parameter.
NOTE: sets play rate on all LODs
def actor.Actor.setSubpartsComplete (   self,
  flag 
)
Sets the subpartsComplete flag.  This affects the behavior
of play(), loop(), stop(), etc., when no explicit parts are
specified.

When this flag is False (the default), play() with no parts
means to play the animation on the overall Actor, which is a
separate part that overlaps each of the subparts.  If you then
play a different animation on a subpart, it may stop the
overall animation (in non-blend mode) or blend with it (in
blend mode).

When this flag is True, play() with no parts means to play the
animation on each of the subparts--instead of on the overall
Actor.  In this case, you may then play a different animation
on a subpart, which replaces only that subpart's animation.

It makes sense to set this True when the union of all of your
subparts completely defines the entire Actor.
def actor.Actor.showAllBounds (   self)
Show the bounds of all actor geoms
def actor.Actor.showAllParts (   self,
  partName,
  lodName = "lodRoot" 
)
Make the given part and all its children render while in the tree.
NOTE: this will affect child geometry
def actor.Actor.showPart (   self,
  partName,
  lodName = "lodRoot" 
)
Make the given part render while in the tree.
NOTE: this will affect child geometry
def actor.Actor.stop (   self,
  animName = None,
  partName = None 
)
stop(self, string=None, string=None)
Stop named animation on the given part of the actor.
If no name specified then stop all animations on the actor.
NOTE: stops all LODs
def actor.Actor.stopJoint (   self,
  partName,
  jointName,
  lodName = "lodRoot" 
)
stopJoint(self, string, string, key="lodRoot")
Stops the joint from animating external nodes.  If the joint
is animating a transform on a node, this will permanently stop
it.  However, this does not affect vertex animations.
def actor.Actor.unloadAnims (   self,
  anims = None,
  partName = None,
  lodName = None 
)
unloadAnims(self, string:string{}, string='modelRoot',
string='lodRoot')
Actor anim unloader. Takes an optional partName (defaults to
'modelRoot' for non-multipart actors) and lodName (defaults
to 'lodRoot' for non-LOD actors) and dict of corresponding
anims in the form animName:animPath{}. Deletes the anim control
for the given animation and parts/lods.

If any parameter is None or omitted, it means all of them.
def actor.Actor.update (   self,
  lod = 0,
  partName = None,
  lodName = None,
  force = False 
)
Updates all of the Actor's joints in the indicated LOD.
The LOD may be specified by name, or by number, where 0 is the
highest level of detail, 1 is the next highest, and so on.

If force is True, this will update every joint, even if we
don't believe it's necessary.

Returns True if any joint has changed as a result of this,
False otherwise. 
def actor.Actor.verifySubpartsComplete (   self,
  partName = None,
  lodName = None 
)
Ensures that each joint is defined by at least one
subPart.  Prints a warning if this is not the case. 
def actor.Actor.waitPending (   self,
  partName = None 
)
Blocks until all asynchronously pending animations (that
are currently playing) have been loaded and bound the the
Actor.  Call this after calling play() if you are using
asynchronous binds, but you need this particular animation
to be loaded immediately. 

Variable Documentation

list __all__ = ['Actor']
tuple child = self.__LODNode.find(str(lodName))

sortedKeys = self.switches.keys() sortedKeys.sort()

tuple index = self.__LODNode.node()
sortedKeys = self.__sortedLODNames

sortedKeys = self.switches.keys() sortedKeys.sort()

tuple switchNum = self.__LODNode.node()
 All Classes Namespaces Functions Variables Properties