Added feature to support model based anim list

This commit is contained in:
Gyedo Jeon 2010-04-24 00:46:27 +00:00
parent e58d747f6a
commit 3849b1221f
3 changed files with 33 additions and 12 deletions

View File

@ -153,7 +153,7 @@ class ObjectMgrBase:
if i == 0:
anim = animFile
newobj.loop(animName)
if newobj is None:
return None
@ -384,11 +384,17 @@ class ObjectMgrBase:
objRGBA = obj[OG.OBJ_RGBA]
# load new model
newobjModel = loader.loadModel(model, okMissing=True)
if newobjModel is None:
print "Can't load model %s"%model
return
newobj = PythonNodePath(newobjModel)
if obj[OG.OBJ_DEF].actor:
try:
newobj = Actor(model)
except:
newobj = Actor(Filename.fromOsSpecific(model).getFullpath())
else:
newobjModel = loader.loadModel(model, okMissing=True)
if newobjModel is None:
print "Can't load model %s"%model
return
newobj = PythonNodePath(newobjModel)
newobj.setTag('OBJRoot','1')
# reparent children
@ -414,10 +420,14 @@ class ObjectMgrBase:
obj[OG.OBJ_MODEL] = model
self.npIndex[NodePath(newobj)] = obj[OG.OBJ_UID]
if fSelectObject:
base.direct.select(newobj, fUndo=0)
self.editor.fNeedToSave = True
# update anim if necessary
animList = obj[OG.OBJ_DEF].animDict.get(model)
if animList:
self.updateObjectAnim(animList[0], obj, fSelectObject=fSelectObject)
else:
if fSelectObject:
base.direct.select(newobj, fUndo=0)
def updateObjectAnim(self, anim, obj, fSelectObject=True):
""" replace object's anim """

View File

@ -8,7 +8,7 @@ class ObjectGen:
class ObjectBase(ObjectGen):
""" Base class for obj definitions """
def __init__(self, name='', createFunction = None, model = None, models= [], anims = [], animNames = [], properties={},
def __init__(self, name='', createFunction = None, model = None, models= [], anims = [], animNames = [], animDict = {}, properties={},
movable = True, actor = False, named=False, orderedProperties=[], propertiesMask={}):
ObjectGen.__init__(self, name)
self.createFunction = createFunction
@ -16,6 +16,7 @@ class ObjectBase(ObjectGen):
self.models = models[:]
self.anims = anims[:]
self.animNames = animNames[:]
self.animDict = copy.deepcopy(animDict)
self.properties = copy.deepcopy(properties)
self.movable = movable
self.actor = actor

View File

@ -323,8 +323,18 @@ class ObjectPropertyUI(ScrolledPanel):
self.editor.objectMgr.onLeaveObjectPropUI,
lambda p0=None, p1=obj: self.editor.objectMgr.updateObjectModelFromUI(p0, p1))
if len(objDef.anims) > 0:
propUI = ObjectPropUICombo(self.lookPane, 'anim', obj[OG.OBJ_ANIM], objDef.anims)
animList = objDef.animDict.get(obj[OG.OBJ_MODEL])
if len(objDef.anims) > 0 or animList:
if animList is None:
animist = objDef.anims
if '' not in animList:
animList.append('')
defaultAnim = obj[OG.OBJ_ANIM]
if defaultAnim is None:
defaultAnim = ''
propUI = ObjectPropUICombo(self.lookPane, 'anim', defaultAnim, animList)
sizer.Add(propUI)
propUI.bindFunc(self.editor.objectMgr.onEnterObjectPropUI,