tweaks to actor

This commit is contained in:
Zachary Pavlov 2007-06-13 21:11:19 +00:00
parent 9bec17d962
commit 0109caeeed

View File

@ -446,6 +446,7 @@ class Actor(DirectObject, NodePath):
self.stop(None) self.stop(None)
self.__frozenJoints = {} self.__frozenJoints = {}
self.flush() self.flush()
if(self.__geomNode):
self.__geomNode.removeNode() self.__geomNode.removeNode()
self.__geomNode = None self.__geomNode = None
if not self.isEmpty(): if not self.isEmpty():
@ -474,6 +475,7 @@ class Actor(DirectObject, NodePath):
self.__LODNode = None self.__LODNode = None
# remove all its children # remove all its children
if(self.__geomNode):
self.__geomNode.removeChildren() self.__geomNode.removeChildren()
@ -1002,6 +1004,17 @@ class Actor(DirectObject, NodePath):
else: else:
Actor.notify.warning("no joint named %s!" % (jointName)) Actor.notify.warning("no joint named %s!" % (jointName))
def getJoints(self, jointName):
joints=[]
for lod in self.__partBundleDict.values():
for part in lod.values():
partBundle=part.partBundle
joint=partBundle.findChild(jointName)
if(joint):
joints.append(joint)
return joints
def getJointTransform(self,partName, jointName, lodName='lodRoot'): def getJointTransform(self,partName, jointName, lodName='lodRoot'):
partBundleDict=self.__partBundleDict.get(lodName) partBundleDict=self.__partBundleDict.get(lodName)
if not partBundleDict: if not partBundleDict:
@ -1076,20 +1089,9 @@ class Actor(DirectObject, NodePath):
#trueName = self.__subpartDict[partName].truePartName #trueName = self.__subpartDict[partName].truePartName
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName)) subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
trueName = subpartDef.truePartName trueName = subpartDef.truePartName
for bundleDict in self.__partBundleDict.values(): for bundleDict in self.__partBundleDict.values():
bundleDict[trueName].partBundle.findChild(jointName).freezeJoint(transform) bundleDict[trueName].partBundle.findChild(jointName).freezeJoint(transform)
# self.__frozenJoints[bundle.this][jointName] = transform
#This is an alternate method to control joints, which can be copied
#This function is optimal in a non control jointed actor
def freezeJointMat(self, partName, jointName, mat):
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
trueName = subpartDef.truePartName
for bundleDict in self.__partBundleDict.values():
bundleDict[trueName].partBundle.findChild(jointName).freezeJoint(Mat4(mat))
def instance(self, path, partName, jointName, lodName="lodRoot"): def instance(self, path, partName, jointName, lodName="lodRoot"):
"""instance(self, NodePath, string, string, key="lodRoot") """instance(self, NodePath, string, string, key="lodRoot")
@ -1301,6 +1303,7 @@ class Actor(DirectObject, NodePath):
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 == None:
for control in self.getAnimControls(animName, partName): for control in self.getAnimControls(animName, partName):
control.loop(restart) control.loop(restart)
@ -1455,6 +1458,7 @@ class Actor(DirectObject, NodePath):
a given anim and part. If none specified, try the first part and lod. a given anim and part. If none specified, try the first part and lod.
Return the animControl if present, or None otherwise Return the animControl if present, or None otherwise
""" """
if not partName: if not partName:
partName = 'modelRoot' partName = 'modelRoot'
@ -1962,7 +1966,7 @@ class Actor(DirectObject, NodePath):
# Before we apply any control joints, we have to make a # Before we apply any control joints, we have to make a
# copy of the bundle hierarchy, so we don't modify other # copy of the bundle hierarchy, so we don't modify other
# Actors that share the same bundle. # Actors that share the same bundle.
animBundle = animBundle.copyBundle()
# Are there any controls requested for joints in this bundle? # Are there any controls requested for joints in this bundle?
@ -1970,6 +1974,8 @@ class Actor(DirectObject, NodePath):
assert Actor.notify.debug('actor bundle %s, %s'% (bundle,bundle.this)) assert Actor.notify.debug('actor bundle %s, %s'% (bundle,bundle.this))
controlDict = self.__controlJoints.get(bundle.this, None) controlDict = self.__controlJoints.get(bundle.this, None)
animBundle = animBundle.copyBundle()
if controlDict: if controlDict:
for jointName, node in controlDict.items(): for jointName, node in controlDict.items():
if node: if node: