mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Added RGBA attribute to object data structure
This commit is contained in:
parent
ce084c9a02
commit
b60fa8ff04
@ -9,6 +9,7 @@ OBJ_DEF = 2
|
||||
OBJ_MODEL = 3
|
||||
OBJ_ANIM = 4
|
||||
OBJ_PROP = 5
|
||||
OBJ_RGBA = 6
|
||||
|
||||
# supported UI types
|
||||
PROP_UI_ENTRY = '_PropUIEntry'
|
||||
|
@ -130,7 +130,7 @@ class ObjectMgr:
|
||||
properties[key] = objDef.properties[key][OG.PROP_DEFAULT]
|
||||
|
||||
# insert obj data to main repository
|
||||
self.objects[uid] = [uid, newobj, objDef, model, anim, properties]
|
||||
self.objects[uid] = [uid, newobj, objDef, model, anim, properties, (1,1,1,1)]
|
||||
self.npIndex[NodePath(newobj)] = uid
|
||||
|
||||
if self.editor:
|
||||
@ -150,7 +150,7 @@ class ObjectMgr:
|
||||
return self.objects.get(uid)
|
||||
|
||||
def findObjectByNodePath(self, nodePath):
|
||||
uid = self.npIndex.get(nodePath)
|
||||
uid = self.npIndex.get(NodePath(nodePath))
|
||||
if uid is None:
|
||||
return None
|
||||
else:
|
||||
@ -265,12 +265,19 @@ class ObjectMgr:
|
||||
np.setSy(float(self.editor.ui.objectPropertyUI.propSY.getValue()))
|
||||
np.setSz(float(self.editor.ui.objectPropertyUI.propSZ.getValue()))
|
||||
|
||||
def updateObjectColor(self, r, g, b, a):
|
||||
if self.currNodePath is None:
|
||||
return
|
||||
def updateObjectColor(self, r, g, b, a, np=None):
|
||||
if np is None:
|
||||
np = self.currNodePath
|
||||
|
||||
np = self.currNodePath
|
||||
np.setColorScale(r, g, b, a)
|
||||
obj = self.findObjectByNodePath(np)
|
||||
if not obj:
|
||||
return
|
||||
obj[OG.OBJ_RGBA] = (r,g,b,a)
|
||||
for child in np.getChildren():
|
||||
if not child.hasTag('OBJRoot') and\
|
||||
child.getName() != 'bboxines':
|
||||
child.setTransparency(1)
|
||||
child.setColorScale(r, g, b, a)
|
||||
|
||||
def updateObjectModel(self, model, obj, fSelectObject=True):
|
||||
""" replace object's model """
|
||||
@ -463,6 +470,7 @@ class ObjectMgr:
|
||||
objDef = obj[OG.OBJ_DEF]
|
||||
objModel = obj[OG.OBJ_MODEL]
|
||||
objProp = obj[OG.OBJ_PROP]
|
||||
objRGBA = obj[OG.OBJ_RGBA]
|
||||
|
||||
if parentId:
|
||||
parentStr = "objects['%s']"%parentId
|
||||
@ -477,8 +485,7 @@ class ObjectMgr:
|
||||
self.saveData.append(" objects['%s'].setPos(%s)"%(uid, np.getPos()))
|
||||
self.saveData.append(" objects['%s'].setHpr(%s)"%(uid, np.getHpr()))
|
||||
self.saveData.append(" objects['%s'].setScale(%s)"%(uid, np.getScale()))
|
||||
self.saveData.append(" objects['%s'].setTransparency(1)"%uid)
|
||||
self.saveData.append(" objects['%s'].setColorScale(%s)"%(uid, np.getColorScale()))
|
||||
self.saveData.append(" objectMgr.updateObjectColor(%f, %f, %f, %f, objects['%s'])"%(objRGBA[0], objRGBA[1], objRGBA[2], objRGBA[3], uid))
|
||||
self.saveData.append(" objectMgr.updateObjectProperties(objects['%s'], %s)"%(uid,objProp))
|
||||
|
||||
self.traverse(child, uid)
|
||||
|
@ -243,7 +243,8 @@ class SceneGraphUI(wx.Panel):
|
||||
itemId = self.tree.GetItemPyData(event.GetItem())
|
||||
if itemId:
|
||||
obj = self.editor.objectMgr.findObjectById(itemId);
|
||||
base.direct.select(obj[OG.OBJ_NP])
|
||||
if obj:
|
||||
base.direct.select(obj[OG.OBJ_NP])
|
||||
|
||||
def onBeginDrag(self, event):
|
||||
item = event.GetItem()
|
||||
|
@ -15,8 +15,7 @@ if objects['1252538687.73gjeon']:
|
||||
objects['1252538687.73gjeon'].setPos(Point3(8.66381, 0, 7.13246))
|
||||
objects['1252538687.73gjeon'].setHpr(VBase3(-180, 0, 0))
|
||||
objects['1252538687.73gjeon'].setScale(VBase3(1, 1, 1))
|
||||
objects['1252538687.73gjeon'].setTransparency(1)
|
||||
objects['1252538687.73gjeon'].setColorScale(VBase4(1, 1, 1, 1))
|
||||
objectMgr.updateObjectColor(1.000000, 1.000000, 1.000000, 1.000000, objects['1252538687.73gjeon'])
|
||||
objectMgr.updateObjectProperties(objects['1252538687.73gjeon'], {'123': 1, 'Abc': 'a', 'Number': 1, 'Happy': True})
|
||||
|
||||
objects['1252538690.2gjeon'] = objectMgr.addNewObject('H Double Smiley', '1252538690.2gjeon', None, objects['1252538687.73gjeon'])
|
||||
@ -24,8 +23,7 @@ if objects['1252538690.2gjeon']:
|
||||
objects['1252538690.2gjeon'].setPos(Point3(0, 0, 2.12046))
|
||||
objects['1252538690.2gjeon'].setHpr(VBase3(0, 0, 0))
|
||||
objects['1252538690.2gjeon'].setScale(VBase3(1, 1, 1))
|
||||
objects['1252538690.2gjeon'].setTransparency(1)
|
||||
objects['1252538690.2gjeon'].setColorScale(VBase4(1, 1, 1, 1))
|
||||
objectMgr.updateObjectColor(1.000000, 1.000000, 1.000000, 1.000000, objects['1252538690.2gjeon'])
|
||||
objectMgr.updateObjectProperties(objects['1252538690.2gjeon'], {'Distance': 2.0, 'Abc': 'a'})
|
||||
|
||||
objects['1252539696.69gjeon'] = objectMgr.addNewObject('H Double Smiley', '1252539696.69gjeon', None, objects['1252538687.73gjeon'])
|
||||
@ -33,8 +31,7 @@ if objects['1252539696.69gjeon']:
|
||||
objects['1252539696.69gjeon'].setPos(Point3(-9.53674e-006, 0, 0))
|
||||
objects['1252539696.69gjeon'].setHpr(VBase3(0, 0, 0))
|
||||
objects['1252539696.69gjeon'].setScale(VBase3(1, 1, 1))
|
||||
objects['1252539696.69gjeon'].setTransparency(1)
|
||||
objects['1252539696.69gjeon'].setColorScale(VBase4(1, 1, 1, 1))
|
||||
objectMgr.updateObjectColor(1.000000, 1.000000, 1.000000, 1.000000, objects['1252539696.69gjeon'])
|
||||
objectMgr.updateObjectProperties(objects['1252539696.69gjeon'], {'Distance': 2.0, 'Abc': 'a'})
|
||||
|
||||
objects['1252539897.22gjeon'] = objectMgr.addNewObject('H Double Smiley', '1252539897.22gjeon', None, objects['1252538687.73gjeon'])
|
||||
@ -42,8 +39,7 @@ if objects['1252539897.22gjeon']:
|
||||
objects['1252539897.22gjeon'].setPos(Point3(0.06987, 0, -2.12046))
|
||||
objects['1252539897.22gjeon'].setHpr(VBase3(0, 0, 0))
|
||||
objects['1252539897.22gjeon'].setScale(VBase3(1, 1, 1))
|
||||
objects['1252539897.22gjeon'].setTransparency(1)
|
||||
objects['1252539897.22gjeon'].setColorScale(VBase4(1, 1, 1, 1))
|
||||
objectMgr.updateObjectColor(1.000000, 1.000000, 1.000000, 1.000000, objects['1252539897.22gjeon'])
|
||||
objectMgr.updateObjectProperties(objects['1252539897.22gjeon'], {'Distance': 2.0, 'Abc': 'a'})
|
||||
|
||||
objects['1252538689.13gjeon'] = objectMgr.addNewObject('V Double Smiley', '1252538689.13gjeon', None, objects['1252538687.73gjeon'])
|
||||
@ -51,8 +47,7 @@ if objects['1252538689.13gjeon']:
|
||||
objects['1252538689.13gjeon'].setPos(Point3(6.07152, 0, -0.863791))
|
||||
objects['1252538689.13gjeon'].setHpr(VBase3(0, 0, 0))
|
||||
objects['1252538689.13gjeon'].setScale(VBase3(1, 1, 1))
|
||||
objects['1252538689.13gjeon'].setTransparency(1)
|
||||
objects['1252538689.13gjeon'].setColorScale(VBase4(1, 1, 1, 1))
|
||||
objectMgr.updateObjectColor(1.000000, 1.000000, 1.000000, 1.000000, objects['1252538689.13gjeon'])
|
||||
objectMgr.updateObjectProperties(objects['1252538689.13gjeon'], {'Distance': 1.0, 'Abc': 'a'})
|
||||
|
||||
objects['1252539974.19gjeon'] = objectMgr.addNewObject('Smiley', '1252539974.19gjeon', 'models/frowney.egg', objects['1252538689.13gjeon'])
|
||||
@ -60,8 +55,7 @@ if objects['1252539974.19gjeon']:
|
||||
objects['1252539974.19gjeon'].setPos(Point3(0.06987, 0, 3.09209))
|
||||
objects['1252539974.19gjeon'].setHpr(VBase3(0, 0, 0))
|
||||
objects['1252539974.19gjeon'].setScale(VBase3(1, 1, 1))
|
||||
objects['1252539974.19gjeon'].setTransparency(1)
|
||||
objects['1252539974.19gjeon'].setColorScale(VBase4(1, 1, 1, 1))
|
||||
objectMgr.updateObjectColor(1.000000, 1.000000, 1.000000, 1.000000, objects['1252539974.19gjeon'])
|
||||
objectMgr.updateObjectProperties(objects['1252539974.19gjeon'], {'123': 1, 'Abc': 'a', 'Number': 1, 'Happy': True})
|
||||
|
||||
objects['1252623762.9gjeon'] = objectMgr.addNewObject('Panda', '1252623762.9gjeon', None, None)
|
||||
@ -69,8 +63,7 @@ if objects['1252623762.9gjeon']:
|
||||
objects['1252623762.9gjeon'].setPos(Point3(0, 0, 0))
|
||||
objects['1252623762.9gjeon'].setHpr(VBase3(172.8, 0, 0))
|
||||
objects['1252623762.9gjeon'].setScale(VBase3(0.005, 0.005, 0.005))
|
||||
objects['1252623762.9gjeon'].setTransparency(1)
|
||||
objects['1252623762.9gjeon'].setColorScale(VBase4(1, 0, 0, 0.57))
|
||||
objectMgr.updateObjectColor(1.000000, 0.000000, 0.000000, 0.517647, objects['1252623762.9gjeon'])
|
||||
objectMgr.updateObjectProperties(objects['1252623762.9gjeon'], {})
|
||||
|
||||
if hasattr(base, 'le'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user