mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
better multipart interfaces
This commit is contained in:
parent
cffaa54239
commit
6a319cc778
@ -648,17 +648,38 @@ class Actor(DirectObject, NodePath):
|
|||||||
def setCenter(self, center):
|
def setCenter(self, center):
|
||||||
if center != None:
|
if center != None:
|
||||||
self.__LODNode.node().setCenter(center)
|
self.__LODNode.node().setCenter(center)
|
||||||
|
|
||||||
def update(self, lod=0):
|
def update(self, lod=0, animName=None, partName='modelRoot',
|
||||||
lodnames = self.getLODNames()
|
lodName=None, force=False):
|
||||||
if (lod < len(lodnames)):
|
""" Updates all of the Actor's joints in the indicated LOD.
|
||||||
partDefs = self.__partBundleDict[lodnames[lod]].values()
|
The LOD may be specified by name, or by number, where 0 is the
|
||||||
for partDef in partDefs:
|
highest level of detail, 1 is the next highest, and so on.
|
||||||
# print "updating: %s" % (partBundle.node())
|
|
||||||
partDef.partBundle.update()
|
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. """
|
||||||
|
|
||||||
|
if lodName == None:
|
||||||
|
lodNames = self.getLODNames()
|
||||||
|
else:
|
||||||
|
lodNames = [lodName]
|
||||||
|
|
||||||
|
anyChanged = False
|
||||||
|
if (lod < len(lodNames)):
|
||||||
|
partBundle = self.getPartBundle(partName, lodNames[lod])
|
||||||
|
if force:
|
||||||
|
if partBundle.forceUpdate():
|
||||||
|
anyChanged = True
|
||||||
|
else:
|
||||||
|
if partBundle.update():
|
||||||
|
anyChanged = True
|
||||||
else:
|
else:
|
||||||
self.notify.warning('update() - no lod: %d' % lod)
|
self.notify.warning('update() - no lod: %d' % lod)
|
||||||
|
|
||||||
|
return anyChanged
|
||||||
|
|
||||||
def getFrameRate(self, animName=None, partName=None):
|
def getFrameRate(self, animName=None, partName=None):
|
||||||
"""getFrameRate(self, string, string=None)
|
"""getFrameRate(self, string, string=None)
|
||||||
Return actual frame rate of given anim name and given part.
|
Return actual frame rate of given anim name and given part.
|
||||||
@ -1298,9 +1319,9 @@ class Actor(DirectObject, NodePath):
|
|||||||
"""
|
"""
|
||||||
bundles = []
|
bundles = []
|
||||||
|
|
||||||
for lodName, bundleDict in self.__partBundleDict.items():
|
for lodName, partBundleDict in self.__partBundleDict.items():
|
||||||
if partName == None:
|
if partName == None:
|
||||||
for partDef in bundleDict.values():
|
for partDef in partBundleDict.values():
|
||||||
bundles.append(partDef.partBundle)
|
bundles.append(partDef.partBundle)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -1891,33 +1912,64 @@ class Actor(DirectObject, NodePath):
|
|||||||
from direct.interval import ActorInterval
|
from direct.interval import ActorInterval
|
||||||
return ActorInterval.ActorInterval(self, *args, **kw)
|
return ActorInterval.ActorInterval(self, *args, **kw)
|
||||||
|
|
||||||
def printAnimBlends(self, animName=None, partName=None, lodName=None):
|
def getAnimBlends(self, animName=None, partName=None, lodName=None):
|
||||||
out = ''
|
""" Returns a list of the form:
|
||||||
first = True
|
|
||||||
|
[ (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. """
|
||||||
|
|
||||||
|
result = []
|
||||||
|
|
||||||
if animName is None:
|
if animName is None:
|
||||||
animNames = self.getAnimNames()
|
animNames = self.getAnimNames()
|
||||||
else:
|
else:
|
||||||
animNames = [animName]
|
animNames = [animName]
|
||||||
for animName in animNames:
|
|
||||||
if animName is 'nothing':
|
if lodName is None:
|
||||||
continue
|
lodNames = self.getLODNames()
|
||||||
thisAnim = '%s: ' % animName
|
else:
|
||||||
totalEffect = 0.
|
lodNames = [lodName]
|
||||||
controls = self.getAnimControls(animName, partName, lodName)
|
|
||||||
for control in controls:
|
if partName == None and self.__subpartsComplete:
|
||||||
part = control.getPart()
|
partNames = self.__subpartDict.keys()
|
||||||
name = part.getName()
|
else:
|
||||||
effect = part.getControlEffect(control)
|
partNames = [partName]
|
||||||
if effect > 0.:
|
|
||||||
totalEffect += effect
|
for lodName in lodNames:
|
||||||
thisAnim += ('%s:%.3f, ' % (name, effect))
|
animList = []
|
||||||
# don't print anything if this animation is not being played
|
for animName in animNames:
|
||||||
if totalEffect > 0.:
|
blendList = []
|
||||||
if not first:
|
for partName in partNames:
|
||||||
out += '\n'
|
control = self.getAnimControl(animName, partName, lodName)
|
||||||
first = False
|
if control:
|
||||||
out += thisAnim
|
part = control.getPart()
|
||||||
print out
|
effect = part.getControlEffect(control)
|
||||||
|
if effect > 0.:
|
||||||
|
blendList.append((partName, effect))
|
||||||
|
if blendList:
|
||||||
|
animList.append((animName, blendList))
|
||||||
|
if animList:
|
||||||
|
result.append((lodName, animList))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
def printAnimBlends(self, animName=None, partName=None, lodName=None):
|
||||||
|
for lodName, animList in self.getAnimBlends(animName, partName, lodName):
|
||||||
|
print 'LOD %s:' % (lodName)
|
||||||
|
for animName, blendList in animList:
|
||||||
|
|
||||||
|
list = []
|
||||||
|
for partName, effect in blendList:
|
||||||
|
list.append('%s:%.3f' % (partName, effect))
|
||||||
|
print ' %s: %s' % (animName, ', '.join(list))
|
||||||
|
|
||||||
def osdAnimBlends(self, animName=None, partName=None, lodName=None):
|
def osdAnimBlends(self, animName=None, partName=None, lodName=None):
|
||||||
if not onScreenDebug.enabled:
|
if not onScreenDebug.enabled:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user