mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
Added feature to replace objects
This commit is contained in:
parent
eee5764b82
commit
218138274b
@ -204,6 +204,15 @@ class ObjectMgrBase:
|
||||
else:
|
||||
return self.objects[uid]
|
||||
|
||||
def findObjectsByTypeName(self, typeName):
|
||||
results = []
|
||||
for uid in self.objects.keys():
|
||||
obj = self.objects[uid]
|
||||
if obj[OG.OBJ_DEF].name == typeName:
|
||||
results.append(obj)
|
||||
|
||||
return results
|
||||
|
||||
def deselectAll(self):
|
||||
self.currNodePath = None
|
||||
taskMgr.remove('_le_updateObjectUITask')
|
||||
@ -228,8 +237,6 @@ class ObjectMgrBase:
|
||||
if base.direct.widget.fActive:
|
||||
base.direct.widget.toggleWidget()
|
||||
|
||||
|
||||
|
||||
def updateObjectPropertyUI(self, obj):
|
||||
objDef = obj[OG.OBJ_DEF]
|
||||
objProp = obj[OG.OBJ_PROP]
|
||||
@ -703,3 +710,17 @@ class ObjectMgrBase:
|
||||
|
||||
self.currLiveNP = obj[OG.OBJ_NP]
|
||||
self.currLiveNP.setColorScale(0, 1, 0, 1)
|
||||
|
||||
def replaceObjectWithTypeName(self, obj, typeName):
|
||||
uid = obj[OG.OBJ_UID]
|
||||
objNP = obj[OG.OBJ_NP]
|
||||
mat = objNP.getMat()
|
||||
parentObj = self.findObjectByNodePath(objNP.getParent())
|
||||
if parentObj:
|
||||
parentNP = parentObj[OG.OBJ_NP]
|
||||
else:
|
||||
parentNP = None
|
||||
self.removeObjectById(uid)
|
||||
self.editor.ui.sceneGraphUI.delete(uid)
|
||||
newobj = self.addNewObject(typeName, uid, parent=parentNP, fSelectObject=False)
|
||||
newobj.setMat(mat)
|
||||
|
@ -66,3 +66,6 @@ class ObjectPaletteUI(wx.Panel):
|
||||
index1 = self.palette.dataKeys.index(data1)
|
||||
index2 = self.palette.dataKeys.index(data2)
|
||||
return cmp(index1, index2)
|
||||
|
||||
def getSelected(self):
|
||||
return self.tree.GetItemPyData(self.tree.GetSelection())
|
||||
|
Loading…
x
Reference in New Issue
Block a user