def loadEggModelsFile(self, filepath):
   print "I: EditorClass.loadEggModelsFile:", filepath
   filebase, filetype = os.path.splitext(filepath)
   if filetype == '.egg':
     print "I: EditorClass.loadEggModelsFile: NodePath"
     self.destroyScene()
     self.treeParent = NodePathWrapper.onCreateInstance(None, filepath)
     #if self.editModeEnabled:
     #  self.treeParent.setEditmodeEnabled([NodePathWrapper])
   elif filetype == '.egs':
     print "I: EditorClass.loadEggModelsFile: SceneNode"
     self.destroyScene()
     self.treeParent = SceneNodeWrapper.onCreateInstance(None, filepath)
     #if self.editModeEnabled:
     #  self.treeParent.setEditmodeEnabled([SceneNodeWrapper, NodePathWrapper])
   else:
     print "I: EditorClass.loadEggModelsFile: Unknown", filetype
     return
   
   if self.editModeEnabled:
     self.treeParent.setEditmodeEnabled()
   else:
     print "I: EditorClass.loadEggModelsFile: edit mode is disabled"
   
   # refresh the scenegraphbrowser
   messenger.send(EVENT_SCENEGRAPH_CHANGE_ROOT, [self.treeParent])
   
   if self.editModeEnabled:
     # select no model -> will select sceneRoot
     modelController.selectObject(None)
Beispiel #2
0
    def loadEggModelsFile(self, filepath):
        print "I: EditorClass.loadEggModelsFile:", filepath
        filebase, filetype = os.path.splitext(filepath)
        if filetype == '.egg':
            print "I: EditorClass.loadEggModelsFile: NodePath"
            self.destroyScene()
            self.treeParent = NodePathWrapper.onCreateInstance(None, filepath)
            #if self.editModeEnabled:
            #  self.treeParent.setEditmodeEnabled([NodePathWrapper])
        elif filetype == '.egs':
            print "I: EditorClass.loadEggModelsFile: SceneNode"
            self.destroyScene()
            self.treeParent = SceneNodeWrapper.onCreateInstance(None, filepath)
            #if self.editModeEnabled:
            #  self.treeParent.setEditmodeEnabled([SceneNodeWrapper, NodePathWrapper])
        else:
            print "I: EditorClass.loadEggModelsFile: Unknown", filetype
            return

        if self.editModeEnabled:
            self.treeParent.setEditmodeEnabled()
        else:
            print "I: EditorClass.loadEggModelsFile: edit mode is disabled"

        # refresh the scenegraphbrowser
        messenger.send(EVENT_SCENEGRAPH_CHANGE_ROOT, [self.treeParent])

        if self.editModeEnabled:
            # select no model -> will select sceneRoot
            modelController.selectObject(None)
 def duplicateModelWrapper(self):
     originalModel = modelController.getSelectedObject()
     objectInstance = originalModel.duplicate(originalModel)
     if objectInstance is not None:
         objectInstance.setEditmodeEnabled()
     #objectInstance.loadFromData( originalModel.getSaveData('.') )
     messenger.send(EVENT_SCENEGRAPH_REFRESH)
     modelController.selectObject(objectInstance)
 def duplicateModelWrapper(self):
   originalModel = modelController.getSelectedObject()
   objectInstance = originalModel.duplicate(originalModel)
   if objectInstance is not None:
     objectInstance.setEditmodeEnabled()
   #objectInstance.loadFromData( originalModel.getSaveData('.') )
   messenger.send( EVENT_SCENEGRAPH_REFRESH )
   modelController.selectObject( objectInstance )
 def createEggWrapper(self, type):
   # create the actual wrapper of the object
   module = __import__("core.modules.pNodePathWrapper.p%s" % type, globals(), locals(), [type], -1)
   modelParent = modelController.getSelectedObject()
   objectInstance = getattr(module, type).onCreateInstance(modelParent)
   if objectInstance is not None:
     objectInstance.setEditmodeEnabled()
   messenger.send(EVENT_SCENEGRAPH_REFRESH)
   modelController.selectObject(objectInstance)
 def createEggWrapper(self, type):
     # create the actual wrapper of the object
     module = __import__("core.modules.pNodePathWrapper.p%s" % type,
                         globals(), locals(), [type], -1)
     modelParent = modelController.getSelectedObject()
     objectInstance = getattr(module, type).onCreateInstance(modelParent)
     if objectInstance is not None:
         objectInstance.setEditmodeEnabled()
     messenger.send(EVENT_SCENEGRAPH_REFRESH)
     modelController.selectObject(objectInstance)
 def onCreateFilebrowserModelWrapper(self, objectType, filepath):
   if filepath != None and filepath != '' and filepath != ' ':
     filepath = Filename.fromOsSpecific(filepath).getFullpath()
     modelParent = modelController.getSelectedObject()
     module = __import__("core.modules.p%s" % objectType, globals(), locals(), [objectType], -1)
     objectInstance = getattr(module, objectType).onCreateInstance(modelParent, filepath)
     if objectInstance is not None:
       objectInstance.setEditmodeEnabled()
     messenger.send(EVENT_SCENEGRAPH_REFRESH)
     modelController.selectObject(objectInstance)
 def onCreateFilebrowserModelWrapper(self, objectType, filepath):
     if filepath != None and filepath != '' and filepath != ' ':
         filepath = Filename.fromOsSpecific(filepath).getFullpath()
         modelParent = modelController.getSelectedObject()
         module = __import__("core.modules.p%s" % objectType, globals(),
                             locals(), [objectType], -1)
         objectInstance = getattr(module, objectType).onCreateInstance(
             modelParent, filepath)
         if objectInstance is not None:
             objectInstance.setEditmodeEnabled()
         messenger.send(EVENT_SCENEGRAPH_REFRESH)
         modelController.selectObject(objectInstance)
Beispiel #9
0
    def onCreateObject(self, e):
        """Invoked when the user hits one of the buttons in the "Create" menu."""

        modelParent = modelController.getSelectedObject()
        if modelParent == None: modelParent = render
        objectInstance = None
        if e.Id == ID_NODEPATH:
            objectInstance = NodePathWrapper.onCreateInstance(modelParent)
        elif e.Id == ID_MODEL:
            filter = "Panda3D Egg Format (*.egg)|*.[eE][gG][gG];*.egg"
            filter += "|Panda3D Binary Format (*.bam)|*.[bB][aA][mM];*.bam"
            filter += "|MultiGen (*.flt)|*.[fF][lL][tT];*.flt"
            filter += "|Lightwave (*.lwo)|*.[lL][wW][oO];*.lwo"
            filter += "|AutoCAD (*.dxf)|*.[dD][xX][fF];*.dxf"
            filter += "|VRML (*.wrl)|*.[wW][rR][lL];*.wrl"
            filter += "|DirectX (*.x)|*.[xX];*.x"
            filter += "|COLLADA (*.dae)|*.[dD][aA][eE];*.dae"
            dlg = wx.FileDialog(self, "Select model", "", "", filter, wx.OPEN)
            try:
                if dlg.ShowModal() == wx.ID_OK:
                    objectInstance = NodePathWrapper.onCreateInstance(
                        modelParent,
                        Filename.fromOsSpecific(dlg.GetPath()).getFullpath())
            finally:
                dlg.Destroy()
        elif e.Id == ID_TERRAIN:
            filter = "Portable Network Graphics (*.png)|*.[pP][nN][gG];*.png"
            dlg = wx.FileDialog(self, "Select heightfield", "", "", filter,
                                wx.OPEN)
            try:
                if dlg.ShowModal() == wx.ID_OK:
                    objectInstance = GeoMipTerrainNodeWrapper.onCreateInstance(
                        modelParent,
                        Filename.fromOsSpecific(dlg.GetPath()).getFullpath())
            finally:
                dlg.Destroy()
        elif e.Id == ID_AMBIENT:
            objectInstance = AmbientLightNodeWrapper.onCreateInstance(
                modelParent)
        elif e.Id == ID_DIRECTIONAL:
            objectInstance = DirectionalLightNodeWrapper.onCreateInstance(
                modelParent)
        elif e.Id == ID_POINT:
            objectInstance = PointLightNodeWrapper.onCreateInstance(
                modelParent)
        elif e.Id == ID_SPOT:
            objectInstance = SpotLightNodeWrapper.onCreateInstance(modelParent)

        if objectInstance != None:
            objectInstance.reparentTo(modelParent)
            objectInstance.enableEditmode()
            modelController.selectObject(objectInstance)
            messenger.send(EVENT_SCENEGRAPH_REFRESH)
 def onCreateObject(self, e):
   """Invoked when the user hits one of the buttons in the "Create" menu."""
   
   modelParent = modelController.getSelectedObject() 
   if modelParent == None: modelParent = render
   objectInstance = None
   if e.Id == ID_NODEPATH:
     objectInstance = NodePathWrapper.onCreateInstance(modelParent)
   elif e.Id == ID_MODEL:
     filter = "Panda3D Egg Format (*.egg)|*.[eE][gG][gG];*.egg"
     filter += "|Panda3D Binary Format (*.bam)|*.[bB][aA][mM];*.bam"
     filter += "|MultiGen (*.flt)|*.[fF][lL][tT];*.flt"
     filter += "|Lightwave (*.lwo)|*.[lL][wW][oO];*.lwo"
     filter += "|AutoCAD (*.dxf)|*.[dD][xX][fF];*.dxf"
     filter += "|VRML (*.wrl)|*.[wW][rR][lL];*.wrl"
     filter += "|DirectX (*.x)|*.[xX];*.x"
     filter += "|COLLADA (*.dae)|*.[dD][aA][eE];*.dae"
     dlg = wx.FileDialog(self, "Select model", "", "", filter, wx.OPEN)
     try:
       if dlg.ShowModal() == wx.ID_OK:
         objectInstance = NodePathWrapper.onCreateInstance(modelParent, Filename.fromOsSpecific(dlg.GetPath()).getFullpath())
     finally:
       dlg.Destroy()
   elif e.Id == ID_TERRAIN:
     filter = "Portable Network Graphics (*.png)|*.[pP][nN][gG];*.png"
     dlg = wx.FileDialog(self, "Select heightfield", "", "", filter, wx.OPEN)
     try:
       if dlg.ShowModal() == wx.ID_OK:
         objectInstance = GeoMipTerrainNodeWrapper.onCreateInstance(modelParent, Filename.fromOsSpecific(dlg.GetPath()).getFullpath())
     finally:
       dlg.Destroy()
   elif e.Id == ID_AMBIENT:
     objectInstance = AmbientLightNodeWrapper.onCreateInstance(modelParent)
   elif e.Id == ID_DIRECTIONAL:
     objectInstance = DirectionalLightNodeWrapper.onCreateInstance(modelParent)
   elif e.Id == ID_POINT:
     objectInstance = PointLightNodeWrapper.onCreateInstance(modelParent)
   elif e.Id == ID_SPOT:
     objectInstance = SpotLightNodeWrapper.onCreateInstance(modelParent)
   
   if objectInstance != None:
     objectInstance.reparentTo(modelParent)
     objectInstance.enableEditmode() 
     modelController.selectObject(objectInstance)
     messenger.send(EVENT_SCENEGRAPH_REFRESH)
Beispiel #11
0
 def __disableEditor(self):
   ''' the gui will call this function and disable the core editor using it
   '''
   if self.editModeEnabled:
     # disable editmode on the object tree
     self.treeParent.setEditmodeDisabled()
     # save the selected model to the texturePainter
     #objectEditor.setEditObject(modelController.getSelectedObject())
     # drop what we have selected
     modelController.selectObject(None)
     # disable the selecting of nodes
     scenePicker.toggleEditmode(False)
     modelModificator.toggleEditmode(False)
     
     #texturePainter.disableEditor()
     
     self.editModeEnabled = False
   else:
     print "I: core.EditorClass.__disableEditor: editmode already disabled"
Beispiel #12
0
    def __disableEditor(self):
        ''' the gui will call this function and disable the core editor using it
    '''
        if self.editModeEnabled:
            # disable editmode on the object tree
            self.treeParent.setEditmodeDisabled()
            # save the selected model to the texturePainter
            #objectEditor.setEditObject(modelController.getSelectedObject())
            # drop what we have selected
            modelController.selectObject(None)
            # disable the selecting of nodes
            scenePicker.toggleEditmode(False)
            modelModificator.toggleEditmode(False)

            #texturePainter.disableEditor()

            self.editModeEnabled = False
        else:
            print "I: core.EditorClass.__disableEditor: editmode already disabled"
Beispiel #13
0
 def destroyModel(self):
   selectedObject = modelController.getSelectedObject()
   if selectedObject is not None:
     if selectedObject == self.treeParent:
       print "W: core.EditorClass: should not destroy root object"
       return
     modelController.selectObject(None)
     
     MEMLEAK_CHECK = False
     if MEMLEAK_CHECK:
       tmp = [selectedObject]
     
     # delete recursively
     for object in selectedObject.getRecChildren():
       if MEMLEAK_CHECK:
         tmp.append(object)
       object.destroy()
       del object
     
     selectedObject.destroy()
     del selectedObject
     
     # refresh the scenegraphbrowser
     messenger.send(EVENT_SCENEGRAPH_REFRESH)
     
     if MEMLEAK_CHECK:
       import gc
       gc.collect()
       gc.collect()
       for t in tmp:
         print "W: EditorClass.destroyModel: MEMLEAK_CHECK"
         print "  - type:          ", t.__class__.__name__
         print "  - instance:      ", t
         print "  - num references:", len(gc.get_referrers(t))
         for ref in gc.get_referrers(t):
           print "    -", ref
Beispiel #14
0
    def destroyModel(self):
        selectedObject = modelController.getSelectedObject()
        if selectedObject is not None:
            if selectedObject == self.treeParent:
                print "W: core.EditorClass: should not destroy root object"
                return
            modelController.selectObject(None)

            MEMLEAK_CHECK = False
            if MEMLEAK_CHECK:
                tmp = [selectedObject]

            # delete recursively
            for object in selectedObject.getRecChildren():
                if MEMLEAK_CHECK:
                    tmp.append(object)
                object.destroy()
                del object

            selectedObject.destroy()
            del selectedObject

            # refresh the scenegraphbrowser
            messenger.send(EVENT_SCENEGRAPH_REFRESH)

            if MEMLEAK_CHECK:
                import gc
                gc.collect()
                gc.collect()
                for t in tmp:
                    print "W: EditorClass.destroyModel: MEMLEAK_CHECK"
                    print "  - type:          ", t.__class__.__name__
                    print "  - instance:      ", t
                    print "  - num references:", len(gc.get_referrers(t))
                    for ref in gc.get_referrers(t):
                        print "    -", ref
 def onSelChange(self, item):
   """This event gets invoked when the selection gets changed on the tree view."""
   if self.ignoreSelChange: return
   if not isinstance(item, wx.TreeItemId):
     item = item.GetItem()
   modelController.selectObject(self.GetItemPyData(item))