|
@@ -5,6 +5,7 @@ __all__ = ['Actor']
|
|
|
from panda3d.core import *
|
|
from panda3d.core import *
|
|
|
from panda3d.core import Loader as PandaLoader
|
|
from panda3d.core import Loader as PandaLoader
|
|
|
from direct.showbase.DirectObject import DirectObject
|
|
from direct.showbase.DirectObject import DirectObject
|
|
|
|
|
+from direct.showbase.Loader import Loader
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
|
from direct.directnotify import DirectNotifyGlobal
|
|
|
|
|
|
|
|
|
|
|
|
@@ -67,7 +68,7 @@ class Actor(DirectObject, NodePath):
|
|
|
|
|
|
|
|
def __init__(self, filename = None, animBundle = None):
|
|
def __init__(self, filename = None, animBundle = None):
|
|
|
self.filename = filename
|
|
self.filename = filename
|
|
|
- self.animBundle = None
|
|
|
|
|
|
|
+ self.animBundle = animBundle
|
|
|
self.animControl = None
|
|
self.animControl = None
|
|
|
|
|
|
|
|
def makeCopy(self):
|
|
def makeCopy(self):
|
|
@@ -104,45 +105,43 @@ class Actor(DirectObject, NodePath):
|
|
|
lodNode = None, flattenable = True, setFinal = False,
|
|
lodNode = None, flattenable = True, setFinal = False,
|
|
|
mergeLODBundles = None, allowAsyncBind = None,
|
|
mergeLODBundles = None, allowAsyncBind = None,
|
|
|
okMissing = None):
|
|
okMissing = None):
|
|
|
- """__init__(self, string | string:string{}, string:string{} |
|
|
|
|
|
- string:(string:string{}){}, Actor=None)
|
|
|
|
|
- Actor constructor: can be used to create single or multipart
|
|
|
|
|
|
|
+ """Actor constructor: can be used to create single or multipart
|
|
|
actors. If another Actor is supplied as an argument this
|
|
actors. If another Actor is supplied as an argument this
|
|
|
method acts like a copy constructor. Single part actors are
|
|
method acts like a copy constructor. Single part actors are
|
|
|
created by calling with a model and animation dictionary
|
|
created by calling with a model and animation dictionary
|
|
|
- (animName:animPath{}) as follows:
|
|
|
|
|
|
|
+ ``(animName:animPath{})`` as follows::
|
|
|
|
|
|
|
|
- a = Actor("panda-3k.egg", {"walk":"panda-walk.egg" \
|
|
|
|
|
|
|
+ a = Actor("panda-3k.egg", {"walk":"panda-walk.egg",
|
|
|
"run":"panda-run.egg"})
|
|
"run":"panda-run.egg"})
|
|
|
|
|
|
|
|
- This could be displayed and animated as such:
|
|
|
|
|
|
|
+ This could be displayed and animated as such::
|
|
|
|
|
|
|
|
a.reparentTo(render)
|
|
a.reparentTo(render)
|
|
|
a.loop("walk")
|
|
a.loop("walk")
|
|
|
a.stop()
|
|
a.stop()
|
|
|
|
|
|
|
|
Multipart actors expect a dictionary of parts and a dictionary
|
|
Multipart actors expect a dictionary of parts and a dictionary
|
|
|
- of animation dictionaries (partName:(animName:animPath{}){}) as
|
|
|
|
|
- below:
|
|
|
|
|
|
|
+ of animation dictionaries ``(partName:(animName:animPath{}){})``
|
|
|
|
|
+ as below::
|
|
|
|
|
|
|
|
a = Actor(
|
|
a = Actor(
|
|
|
|
|
|
|
|
# part dictionary
|
|
# part dictionary
|
|
|
- {"head":"char/dogMM/dogMM_Shorts-head-mod", \
|
|
|
|
|
- "torso":"char/dogMM/dogMM_Shorts-torso-mod", \
|
|
|
|
|
- "legs":"char/dogMM/dogMM_Shorts-legs-mod"}, \
|
|
|
|
|
|
|
+ {"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
|
|
# 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"} \
|
|
|
|
|
|
|
+ {"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 addition multipart actor parts need to be connected together
|
|
|
- in a meaningful fashion:
|
|
|
|
|
|
|
+ in a meaningful fashion::
|
|
|
|
|
|
|
|
a.attach("head", "torso", "joint-head")
|
|
a.attach("head", "torso", "joint-head")
|
|
|
a.attach("torso", "legs", "joint-hips")
|
|
a.attach("torso", "legs", "joint-hips")
|
|
@@ -151,7 +150,7 @@ class Actor(DirectObject, NodePath):
|
|
|
# ADD LOD COMMENT HERE!
|
|
# ADD LOD COMMENT HERE!
|
|
|
#
|
|
#
|
|
|
|
|
|
|
|
- Other useful Actor class functions:
|
|
|
|
|
|
|
+ Other useful Actor class functions::
|
|
|
|
|
|
|
|
#fix actor eye rendering
|
|
#fix actor eye rendering
|
|
|
a.drawInFront("joint-pupil?", "eyes*")
|
|
a.drawInFront("joint-pupil?", "eyes*")
|
|
@@ -213,7 +212,7 @@ class Actor(DirectObject, NodePath):
|
|
|
self.__LODCenter = Point3(0, 0, 0)
|
|
self.__LODCenter = Point3(0, 0, 0)
|
|
|
self.switches = None
|
|
self.switches = None
|
|
|
|
|
|
|
|
- if (other == None):
|
|
|
|
|
|
|
+ if other is None:
|
|
|
# act like a normal constructor
|
|
# act like a normal constructor
|
|
|
|
|
|
|
|
# create base hierarchy
|
|
# create base hierarchy
|
|
@@ -353,7 +352,7 @@ class Actor(DirectObject, NodePath):
|
|
|
self.gotName = other.gotName
|
|
self.gotName = other.gotName
|
|
|
|
|
|
|
|
# copy the scene graph elements of other
|
|
# copy the scene graph elements of other
|
|
|
- if (overwrite):
|
|
|
|
|
|
|
+ if overwrite:
|
|
|
otherCopy = other.copyTo(NodePath())
|
|
otherCopy = other.copyTo(NodePath())
|
|
|
otherCopy.detachNode()
|
|
otherCopy.detachNode()
|
|
|
# assign these elements to ourselve (overwrite)
|
|
# assign these elements to ourselve (overwrite)
|
|
@@ -373,7 +372,7 @@ class Actor(DirectObject, NodePath):
|
|
|
self.switches = other.switches
|
|
self.switches = other.switches
|
|
|
self.__LODNode = self.find('**/+LODNode')
|
|
self.__LODNode = self.find('**/+LODNode')
|
|
|
self.__hasLOD = 0
|
|
self.__hasLOD = 0
|
|
|
- if (not self.__LODNode.isEmpty()):
|
|
|
|
|
|
|
+ if not self.__LODNode.isEmpty():
|
|
|
self.__hasLOD = 1
|
|
self.__hasLOD = 1
|
|
|
|
|
|
|
|
|
|
|
|
@@ -419,7 +418,7 @@ class Actor(DirectObject, NodePath):
|
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
|
|
|
|
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
|
- if partDef == None:
|
|
|
|
|
|
|
+ if partDef is None:
|
|
|
Actor.notify.error("no part named: %s" % (partName))
|
|
Actor.notify.error("no part named: %s" % (partName))
|
|
|
|
|
|
|
|
self.__doListJoints(0, partDef.getBundle(),
|
|
self.__doListJoints(0, partDef.getBundle(),
|
|
@@ -492,7 +491,7 @@ class Actor(DirectObject, NodePath):
|
|
|
for animName, file, animControl in animInfo:
|
|
for animName, file, animControl in animInfo:
|
|
|
print(' Anim: %s' % animName)
|
|
print(' Anim: %s' % animName)
|
|
|
print(' File: %s' % file)
|
|
print(' File: %s' % file)
|
|
|
- if animControl == None:
|
|
|
|
|
|
|
+ if animControl is None:
|
|
|
print(' (not loaded)')
|
|
print(' (not loaded)')
|
|
|
else:
|
|
else:
|
|
|
print(' NumFrames: %d PlayRate: %0.2f' %
|
|
print(' NumFrames: %d PlayRate: %0.2f' %
|
|
@@ -501,7 +500,12 @@ class Actor(DirectObject, NodePath):
|
|
|
|
|
|
|
|
def cleanup(self):
|
|
def cleanup(self):
|
|
|
"""
|
|
"""
|
|
|
- Actor cleanup function
|
|
|
|
|
|
|
+ This method should be called when intending to destroy the Actor, and
|
|
|
|
|
+ cleans up any additional resources stored on the Actor class before
|
|
|
|
|
+ removing the underlying node using `removeNode()`.
|
|
|
|
|
+
|
|
|
|
|
+ Note that `removeNode()` itself is not sufficient to destroy actors,
|
|
|
|
|
+ which is why this method exists.
|
|
|
"""
|
|
"""
|
|
|
self.stop(None)
|
|
self.stop(None)
|
|
|
self.clearPythonData()
|
|
self.clearPythonData()
|
|
@@ -513,6 +517,11 @@ class Actor(DirectObject, NodePath):
|
|
|
self.removeNode()
|
|
self.removeNode()
|
|
|
|
|
|
|
|
def removeNode(self):
|
|
def removeNode(self):
|
|
|
|
|
+ """
|
|
|
|
|
+ You should call `cleanup()` for Actor objects instead, since
|
|
|
|
|
+ :meth:`~panda3d.core.NodePath.removeNode()` is not sufficient for
|
|
|
|
|
+ completely destroying Actor objects.
|
|
|
|
|
+ """
|
|
|
if self.__geomNode and (self.__geomNode.getNumChildren() > 0):
|
|
if self.__geomNode and (self.__geomNode.getNumChildren() > 0):
|
|
|
assert self.notify.warning("called actor.removeNode() on %s without calling cleanup()" % self.getName())
|
|
assert self.notify.warning("called actor.removeNode() on %s without calling cleanup()" % self.getName())
|
|
|
NodePath.removeNode(self)
|
|
NodePath.removeNode(self)
|
|
@@ -526,7 +535,7 @@ class Actor(DirectObject, NodePath):
|
|
|
|
|
|
|
|
def flush(self):
|
|
def flush(self):
|
|
|
"""
|
|
"""
|
|
|
- Actor flush function
|
|
|
|
|
|
|
+ Actor flush function. Used by `cleanup()`.
|
|
|
"""
|
|
"""
|
|
|
self.clearPythonData()
|
|
self.clearPythonData()
|
|
|
|
|
|
|
@@ -558,14 +567,14 @@ class Actor(DirectObject, NodePath):
|
|
|
bundles = []
|
|
bundles = []
|
|
|
|
|
|
|
|
for lodName, partBundleDict in self.__partBundleDict.items():
|
|
for lodName, partBundleDict in self.__partBundleDict.items():
|
|
|
- if partName == None:
|
|
|
|
|
|
|
+ if partName is None:
|
|
|
for partDef in partBundleDict.values():
|
|
for partDef in partBundleDict.values():
|
|
|
bundles.append(partDef.getBundle())
|
|
bundles.append(partDef.getBundle())
|
|
|
|
|
|
|
|
else:
|
|
else:
|
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
|
- if partDef != None:
|
|
|
|
|
|
|
+ if partDef is not None:
|
|
|
bundles.append(partDef.getBundle())
|
|
bundles.append(partDef.getBundle())
|
|
|
else:
|
|
else:
|
|
|
Actor.notify.warning("Couldn't find part: %s" % (partName))
|
|
Actor.notify.warning("Couldn't find part: %s" % (partName))
|
|
@@ -636,7 +645,7 @@ class Actor(DirectObject, NodePath):
|
|
|
Set the node that switches actor geometry in and out.
|
|
Set the node that switches actor geometry in and out.
|
|
|
If one is not supplied as an argument, make one
|
|
If one is not supplied as an argument, make one
|
|
|
"""
|
|
"""
|
|
|
- if (node == None):
|
|
|
|
|
|
|
+ if node is None:
|
|
|
node = LODNode.makeDefaultLod("lod")
|
|
node = LODNode.makeDefaultLod("lod")
|
|
|
|
|
|
|
|
if self.__LODNode:
|
|
if self.__LODNode:
|
|
@@ -686,7 +695,7 @@ class Actor(DirectObject, NodePath):
|
|
|
self.switches[lodName] = [inDist, outDist]
|
|
self.switches[lodName] = [inDist, outDist]
|
|
|
# add the switch distance info
|
|
# add the switch distance info
|
|
|
self.__LODNode.node().addSwitch(inDist, outDist)
|
|
self.__LODNode.node().addSwitch(inDist, outDist)
|
|
|
- if center != None:
|
|
|
|
|
|
|
+ if center is not None:
|
|
|
self.setCenter(center)
|
|
self.setCenter(center)
|
|
|
|
|
|
|
|
def setLOD(self, lodName, inDist=0, outDist=0):
|
|
def setLOD(self, lodName, inDist=0, outDist=0):
|
|
@@ -725,7 +734,7 @@ class Actor(DirectObject, NodePath):
|
|
|
return self.__hasLOD
|
|
return self.__hasLOD
|
|
|
|
|
|
|
|
def setCenter(self, center):
|
|
def setCenter(self, center):
|
|
|
- if center == None:
|
|
|
|
|
|
|
+ if center is None:
|
|
|
center = Point3(0, 0, 0)
|
|
center = Point3(0, 0, 0)
|
|
|
self.__LODCenter = center
|
|
self.__LODCenter = center
|
|
|
if self.__LODNode:
|
|
if self.__LODNode:
|
|
@@ -783,7 +792,7 @@ class Actor(DirectObject, NodePath):
|
|
|
Returns True if any joint has changed as a result of this,
|
|
Returns True if any joint has changed as a result of this,
|
|
|
False otherwise. """
|
|
False otherwise. """
|
|
|
|
|
|
|
|
- if lodName == None:
|
|
|
|
|
|
|
+ if lodName is None:
|
|
|
lodNames = self.getLODNames()
|
|
lodNames = self.getLODNames()
|
|
|
else:
|
|
else:
|
|
|
lodNames = [lodName]
|
|
lodNames = [lodName]
|
|
@@ -791,7 +800,7 @@ class Actor(DirectObject, NodePath):
|
|
|
anyChanged = False
|
|
anyChanged = False
|
|
|
if lod < len(lodNames):
|
|
if lod < len(lodNames):
|
|
|
lodName = lodNames[lod]
|
|
lodName = lodNames[lod]
|
|
|
- if partName == None:
|
|
|
|
|
|
|
+ if partName is None:
|
|
|
partBundleDict = self.__partBundleDict[lodName]
|
|
partBundleDict = self.__partBundleDict[lodName]
|
|
|
partNames = list(partBundleDict.keys())
|
|
partNames = list(partBundleDict.keys())
|
|
|
else:
|
|
else:
|
|
@@ -907,11 +916,11 @@ class Actor(DirectObject, NodePath):
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
lodName, animControlDict = next(iter(self.__animControlDict.items()))
|
|
lodName, animControlDict = next(iter(self.__animControlDict.items()))
|
|
|
- if partName == None:
|
|
|
|
|
|
|
+ if partName is None:
|
|
|
partName, animDict = next(iter(animControlDict.items()))
|
|
partName, animDict = next(iter(animControlDict.items()))
|
|
|
else:
|
|
else:
|
|
|
animDict = animControlDict.get(partName)
|
|
animDict = animControlDict.get(partName)
|
|
|
- if animDict == None:
|
|
|
|
|
|
|
+ if animDict is None:
|
|
|
# part was not present
|
|
# part was not present
|
|
|
Actor.notify.warning("couldn't find part: %s" % (partName))
|
|
Actor.notify.warning("couldn't find part: %s" % (partName))
|
|
|
return None
|
|
return None
|
|
@@ -932,11 +941,11 @@ class Actor(DirectObject, NodePath):
|
|
|
in dictionary. NOTE: only returns info for an arbitrary LOD
|
|
in dictionary. NOTE: only returns info for an arbitrary LOD
|
|
|
"""
|
|
"""
|
|
|
lodName, animControlDict = next(iter(self.__animControlDict.items()))
|
|
lodName, animControlDict = next(iter(self.__animControlDict.items()))
|
|
|
- if partName == None:
|
|
|
|
|
|
|
+ if partName is None:
|
|
|
partName, animDict = next(iter(animControlDict.items()))
|
|
partName, animDict = next(iter(animControlDict.items()))
|
|
|
else:
|
|
else:
|
|
|
animDict = animControlDict.get(partName)
|
|
animDict = animControlDict.get(partName)
|
|
|
- if animDict == None:
|
|
|
|
|
|
|
+ if animDict is None:
|
|
|
# part was not present
|
|
# part was not present
|
|
|
Actor.notify.warning("couldn't find part: %s" % (partName))
|
|
Actor.notify.warning("couldn't find part: %s" % (partName))
|
|
|
return None
|
|
return None
|
|
@@ -970,7 +979,7 @@ class Actor(DirectObject, NodePath):
|
|
|
return None
|
|
return None
|
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
|
- if partDef != None:
|
|
|
|
|
|
|
+ if partDef is not None:
|
|
|
return partDef.partBundleNP
|
|
return partDef.partBundleNP
|
|
|
return None
|
|
return None
|
|
|
|
|
|
|
@@ -985,7 +994,7 @@ class Actor(DirectObject, NodePath):
|
|
|
return None
|
|
return None
|
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
|
- if partDef != None:
|
|
|
|
|
|
|
+ if partDef is not None:
|
|
|
return partDef.getBundle()
|
|
return partDef.getBundle()
|
|
|
return None
|
|
return None
|
|
|
|
|
|
|
@@ -1002,9 +1011,9 @@ class Actor(DirectObject, NodePath):
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
# remove the part
|
|
# remove the part
|
|
|
- if (partName in partBundleDict):
|
|
|
|
|
|
|
+ if partName in partBundleDict:
|
|
|
partBundleDict[partName].partBundleNP.removeNode()
|
|
partBundleDict[partName].partBundleNP.removeNode()
|
|
|
- del(partBundleDict[partName])
|
|
|
|
|
|
|
+ del partBundleDict[partName]
|
|
|
|
|
|
|
|
# find the corresponding anim control dict
|
|
# find the corresponding anim control dict
|
|
|
if self.mergeLODBundles:
|
|
if self.mergeLODBundles:
|
|
@@ -1015,8 +1024,8 @@ class Actor(DirectObject, NodePath):
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
# remove the animations
|
|
# remove the animations
|
|
|
- if (partName in partDict):
|
|
|
|
|
- del(partDict[partName])
|
|
|
|
|
|
|
+ if partName in partDict:
|
|
|
|
|
+ del partDict[partName]
|
|
|
|
|
|
|
|
def hidePart(self, partName, lodName="lodRoot"):
|
|
def hidePart(self, partName, lodName="lodRoot"):
|
|
|
"""
|
|
"""
|
|
@@ -1094,7 +1103,7 @@ class Actor(DirectObject, NodePath):
|
|
|
if node is None:
|
|
if node is None:
|
|
|
node = partDef.partBundleNP.attachNewNode(jointName)
|
|
node = partDef.partBundleNP.attachNewNode(jointName)
|
|
|
|
|
|
|
|
- if (joint):
|
|
|
|
|
|
|
+ if joint:
|
|
|
if localTransform:
|
|
if localTransform:
|
|
|
joint.addLocalTransform(node.node())
|
|
joint.addLocalTransform(node.node())
|
|
|
else:
|
|
else:
|
|
@@ -1126,7 +1135,7 @@ class Actor(DirectObject, NodePath):
|
|
|
# Get a handle to the joint.
|
|
# Get a handle to the joint.
|
|
|
joint = bundle.findChild(jointName)
|
|
joint = bundle.findChild(jointName)
|
|
|
|
|
|
|
|
- if (joint):
|
|
|
|
|
|
|
+ if joint:
|
|
|
joint.clearNetTransforms()
|
|
joint.clearNetTransforms()
|
|
|
joint.clearLocalTransforms()
|
|
joint.clearLocalTransforms()
|
|
|
else:
|
|
else:
|
|
@@ -1135,16 +1144,16 @@ class Actor(DirectObject, NodePath):
|
|
|
def getJoints(self, partName = None, jointName = '*', lodName = None):
|
|
def getJoints(self, partName = None, jointName = '*', lodName = None):
|
|
|
""" Returns the list of all joints, from the named part or
|
|
""" Returns the list of all joints, from the named part or
|
|
|
from all parts, that match the indicated jointName. The
|
|
from all parts, that match the indicated jointName. The
|
|
|
- jointName may include pattern characters like *. """
|
|
|
|
|
|
|
+ jointName may include pattern characters like \\*. """
|
|
|
|
|
|
|
|
joints=[]
|
|
joints=[]
|
|
|
pattern = GlobPattern(jointName)
|
|
pattern = GlobPattern(jointName)
|
|
|
|
|
|
|
|
- if lodName == None and self.mergeLODBundles:
|
|
|
|
|
|
|
+ if lodName is None and self.mergeLODBundles:
|
|
|
# Get the common bundle.
|
|
# Get the common bundle.
|
|
|
partBundleDicts = [self.__commonBundleHandles]
|
|
partBundleDicts = [self.__commonBundleHandles]
|
|
|
|
|
|
|
|
- elif lodName == None:
|
|
|
|
|
|
|
+ elif lodName is None:
|
|
|
# Get all LOD's.
|
|
# Get all LOD's.
|
|
|
partBundleDicts = self.__partBundleDict.values()
|
|
partBundleDicts = self.__partBundleDict.values()
|
|
|
else:
|
|
else:
|
|
@@ -1233,7 +1242,7 @@ class Actor(DirectObject, NodePath):
|
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
joint = bundle.findChild(jointName)
|
|
joint = bundle.findChild(jointName)
|
|
|
- if joint == None:
|
|
|
|
|
|
|
+ if joint is None:
|
|
|
Actor.notify.warning("no joint named %s!" % (jointName))
|
|
Actor.notify.warning("no joint named %s!" % (jointName))
|
|
|
return None
|
|
return None
|
|
|
return joint.getDefaultValue()
|
|
return joint.getDefaultValue()
|
|
@@ -1253,7 +1262,7 @@ class Actor(DirectObject, NodePath):
|
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
joint = bundle.findChild(jointName)
|
|
joint = bundle.findChild(jointName)
|
|
|
- if joint == None:
|
|
|
|
|
|
|
+ if joint is None:
|
|
|
Actor.notify.warning("no joint named %s!" % (jointName))
|
|
Actor.notify.warning("no joint named %s!" % (jointName))
|
|
|
return None
|
|
return None
|
|
|
return joint.getTransformState()
|
|
return joint.getTransformState()
|
|
@@ -1278,7 +1287,7 @@ class Actor(DirectObject, NodePath):
|
|
|
anyGood = False
|
|
anyGood = False
|
|
|
for bundleDict in self.__partBundleDict.values():
|
|
for bundleDict in self.__partBundleDict.values():
|
|
|
bundle = bundleDict[trueName].getBundle()
|
|
bundle = bundleDict[trueName].getBundle()
|
|
|
- if node == None:
|
|
|
|
|
|
|
+ if node is None:
|
|
|
node = self.attachNewNode(ModelNode(jointName))
|
|
node = self.attachNewNode(ModelNode(jointName))
|
|
|
joint = bundle.findChild(jointName)
|
|
joint = bundle.findChild(jointName)
|
|
|
if joint and isinstance(joint, MovingPartMatrix):
|
|
if joint and isinstance(joint, MovingPartMatrix):
|
|
@@ -1300,7 +1309,7 @@ class Actor(DirectObject, NodePath):
|
|
|
optimal than controlJoint() for cases in which the transform
|
|
optimal than controlJoint() for cases in which the transform
|
|
|
is not intended to be animated during the lifetime of the
|
|
is not intended to be animated during the lifetime of the
|
|
|
Actor. """
|
|
Actor. """
|
|
|
- if transform == None:
|
|
|
|
|
|
|
+ if transform is None:
|
|
|
transform = TransformState.makePosHprScale(pos, hpr, scale)
|
|
transform = TransformState.makePosHprScale(pos, hpr, scale)
|
|
|
|
|
|
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
|
|
@@ -1331,7 +1340,7 @@ class Actor(DirectObject, NodePath):
|
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
partDef = partBundleDict.get(subpartDef.truePartName)
|
|
|
if partDef:
|
|
if partDef:
|
|
|
joint = partDef.partBundleNP.find("**/" + jointName)
|
|
joint = partDef.partBundleNP.find("**/" + jointName)
|
|
|
- if (joint.isEmpty()):
|
|
|
|
|
|
|
+ if joint.isEmpty():
|
|
|
Actor.notify.warning("%s not found!" % (jointName))
|
|
Actor.notify.warning("%s not found!" % (jointName))
|
|
|
else:
|
|
else:
|
|
|
return path.instanceTo(joint)
|
|
return path.instanceTo(joint)
|
|
@@ -1351,7 +1360,7 @@ class Actor(DirectObject, NodePath):
|
|
|
anotherPartDef = partBundleDict.get(anotherPartName)
|
|
anotherPartDef = partBundleDict.get(anotherPartName)
|
|
|
if anotherPartDef:
|
|
if anotherPartDef:
|
|
|
joint = anotherPartDef.partBundleNP.find("**/" + jointName)
|
|
joint = anotherPartDef.partBundleNP.find("**/" + jointName)
|
|
|
- if (joint.isEmpty()):
|
|
|
|
|
|
|
+ if joint.isEmpty():
|
|
|
Actor.notify.warning("%s not found!" % (jointName))
|
|
Actor.notify.warning("%s not found!" % (jointName))
|
|
|
else:
|
|
else:
|
|
|
partDef.partBundleNP.reparentTo(joint)
|
|
partDef.partBundleNP.reparentTo(joint)
|
|
@@ -1396,10 +1405,10 @@ class Actor(DirectObject, NodePath):
|
|
|
root under the given lod.
|
|
root under the given lod.
|
|
|
"""
|
|
"""
|
|
|
# check to see if we are working within an lod
|
|
# check to see if we are working within an lod
|
|
|
- if lodName != None:
|
|
|
|
|
|
|
+ if lodName is not None:
|
|
|
# find the named lod node
|
|
# find the named lod node
|
|
|
lodRoot = self.__LODNode.find(str(lodName))
|
|
lodRoot = self.__LODNode.find(str(lodName))
|
|
|
- if root == None:
|
|
|
|
|
|
|
+ if root is None:
|
|
|
# no need to look further
|
|
# no need to look further
|
|
|
root = lodRoot
|
|
root = lodRoot
|
|
|
else:
|
|
else:
|
|
@@ -1407,7 +1416,7 @@ class Actor(DirectObject, NodePath):
|
|
|
root = lodRoot.find("**/" + root)
|
|
root = lodRoot.find("**/" + root)
|
|
|
else:
|
|
else:
|
|
|
# start search from self if no root and no lod given
|
|
# start search from self if no root and no lod given
|
|
|
- if root == None:
|
|
|
|
|
|
|
+ if root is None:
|
|
|
root = self
|
|
root = self
|
|
|
|
|
|
|
|
frontParts = root.findAllMatches("**/" + frontPartName)
|
|
frontParts = root.findAllMatches("**/" + frontPartName)
|
|
@@ -1427,7 +1436,7 @@ class Actor(DirectObject, NodePath):
|
|
|
|
|
|
|
|
# Find the back part.
|
|
# Find the back part.
|
|
|
backPart = root.find("**/" + backPartName)
|
|
backPart = root.find("**/" + backPartName)
|
|
|
- if (backPart.isEmpty()):
|
|
|
|
|
|
|
+ if backPart.isEmpty():
|
|
|
Actor.notify.warning("no part named %s!" % (backPartName))
|
|
Actor.notify.warning("no part named %s!" % (backPartName))
|
|
|
return
|
|
return
|
|
|
|
|
|
|
@@ -1443,7 +1452,7 @@ class Actor(DirectObject, NodePath):
|
|
|
|
|
|
|
|
|
|
|
|
|
def fixBounds(self, partName = None):
|
|
def fixBounds(self, partName = None):
|
|
|
- if(partName == None):
|
|
|
|
|
|
|
+ if partName is None:
|
|
|
#iterate through everything
|
|
#iterate through everything
|
|
|
for lodData in self.__partBundleDict.values():
|
|
for lodData in self.__partBundleDict.values():
|
|
|
for partData in lodData.values():
|
|
for partData in lodData.values():
|
|
@@ -1474,7 +1483,7 @@ class Actor(DirectObject, NodePath):
|
|
|
in this actor
|
|
in this actor
|
|
|
"""
|
|
"""
|
|
|
# if no part name specified fix all parts
|
|
# if no part name specified fix all parts
|
|
|
- if (part==None):
|
|
|
|
|
|
|
+ if part is None:
|
|
|
part = self
|
|
part = self
|
|
|
|
|
|
|
|
# update all characters first
|
|
# update all characters first
|
|
@@ -1532,12 +1541,12 @@ class Actor(DirectObject, NodePath):
|
|
|
Play the given animation on the given part of the actor.
|
|
Play the given animation on the given part of the actor.
|
|
|
If no part is specified, try to play on all parts. NOTE:
|
|
If no part is specified, try to play on all parts. NOTE:
|
|
|
plays over ALL LODs"""
|
|
plays over ALL LODs"""
|
|
|
- if fromFrame == None:
|
|
|
|
|
|
|
+ if fromFrame is None:
|
|
|
for control in self.getAnimControls(animName, partName):
|
|
for control in self.getAnimControls(animName, partName):
|
|
|
control.play()
|
|
control.play()
|
|
|
else:
|
|
else:
|
|
|
for control in self.getAnimControls(animName, partName):
|
|
for control in self.getAnimControls(animName, partName):
|
|
|
- if toFrame == None:
|
|
|
|
|
|
|
+ if toFrame is None:
|
|
|
control.play(fromFrame, control.getNumFrames() - 1)
|
|
control.play(fromFrame, control.getNumFrames() - 1)
|
|
|
else:
|
|
else:
|
|
|
control.play(fromFrame, toFrame)
|
|
control.play(fromFrame, toFrame)
|
|
@@ -1551,12 +1560,12 @@ class Actor(DirectObject, NodePath):
|
|
|
all LOD's
|
|
all LOD's
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
- if fromFrame == None:
|
|
|
|
|
|
|
+ if fromFrame is None:
|
|
|
for control in self.getAnimControls(animName, partName):
|
|
for control in self.getAnimControls(animName, partName):
|
|
|
control.loop(restart)
|
|
control.loop(restart)
|
|
|
else:
|
|
else:
|
|
|
for control in self.getAnimControls(animName, partName):
|
|
for control in self.getAnimControls(animName, partName):
|
|
|
- if toFrame == None:
|
|
|
|
|
|
|
+ if toFrame is None:
|
|
|
control.loop(restart, fromFrame, control.getNumFrames() - 1)
|
|
control.loop(restart, fromFrame, control.getNumFrames() - 1)
|
|
|
else:
|
|
else:
|
|
|
control.loop(restart, fromFrame, toFrame)
|
|
control.loop(restart, fromFrame, toFrame)
|
|
@@ -1568,11 +1577,11 @@ class Actor(DirectObject, NodePath):
|
|
|
restarting at zero frame if requested. If no part name
|
|
restarting at zero frame if requested. If no part name
|
|
|
is given then try to loop on all parts. NOTE: loops on
|
|
is given then try to loop on all parts. NOTE: loops on
|
|
|
all LOD's"""
|
|
all LOD's"""
|
|
|
- if fromFrame == None:
|
|
|
|
|
|
|
+ if fromFrame is None:
|
|
|
fromFrame = 0
|
|
fromFrame = 0
|
|
|
|
|
|
|
|
for control in self.getAnimControls(animName, partName):
|
|
for control in self.getAnimControls(animName, partName):
|
|
|
- if toFrame == None:
|
|
|
|
|
|
|
+ if toFrame is None:
|
|
|
control.pingpong(restart, fromFrame, control.getNumFrames() - 1)
|
|
control.pingpong(restart, fromFrame, control.getNumFrames() - 1)
|
|
|
else:
|
|
else:
|
|
|
control.pingpong(restart, fromFrame, toFrame)
|
|
control.pingpong(restart, fromFrame, toFrame)
|
|
@@ -1624,11 +1633,11 @@ class Actor(DirectObject, NodePath):
|
|
|
Config.prc variable.
|
|
Config.prc variable.
|
|
|
"""
|
|
"""
|
|
|
for bundle in self.getPartBundles(partName = partName):
|
|
for bundle in self.getPartBundles(partName = partName):
|
|
|
- if blendType != None:
|
|
|
|
|
|
|
+ if blendType is not None:
|
|
|
bundle.setBlendType(blendType)
|
|
bundle.setBlendType(blendType)
|
|
|
- if animBlend != None:
|
|
|
|
|
|
|
+ if animBlend is not None:
|
|
|
bundle.setAnimBlendFlag(animBlend)
|
|
bundle.setAnimBlendFlag(animBlend)
|
|
|
- if frameBlend != None:
|
|
|
|
|
|
|
+ if frameBlend is not None:
|
|
|
bundle.setFrameBlendFlag(frameBlend)
|
|
bundle.setFrameBlendFlag(frameBlend)
|
|
|
|
|
|
|
|
def enableBlend(self, blendType = PartBundle.BTNormalizedLinear, partName = None):
|
|
def enableBlend(self, blendType = PartBundle.BTNormalizedLinear, partName = None):
|
|
@@ -1707,15 +1716,15 @@ class Actor(DirectObject, NodePath):
|
|
|
|
|
|
|
|
partDict = self.__animControlDict.get(lodName)
|
|
partDict = self.__animControlDict.get(lodName)
|
|
|
# if this assertion fails, named lod was not present
|
|
# if this assertion fails, named lod was not present
|
|
|
- assert partDict != None
|
|
|
|
|
|
|
+ assert partDict is not None
|
|
|
|
|
|
|
|
animDict = partDict.get(partName)
|
|
animDict = partDict.get(partName)
|
|
|
- if animDict == None:
|
|
|
|
|
|
|
+ if animDict is None:
|
|
|
# part was not present
|
|
# part was not present
|
|
|
Actor.notify.warning("couldn't find part: %s" % (partName))
|
|
Actor.notify.warning("couldn't find part: %s" % (partName))
|
|
|
else:
|
|
else:
|
|
|
anim = animDict.get(animName)
|
|
anim = animDict.get(animName)
|
|
|
- if anim == None:
|
|
|
|
|
|
|
+ if anim is None:
|
|
|
# anim was not present
|
|
# anim was not present
|
|
|
assert Actor.notify.debug("couldn't find anim: %s" % (animName))
|
|
assert Actor.notify.debug("couldn't find anim: %s" % (animName))
|
|
|
pass
|
|
pass
|
|
@@ -1751,7 +1760,7 @@ class Actor(DirectObject, NodePath):
|
|
|
If lodName is None or omitted, all LOD's are returned.
|
|
If lodName is None or omitted, all LOD's are returned.
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
- if partName == None and self.__subpartsComplete:
|
|
|
|
|
|
|
+ if partName is None and self.__subpartsComplete:
|
|
|
# If we have the __subpartsComplete flag, and no partName
|
|
# If we have the __subpartsComplete flag, and no partName
|
|
|
# is specified, it really means to play the animation on
|
|
# is specified, it really means to play the animation on
|
|
|
# all subparts, not on the overall Actor.
|
|
# all subparts, not on the overall Actor.
|
|
@@ -1760,12 +1769,12 @@ class Actor(DirectObject, NodePath):
|
|
|
controls = []
|
|
controls = []
|
|
|
# build list of lodNames and corresponding animControlDicts
|
|
# build list of lodNames and corresponding animControlDicts
|
|
|
# requested.
|
|
# requested.
|
|
|
- if lodName == None or self.mergeLODBundles:
|
|
|
|
|
|
|
+ if lodName is None or self.mergeLODBundles:
|
|
|
# Get all LOD's
|
|
# Get all LOD's
|
|
|
animControlDictItems = self.__animControlDict.items()
|
|
animControlDictItems = self.__animControlDict.items()
|
|
|
else:
|
|
else:
|
|
|
partDict = self.__animControlDict.get(lodName)
|
|
partDict = self.__animControlDict.get(lodName)
|
|
|
- if partDict == None:
|
|
|
|
|
|
|
+ if partDict is None:
|
|
|
Actor.notify.warning("couldn't find lod: %s" % (lodName))
|
|
Actor.notify.warning("couldn't find lod: %s" % (lodName))
|
|
|
animControlDictItems = []
|
|
animControlDictItems = []
|
|
|
else:
|
|
else:
|
|
@@ -1774,7 +1783,7 @@ class Actor(DirectObject, NodePath):
|
|
|
for lodName, partDict in animControlDictItems:
|
|
for lodName, partDict in animControlDictItems:
|
|
|
# Now, build the list of partNames and the corresponding
|
|
# Now, build the list of partNames and the corresponding
|
|
|
# animDicts.
|
|
# animDicts.
|
|
|
- if partName == None:
|
|
|
|
|
|
|
+ if partName is None:
|
|
|
# Get all main parts, but not sub-parts.
|
|
# Get all main parts, but not sub-parts.
|
|
|
animDictItems = []
|
|
animDictItems = []
|
|
|
for thisPart, animDict in partDict.items():
|
|
for thisPart, animDict in partDict.items():
|
|
@@ -1792,14 +1801,14 @@ class Actor(DirectObject, NodePath):
|
|
|
|
|
|
|
|
for pName in partNameList:
|
|
for pName in partNameList:
|
|
|
animDict = partDict.get(pName)
|
|
animDict = partDict.get(pName)
|
|
|
- if animDict == None:
|
|
|
|
|
|
|
+ if animDict is None:
|
|
|
# Maybe it's a subpart that hasn't been bound yet.
|
|
# Maybe it's a subpart that hasn't been bound yet.
|
|
|
subpartDef = self.__subpartDict.get(pName)
|
|
subpartDef = self.__subpartDict.get(pName)
|
|
|
if subpartDef:
|
|
if subpartDef:
|
|
|
animDict = {}
|
|
animDict = {}
|
|
|
partDict[pName] = animDict
|
|
partDict[pName] = animDict
|
|
|
|
|
|
|
|
- if animDict == None:
|
|
|
|
|
|
|
+ if animDict is None:
|
|
|
# part was not present
|
|
# part was not present
|
|
|
Actor.notify.warning("couldn't find part: %s" % (pName))
|
|
Actor.notify.warning("couldn't find part: %s" % (pName))
|
|
|
else:
|
|
else:
|
|
@@ -1825,7 +1834,7 @@ class Actor(DirectObject, NodePath):
|
|
|
names = animDict.keys()
|
|
names = animDict.keys()
|
|
|
for animName in names:
|
|
for animName in names:
|
|
|
anim = animDict.get(animName)
|
|
anim = animDict.get(animName)
|
|
|
- if anim == None and partName != None:
|
|
|
|
|
|
|
+ if anim is None and partName is not None:
|
|
|
for pName in partNameList:
|
|
for pName in partNameList:
|
|
|
# Maybe it's a subpart that hasn't been bound yet.
|
|
# Maybe it's a subpart that hasn't been bound yet.
|
|
|
subpartDef = self.__subpartDict.get(pName)
|
|
subpartDef = self.__subpartDict.get(pName)
|
|
@@ -1836,14 +1845,14 @@ class Actor(DirectObject, NodePath):
|
|
|
anim = anim.makeCopy()
|
|
anim = anim.makeCopy()
|
|
|
animDict[animName] = anim
|
|
animDict[animName] = anim
|
|
|
|
|
|
|
|
- if anim == None:
|
|
|
|
|
|
|
+ if anim is None:
|
|
|
# anim was not present
|
|
# anim was not present
|
|
|
assert Actor.notify.debug("couldn't find anim: %s" % (animName))
|
|
assert Actor.notify.debug("couldn't find anim: %s" % (animName))
|
|
|
pass
|
|
pass
|
|
|
else:
|
|
else:
|
|
|
# bind the animation first if we need to
|
|
# bind the animation first if we need to
|
|
|
animControl = anim.animControl
|
|
animControl = anim.animControl
|
|
|
- if animControl == None:
|
|
|
|
|
|
|
+ if animControl is None:
|
|
|
animControl = self.__bindAnimToPart(
|
|
animControl = self.__bindAnimToPart(
|
|
|
animName, thisPart, lodName,
|
|
animName, thisPart, lodName,
|
|
|
allowAsyncBind = allowAsyncBind)
|
|
allowAsyncBind = allowAsyncBind)
|
|
@@ -1870,7 +1879,7 @@ class Actor(DirectObject, NodePath):
|
|
|
if isinstance(modelPath, NodePath):
|
|
if isinstance(modelPath, NodePath):
|
|
|
# If we got a NodePath instead of a string, use *that* as
|
|
# If we got a NodePath instead of a string, use *that* as
|
|
|
# the model directly.
|
|
# the model directly.
|
|
|
- if (copy):
|
|
|
|
|
|
|
+ if copy:
|
|
|
model = modelPath.copyTo(NodePath())
|
|
model = modelPath.copyTo(NodePath())
|
|
|
else:
|
|
else:
|
|
|
model = modelPath
|
|
model = modelPath
|
|
@@ -1888,6 +1897,9 @@ class Actor(DirectObject, NodePath):
|
|
|
else:
|
|
else:
|
|
|
loaderOptions.setFlags(loaderOptions.getFlags() | LoaderOptions.LFReportErrors)
|
|
loaderOptions.setFlags(loaderOptions.getFlags() | LoaderOptions.LFReportErrors)
|
|
|
|
|
|
|
|
|
|
+ # Ensure that custom Python loader hooks are initialized.
|
|
|
|
|
+ Loader._loadPythonFileTypes()
|
|
|
|
|
+
|
|
|
# Pass loaderOptions to specify that we want to
|
|
# Pass loaderOptions to specify that we want to
|
|
|
# get the skeleton model. This only matters to model
|
|
# get the skeleton model. This only matters to model
|
|
|
# files (like .mb) for which we can choose to extract
|
|
# files (like .mb) for which we can choose to extract
|
|
@@ -1896,15 +1908,15 @@ class Actor(DirectObject, NodePath):
|
|
|
if model is not None:
|
|
if model is not None:
|
|
|
model = NodePath(model)
|
|
model = NodePath(model)
|
|
|
|
|
|
|
|
- if (model == None):
|
|
|
|
|
|
|
+ if model is None:
|
|
|
raise IOError("Could not load Actor model %s" % (modelPath))
|
|
raise IOError("Could not load Actor model %s" % (modelPath))
|
|
|
|
|
|
|
|
- if (model.node().isOfType(Character.getClassType())):
|
|
|
|
|
|
|
+ if model.node().isOfType(Character.getClassType()):
|
|
|
bundleNP = model
|
|
bundleNP = model
|
|
|
else:
|
|
else:
|
|
|
bundleNP = model.find("**/+Character")
|
|
bundleNP = model.find("**/+Character")
|
|
|
|
|
|
|
|
- if (bundleNP.isEmpty()):
|
|
|
|
|
|
|
+ if bundleNP.isEmpty():
|
|
|
Actor.notify.warning("%s is not a character!" % (modelPath))
|
|
Actor.notify.warning("%s is not a character!" % (modelPath))
|
|
|
model.reparentTo(self.__geomNode)
|
|
model.reparentTo(self.__geomNode)
|
|
|
else:
|
|
else:
|
|
@@ -1921,7 +1933,7 @@ class Actor(DirectObject, NodePath):
|
|
|
# Now extract out the Character and integrate it with
|
|
# Now extract out the Character and integrate it with
|
|
|
# the Actor.
|
|
# the Actor.
|
|
|
|
|
|
|
|
- if (lodName!="lodRoot"):
|
|
|
|
|
|
|
+ if lodName != "lodRoot":
|
|
|
# parent to appropriate node under LOD switch
|
|
# parent to appropriate node under LOD switch
|
|
|
bundleNP.reparentTo(self.__LODNode.find(str(lodName)))
|
|
bundleNP.reparentTo(self.__LODNode.find(str(lodName)))
|
|
|
else:
|
|
else:
|
|
@@ -1947,6 +1959,7 @@ class Actor(DirectObject, NodePath):
|
|
|
animName = acc.getAnimName(i)
|
|
animName = acc.getAnimName(i)
|
|
|
|
|
|
|
|
animDef = Actor.AnimDef()
|
|
animDef = Actor.AnimDef()
|
|
|
|
|
+ animDef.animBundle = animControl.getAnim()
|
|
|
animDef.animControl = animControl
|
|
animDef.animControl = animControl
|
|
|
self.__animControlDict[lodName][partName][animName] = animDef
|
|
self.__animControlDict[lodName][partName][animName] = animDef
|
|
|
|
|
|
|
@@ -1962,7 +1975,7 @@ class Actor(DirectObject, NodePath):
|
|
|
self.gotName = 1
|
|
self.gotName = 1
|
|
|
|
|
|
|
|
bundleDict = self.__partBundleDict.get(lodName, None)
|
|
bundleDict = self.__partBundleDict.get(lodName, None)
|
|
|
- if bundleDict == None:
|
|
|
|
|
|
|
+ if bundleDict is None:
|
|
|
# make a dictionary to store these parts in
|
|
# make a dictionary to store these parts in
|
|
|
bundleDict = {}
|
|
bundleDict = {}
|
|
|
self.__partBundleDict[lodName] = bundleDict
|
|
self.__partBundleDict[lodName] = bundleDict
|
|
@@ -2251,7 +2264,7 @@ class Actor(DirectObject, NodePath):
|
|
|
for lodName in lodNames:
|
|
for lodName in lodNames:
|
|
|
for partName in partNames:
|
|
for partName in partNames:
|
|
|
for animDef in self.__animControlDict[lodName][partName].values():
|
|
for animDef in self.__animControlDict[lodName][partName].values():
|
|
|
- if animDef.animControl != None:
|
|
|
|
|
|
|
+ if animDef.animControl is not None:
|
|
|
# Try to clear any control effects before we let
|
|
# Try to clear any control effects before we let
|
|
|
# our handle on them go. This is especially
|
|
# our handle on them go. This is especially
|
|
|
# important if the anim control was blending
|
|
# important if the anim control was blending
|
|
@@ -2263,12 +2276,12 @@ class Actor(DirectObject, NodePath):
|
|
|
for partName in partNames:
|
|
for partName in partNames:
|
|
|
for anim in anims:
|
|
for anim in anims:
|
|
|
animDef = self.__animControlDict[lodName][partName].get(anim)
|
|
animDef = self.__animControlDict[lodName][partName].get(anim)
|
|
|
- if animDef and animDef.animControl != None:
|
|
|
|
|
|
|
+ if animDef and animDef.animControl is not None:
|
|
|
# Try to clear any control effects before we let
|
|
# Try to clear any control effects before we let
|
|
|
# our handle on them go. This is especially
|
|
# our handle on them go. This is especially
|
|
|
# important if the anim control was blending
|
|
# important if the anim control was blending
|
|
|
# animations.
|
|
# animations.
|
|
|
- animDef.animControl.getPart().clearControlEffects()
|
|
|
|
|
|
|
+ animDef.animControl.getPart().setControlEffect(animDef.animControl, 0.0)
|
|
|
animDef.animControl = None
|
|
animDef.animControl = None
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2326,19 +2339,19 @@ class Actor(DirectObject, NodePath):
|
|
|
|
|
|
|
|
partDict = self.__animControlDict[lodName]
|
|
partDict = self.__animControlDict[lodName]
|
|
|
animDict = partDict.get(partName)
|
|
animDict = partDict.get(partName)
|
|
|
- if animDict == None:
|
|
|
|
|
|
|
+ if animDict is None:
|
|
|
# It must be a subpart that hasn't been bound yet.
|
|
# It must be a subpart that hasn't been bound yet.
|
|
|
animDict = {}
|
|
animDict = {}
|
|
|
partDict[partName] = animDict
|
|
partDict[partName] = animDict
|
|
|
|
|
|
|
|
anim = animDict.get(animName)
|
|
anim = animDict.get(animName)
|
|
|
- if anim == None:
|
|
|
|
|
|
|
+ if anim is None:
|
|
|
# It must be a subpart that hasn't been bound yet.
|
|
# It must be a subpart that hasn't been bound yet.
|
|
|
anim = partDict[subpartDef.truePartName].get(animName)
|
|
anim = partDict[subpartDef.truePartName].get(animName)
|
|
|
anim = anim.makeCopy()
|
|
anim = anim.makeCopy()
|
|
|
animDict[animName] = anim
|
|
animDict[animName] = anim
|
|
|
|
|
|
|
|
- if anim == None:
|
|
|
|
|
|
|
+ if anim is None:
|
|
|
Actor.notify.error("actor has no animation %s", animName)
|
|
Actor.notify.error("actor has no animation %s", animName)
|
|
|
|
|
|
|
|
# only bind if not already bound!
|
|
# only bind if not already bound!
|
|
@@ -2393,7 +2406,7 @@ class Actor(DirectObject, NodePath):
|
|
|
|
|
|
|
|
# find the part in our tree
|
|
# find the part in our tree
|
|
|
bundleNP = partLod.find("**/%s%s"%(Actor.partPrefix,partName))
|
|
bundleNP = partLod.find("**/%s%s"%(Actor.partPrefix,partName))
|
|
|
- if (bundleNP != None):
|
|
|
|
|
|
|
+ if bundleNP is not None:
|
|
|
# store the part bundle
|
|
# store the part bundle
|
|
|
self.__prepareBundle(bundleNP, partDef.partModel,
|
|
self.__prepareBundle(bundleNP, partDef.partModel,
|
|
|
partName, lodName)
|
|
partName, lodName)
|
|
@@ -2438,15 +2451,15 @@ class Actor(DirectObject, NodePath):
|
|
|
return ActorInterval.ActorInterval(self, *args, **kw)
|
|
return ActorInterval.ActorInterval(self, *args, **kw)
|
|
|
|
|
|
|
|
def getAnimBlends(self, animName=None, partName=None, lodName=None):
|
|
def getAnimBlends(self, animName=None, partName=None, lodName=None):
|
|
|
- """ Returns a list of the form:
|
|
|
|
|
|
|
+ """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), ...]),
|
|
|
|
|
- ...]),
|
|
|
|
|
- ... ]
|
|
|
|
|
|
|
+ [ (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
|
|
This list reports the non-zero control effects for each
|
|
|
partName within a particular animation and LOD. """
|
|
partName within a particular animation and LOD. """
|
|
@@ -2465,7 +2478,7 @@ class Actor(DirectObject, NodePath):
|
|
|
else:
|
|
else:
|
|
|
lodNames = [lodName]
|
|
lodNames = [lodName]
|
|
|
|
|
|
|
|
- if partName == None and self.__subpartsComplete:
|
|
|
|
|
|
|
+ if partName is None and self.__subpartsComplete:
|
|
|
partNames = self.__subpartDict.keys()
|
|
partNames = self.__subpartDict.keys()
|
|
|
else:
|
|
else:
|
|
|
partNames = [partName]
|
|
partNames = [partName]
|