def getMouseOverObjectModel(self, pickedObj): ''' get a object under the mouse ''' if pickedObj: pickedObjTaggedParent = pickedObj.findNetTag(EDITABLE_OBJECT_TAG) if not pickedObjTaggedParent.isEmpty(): objectId = pickedObjTaggedParent.getNetTag(EDITABLE_OBJECT_TAG) object = modelIdManager.getObject(objectId) return object return None
def getMouseOverObjectModel(self, pickedObj): ''' get a object under the mouse ''' if pickedObj: pickedObjTaggedParent=pickedObj.findNetTag(EDITABLE_OBJECT_TAG) if not pickedObjTaggedParent.isEmpty(): objectId = pickedObjTaggedParent.getNetTag(EDITABLE_OBJECT_TAG) object = modelIdManager.getObject(objectId) return object return None
def __appendChildren(self, treeParent, nodePath): """Used internally to recursively add the children of a nodepath to the scene graph browser.""" for c in xrange(nodePath.getNumChildren()): childNodePath = nodePath.getChildren(c) childModel = modelIdManager.getObject(modelIdManager.getObjectId(childNodePath)) #if childNodePath.hasTag(ENABLE_SCENEGRAPHBROWSER_MODEL_TAG): if True: treeItem = self.AppendItem(treeParent, childNodePath.getName()) self.SetItemPyData(treeItem, childModel) self.modelDict[childNodePath] = treeItem # Iterate through the children self.__appendChildren(treeItem, childNodePath)
def mouseButtonPress(self): if self.__3dModelSelectionActive: if self.editmodeEnabled: pickedObjects = self.getMouseOverNodesList() # print "I: ModelController.mouseButtonPress: found", len(pickedObjects) if len(pickedObjects) > 0: editModel = self.getMouseOverObjectModel(pickedObjects[0]) editTool = self.getMouseOverObjectTool(pickedObjects) if editTool: messenger.send(EVENT_MODELCONTROLLER_EDITTOOL_SELECTED, [editTool]) elif editModel: #if self.__3dModelSelectionActive: modelId = modelIdManager.getObjectId(editModel) object = modelIdManager.getObject(modelId) messenger.send(EVENT_MODELCONTROLLER_SELECT_OBJECT, [object]) else: # no object was clicked on messenger.send(EVENT_MODELCONTROLLER_SELECT_OBJECT, [None])
def __init__(self, object): # you should store the object :-) self.object = object taskMgr.add(self.updateTask, 'updateTask-%s' % self.object.id) if DEBUG: print "I: TestObjectExtension.__init__" print " - searching for object", modelIdManager.getObject(self.object.id) print " - number of objects in scene", len(modelIdManager.getAllObjects()) allNodes = modelIdManager.getAllObjects() for node in allNodes: try: if node.getNodepath().getName() == 'teapot.egg.pz': if DEBUG: print " - found teapot", node except: if DEBUG: print "E: TestObjectExtension.__init__: this is a bug in the code, delete seems not have run on all objects" self.accept('arrow_up', self.up) if DEBUG: print " - done"