コード例 #1
0
ファイル: InGameEditor.py プロジェクト: perpi06/ttoffline
    def addColorWidget(self, levelSpec, entSpec, entId, attribName, params):

        def veCommand(colorlist):
            self.level.setAttribEdit(entId, attribName, Vec4(*colorlist) / 255.0)

        vec = entSpec[attribName]
        value = [vec[0] * 255.0,
         vec[1] * 255.0,
         vec[2] * 255.0,
         vec[3] * 255.0]
        floaterLabels = ['r',
         'g',
         'b',
         'a']
        widg = VectorWidgets.ColorEntry(self.pageOneFrame.interior(), text=attribName, type='slider', relief=None, bd=0, label_justify=LEFT, label_anchor=W, label_width=14, label_bd=0, labelIpadx=0, floaterGroup_labels=floaterLabels, value=value, floaterGroup_value=value)
        widg['command'] = veCommand
        widg.pack(fill=X, expand=1)

        def adjustEntity(vec):
            entity = self.level.getEntInstance(entId)
            if entity is not None:
                entity.setColor(vec[0] / 255.0, vec[1] / 255.0, vec[2] / 255.0, vec[3] / 255.0)
            widg.set(vec, 0)
            return

        widg._floaters['command'] = adjustEntity
        widg._floaters.component('valuatorGroup')['postCallback'] = lambda x, y, z, a: veCommand([x,
         y,
         z,
         a])
        self.attribWidgets.append(widg)
        self.curEntWidgets[attribName] = lambda x: widg.set(x * 255.0, 0)
        return
コード例 #2
0
ファイル: InGameEditor.py プロジェクト: perpi06/ttoffline
    def addVec3Widget(self, levelSpec, entSpec, entId, attribName, params, datatype):

        def veCommand(poslist):
            self.level.setAttribEdit(entId, attribName, Point3(*poslist))

        vec = entSpec[attribName]
        if not isinstance(vec, VBase3):
            vec = Vec3(vec)
        value = [
         vec[0], vec[1], vec[2]]
        minVal = maxVal = None
        if datatype == 'pos':
            floaterLabels = [
             'x', 'y', 'z']
            floaterType = 'floater'
        elif datatype == 'hpr':
            floaterLabels = [
             'h', 'p', 'r']
            floaterType = 'angledial'
        else:
            floaterLabels = [
             'sx', 'sy', 'sz']
            floaterType = 'slider'
            minVal = 0
            maxVal = 1000
        widg = VectorWidgets.VectorEntry(self.pageOneFrame.interior(), text=attribName, value=value, type=floaterType, bd=0, relief=None, min=minVal, max=maxVal, label_justify=LEFT, label_anchor=W, label_width=14, label_bd=0, labelIpadx=0, floaterGroup_labels=floaterLabels)
        widg['command'] = veCommand
        widg.pack(fill=X, expand=1)
        if attribName in ('pos', 'hpr', 'scale'):

            def placeEntity():
                selectedEntityNP = self.level.getEntInstanceNP(entId)
                if selectedEntityNP is not None:
                    selectedEntityNP.place()
                return

            widg.menu.add_command(label='Place...', command=placeEntity)

        def adjustCopy(vec):
            self.updateEntityCopy(entId)
            if self.entityCopy is not None:
                if datatype == 'pos':
                    self.entityCopy.setPos(vec[0], vec[1], vec[2])
                elif datatype == 'hpr':
                    self.entityCopy.setHpr(vec[0], vec[1], vec[2])
                elif datatype == 'scale':
                    self.entityCopy.setScale(vec[0], vec[1], vec[2])
            widg.set(vec, 0)
            return

        widg._floaters['command'] = adjustCopy
        widg._floaters.component('valuatorGroup')['postCallback'] = lambda x, y, z: veCommand([x, y, z])
        self.attribWidgets.append(widg)
        self.curEntWidgets[attribName] = lambda x: widg.set(x, 0)
        return
コード例 #3
0
    def createInterface(self):
        # The interior of the toplevel panel
        interior = self.interior()
        # Add placer commands to menubar
        self.menuBar.addmenu('DIRECT', 'Direct Session Panel Operations')
        
        self.directEnabled = BooleanVar()
        self.directEnabled.set(1)
        self.menuBar.addmenuitem('DIRECT', 'checkbutton',
                                 'DIRECT Enabled',
                                 label = 'Enable',
                                 variable = self.directEnabled,
                                 command = self.toggleDirect)
        
        self.directGridEnabled = BooleanVar()
        self.directGridEnabled.set(direct.grid.isEnabled())
        self.menuBar.addmenuitem('DIRECT', 'checkbutton',
                                 'DIRECT Grid Enabled',
                                 label = 'Enable Grid',
                                 variable = self.directGridEnabled,
                                 command = self.toggleDirectGrid)

        self.menuBar.addmenuitem('DIRECT', 'command',
                                 'Toggle Object Handles Visability',
                                 label = 'Toggle Widget Viz',
                                 command = direct.toggleWidgetVis)

        self.menuBar.addmenuitem(
            'DIRECT', 'command',
            'Toggle Widget Move/COA Mode',
            label = 'Toggle Widget Mode',
            command = direct.manipulationControl.toggleObjectHandlesMode)
        
        self.directWidgetOnTop = BooleanVar()
        self.directWidgetOnTop.set(0)
        self.menuBar.addmenuitem('DIRECT', 'checkbutton',
                                 'DIRECT Widget On Top',
                                 label = 'Widget On Top',
                                 variable = self.directWidgetOnTop,
                                 command = self.toggleWidgetOnTop)

        self.menuBar.addmenuitem('DIRECT', 'command',
                                 'Deselect All',
                                 label = 'Deselect All',
                                 command = direct.deselectAll)

        # Get a handle to the menu frame
        menuFrame = self.menuFrame

        # Widget to select node paths (and display list of selected node paths)
        self.nodePathMenu = Pmw.ComboBox(
            menuFrame, labelpos = W, label_text = 'DIRECT Select:',
            entry_width = 20,
            selectioncommand = self.selectNodePathNamed,
            scrolledlist_items = self.nodePathNames)
        self.nodePathMenu.selectitem('widget')
        self.nodePathMenuEntry = (
            self.nodePathMenu.component('entryfield_entry'))
        self.nodePathMenuBG = (
            self.nodePathMenuEntry.configure('background')[3])
        self.nodePathMenu.pack(side = LEFT, fill = X, expand = 1)
        self.bind(self.nodePathMenu, 'Select node path to manipulate')

        self.undoButton = Button(menuFrame, text = 'Undo',
                                 command = direct.undo)
        if direct.undoList:
            self.undoButton['state'] = 'normal'
        else:
            self.undoButton['state'] = 'disabled'
        self.undoButton.pack(side = LEFT, expand = 0)
        self.bind(self.undoButton, 'Undo last operation')

        self.redoButton = Button(menuFrame, text = 'Redo',
                                 command = direct.redo)
        if direct.redoList:
            self.redoButton['state'] = 'normal'
        else:
            self.redoButton['state'] = 'disabled'
        self.redoButton.pack(side = LEFT, expand = 0)
        self.bind(self.redoButton, 'Redo last operation')

        # The master frame for the dials
        mainFrame = Frame(interior)

        # Paned widget for dividing two halves
        framePane = Pmw.PanedWidget(mainFrame, orient = HORIZONTAL)
        sgeFrame = framePane.add('left', min = 250)
        notebookFrame = framePane.add('right', min = 300)

        # Scene Graph Explorer
        self.SGE = SceneGraphExplorer.SceneGraphExplorer(
            sgeFrame, nodePath = render,
            scrolledCanvas_hull_width = 250,
            scrolledCanvas_hull_height = 300)
        self.SGE.pack(fill = BOTH, expand = 0)
        sgeFrame.pack(side = LEFT, fill = 'both', expand = 0)

        # Create the notebook pages
        notebook = Pmw.NoteBook(notebookFrame)
        notebook.pack(fill = BOTH, expand = 1)
        envPage = notebook.add('Environment')
        lightsPage = notebook.add('Lights')
        gridPage = notebook.add('Grid')
        devicePage = notebook.add('Devices')
        tasksPage = notebook.add('Tasks')
        scenePage = notebook.add('Scene')
        # Put this here so it isn't called right away
        notebook['raisecommand'] = self.updateInfo

        ## Environment page ##
        # Backgroud color
        bkgrdFrame = Frame(envPage, borderwidth = 2, relief = 'sunken')
        
        Label(bkgrdFrame, text = 'Background',
              font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
        
        self.backgroundColor = VectorWidgets.ColorEntry(
            bkgrdFrame, text = 'Background Color')
        self.backgroundColor['command'] = self.setBackgroundColorVec
        self.backgroundColor.pack(fill = X, expand = 0)
        self.bind(self.backgroundColor, 'Set background color')
        bkgrdFrame.pack(fill = BOTH, expand = 0)

        drFrame = Frame(envPage, borderwidth = 2, relief = 'sunken')
        Label(drFrame, text = 'Display Region',
              font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
        
        nameList = map(lambda x: 'Display Region ' + `x`,
                       range(len(direct.drList)))
        self.drMenu = Pmw.ComboBox(
            drFrame, labelpos = W, label_text = 'Display Region:',
            entry_width = 20,
            selectioncommand = self.selectDisplayRegionNamed,
            scrolledlist_items = nameList)
        self.drMenu.pack(fill = X, expand = 0)
        self.bind(self.drMenu, 'Select display region to configure')
        
        self.nearPlane = Floater.Floater(
            drFrame,
            text = 'Near Plane',
            min = 0.01)
        self.nearPlane['command'] = self.setNear
        self.nearPlane.pack(fill = X, expand = 0)
        self.bind(self.nearPlane, 'Set near plane distance')
           
        self.farPlane = Floater.Floater(
            drFrame,
            text = 'Far Plane',
            min = 0.01)
        self.farPlane['command'] = self.setFar
        self.farPlane.pack(fill = X, expand = 0)
        self.bind(self.farPlane, 'Set far plane distance')

        fovFrame = Frame(drFrame)
        fovFloaterFrame = Frame(fovFrame)
        self.hFov = Slider.Slider(
            fovFloaterFrame,
            text = 'Horizontal FOV',
            min = 0.01, max = 170.0)
        self.hFov['command'] = self.setHFov
        self.hFov.pack(fill = X, expand = 0)
        self.bind(self.hFov, 'Set horizontal field of view')
           
        self.vFov = Slider.Slider(
            fovFloaterFrame,
            text = 'Vertical FOV',
            min = 0.01, max = 170.0)
        self.vFov['command'] = self.setVFov
        self.vFov.pack(fill = X, expand = 0)
        self.bind(self.vFov, 'Set vertical field of view')
        fovFloaterFrame.pack(side = LEFT, fill = X, expand = 1)

        frame = Frame(fovFrame)
        self.lockedFov = BooleanVar()
        self.lockedFov.set(1)
        self.lockedFovButton = Checkbutton(
            frame,
            text = 'Locked',
            anchor = 'w', justify = LEFT,
            variable = self.lockedFov)
        self.lockedFovButton.pack(fill = X, expand = 0)

        self.resetFovButton = Button(
            frame,
            text = 'Reset',
            command = self.resetFov)
        self.resetFovButton.pack(fill = X, expand = 0)
        frame.pack(side = LEFT, fill = X, expand = 0)
        fovFrame.pack(fill = X, expand = 1)
        
        
        drFrame.pack(fill = BOTH, expand = 0)

        ## Render Style ##
        toggleFrame = Frame(envPage, borderwidth = 2, relief = 'sunken')
        Label(toggleFrame, text = 'Toggle Render Style',
              font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
        self.toggleBackfaceButton = Button(
            toggleFrame,
            text = 'Backface',
            command = base.toggleBackface)
        self.toggleBackfaceButton.pack(side = LEFT, fill = X, expand = 1)
        
        self.toggleLightsButton = Button(
            toggleFrame,
            text = 'Lights',
            command = direct.lights.toggle)
        self.toggleLightsButton.pack(side = LEFT, fill = X, expand = 1)

        self.toggleTextureButton = Button(
            toggleFrame,
            text = 'Texture',
            command = base.toggleTexture)
        self.toggleTextureButton.pack(side = LEFT, fill = X, expand = 1)
        
        self.toggleWireframeButton = Button(
            toggleFrame,
            text = 'Wireframe',
            command = base.toggleWireframe)
        self.toggleWireframeButton.pack(fill = X, expand = 1)
        toggleFrame.pack(side = LEFT, fill = X, expand = 1)

        ## Lights page ##
        # Lights #
        lightFrame = Frame(lightsPage, borderwidth = 2, relief = 'sunken')
        self.lightsButton = Menubutton(lightFrame, text = 'Lights',
                                       font=('MSSansSerif', 14, 'bold'),
                                       activebackground = '#909090')
        lightsMenu = Menu(self.lightsButton)
        lightsMenu.add_command(label = 'Add Ambient Light',
                            command = self.addAmbient)
        lightsMenu.add_command(label = 'Add Directional Light',
                            command = self.addDirectional)
        lightsMenu.add_command(label = 'Add Point Light',
                            command = self.addPoint)
        lightsMenu.add_command(label = 'Add Spotlight',
                            command = self.addSpot)
            
        self.lightsButton.pack(expand = 0)
        self.lightsButton['menu'] = lightsMenu
        
        # Notebook pages for light specific controls
        self.lightNotebook = Pmw.NoteBook(lightFrame, tabpos = None,
                                          borderwidth = 0)
        ambientPage = self.lightNotebook.add('Ambient')
        directionalPage = self.lightNotebook.add('Directional')
        pointPage = self.lightNotebook.add('Point')
        spotPage = self.lightNotebook.add('Spot')
        # Put this here so it isn't called right away
        self.lightNotebook['raisecommand'] = self.updateLightInfo

        # Main light switch
        mainSwitchFrame = Frame(lightFrame)
        Label(mainSwitchFrame,
              text = 'Lighting:').pack(side = LEFT, expand = 0)
        self.enableLights = BooleanVar()
        self.enableLightsButton = Checkbutton(
            mainSwitchFrame,
            text = 'Enabled/Disabled',
            variable = self.enableLights,
            command = self.toggleLights)
        self.enableLightsButton.pack(side = LEFT, fill = X, expand = 0)
        mainSwitchFrame.pack(fill = X, expand = 0)
        
        # Widget to select a light to configure
        nameList = direct.lights.getNameList()
        lightMenuFrame = Frame(lightFrame)
        
        self.lightMenu = Pmw.ComboBox(
            lightMenuFrame, labelpos = W, label_text = 'Light:',
            entry_width = 20,
            selectioncommand = self.selectLightNamed,
            scrolledlist_items = nameList)
        self.lightMenu.pack(side = LEFT, fill = X, expand = 0)
        self.bind(self.lightMenu, 'Select light to configure')
        
        self.lightActive = BooleanVar()
        self.lightActiveButton = Checkbutton(
            lightMenuFrame,
            text = 'On/Off',
            variable = self.lightActive,
            command = self.toggleActiveLight)
        self.lightActiveButton.pack(side = LEFT, fill = X, expand = 0)

        # Pack light menu
        lightMenuFrame.pack(fill = X, expand = 0, padx = 2)

        self.lightColor = VectorWidgets.ColorEntry(
            lightFrame, text = 'Light Color')
        self.lightColor['command'] = self.setLightColor
        self.lightColor.pack(fill = X, expand = 0, padx = 4)
        self.bind(self.lightColor, 'Set active light color')

        # Directional light controls
        self.dSpecularColor = VectorWidgets.ColorEntry(
            directionalPage, text = 'Specular Color')
        self.dSpecularColor['command'] = self.setSpecularColor
        self.dSpecularColor.pack(fill = X, expand = 0)
        self.bind(self.dSpecularColor,
                  'Set directional light specular color')

        # Point light controls
        self.pSpecularColor = VectorWidgets.ColorEntry(
            pointPage, text = 'Specular Color')
        self.pSpecularColor['command'] = self.setSpecularColor
        self.pSpecularColor.pack(fill = X, expand = 0)
        self.bind(self.pSpecularColor,
                  'Set point light specular color')

        self.pConstantAttenuation = Slider.Slider(
            pointPage,
            text = 'Constant Attenuation',
            min = 0.0, max = 1.0, value = 1.0)
        self.pConstantAttenuation['command'] = self.setConstantAttenuation
        self.pConstantAttenuation.pack(fill = X, expand = 0)
        self.bind(self.pConstantAttenuation,
                  'Set point light constant attenuation')
           
        self.pLinearAttenuation = Slider.Slider(
            pointPage,
            text = 'Linear Attenuation',
            min = 0.0, max = 1.0, value = 0.0)
        self.pLinearAttenuation['command'] = self.setLinearAttenuation
        self.pLinearAttenuation.pack(fill = X, expand = 0)
        self.bind(self.pLinearAttenuation,
                  'Set point light linear attenuation')
           
        self.pQuadraticAttenuation = Slider.Slider(
            pointPage,
            text = 'Quadratic Attenuation',
            min = 0.0, max = 1.0, value = 0.0)
        self.pQuadraticAttenuation['command'] = self.setQuadraticAttenuation
        self.pQuadraticAttenuation.pack(fill = X, expand = 0)
        self.bind(self.pQuadraticAttenuation,
                  'Set point light quadratic attenuation')
           
        # Spot light controls
        self.sSpecularColor = VectorWidgets.ColorEntry(
            spotPage, text = 'Specular Color')
        self.sSpecularColor['command'] = self.setSpecularColor
        self.sSpecularColor.pack(fill = X, expand = 0)
        self.bind(self.sSpecularColor,
                  'Set spot light specular color')

        self.sConstantAttenuation = Slider.Slider(
            spotPage,
            text = 'Constant Attenuation',
            min = 0.0, max = 1.0, value = 1.0)
        self.sConstantAttenuation['command'] = self.setConstantAttenuation
        self.sConstantAttenuation.pack(fill = X, expand = 0)
        self.bind(self.sConstantAttenuation,
                  'Set spot light constant attenuation')
           
        self.sLinearAttenuation = Slider.Slider(
            spotPage,
            text = 'Linear Attenuation',
            min = 0.0, max = 1.0, value = 0.0)
        self.sLinearAttenuation['command'] = self.setLinearAttenuation
        self.sLinearAttenuation.pack(fill = X, expand = 0)
        self.bind(self.sLinearAttenuation,
                  'Set spot light linear attenuation')
           
        self.sQuadraticAttenuation = Slider.Slider(
            spotPage,
            text = 'Quadratic Attenuation',
            min = 0.0, max = 1.0, value = 0.0)
        self.sQuadraticAttenuation['command'] = self.setQuadraticAttenuation
        self.sQuadraticAttenuation.pack(fill = X, expand = 0)
        self.bind(self.sQuadraticAttenuation,
                  'Set spot light quadratic attenuation')
           
        self.sExponent = Slider.Slider(
            spotPage,
            text = 'Exponent',
            min = 0.0, max = 1.0, value = 0.0)
        self.sExponent['command'] = self.setExponent
        self.sExponent.pack(fill = X, expand = 0)
        self.bind(self.sExponent,
                  'Set spot light exponent')

        # MRM: Add frustum controls
           
        self.lightNotebook.setnaturalsize()
        self.lightNotebook.pack(expand = 1, fill = BOTH)
        
        lightFrame.pack(expand = 1, fill = BOTH)

        ## GRID PAGE ##
        Label(gridPage, text = 'Grid',
              font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
        self.enableGrid = BooleanVar()
        self.enableGridButton = Checkbutton(
            gridPage,
            text = 'Enabled/Disabled',
            anchor = 'w', justify = LEFT,
            variable = self.enableGrid,
            command = self.toggleGrid)
        self.enableGridButton.pack(fill = X, expand = 0)

        self.xyzSnap = BooleanVar()
        self.xyzSnapButton = Checkbutton(
            gridPage,
            text = 'XYZ Snap',
            anchor = 'w', justify = LEFT,
            variable = self.xyzSnap,
            command = self.toggleXyzSnap)
        self.xyzSnapButton.pack(fill = X, expand = 0)

        self.hprSnap = BooleanVar()
        self.hprSnapButton = Checkbutton(
            gridPage,
            text = 'HPR Snap',
            anchor = 'w', justify = LEFT,
            variable = self.hprSnap,
            command = self.toggleHprSnap)
        self.hprSnapButton.pack(fill = X, expand = 0)

        self.gridSpacing = Floater.Floater(
            gridPage,
            text = 'Grid Spacing',
            min = 0.1,
            value = direct.grid.getGridSpacing())
        self.gridSpacing['command'] = direct.grid.setGridSpacing
        self.gridSpacing.pack(fill = X, expand = 0)
        
        self.gridSize = Floater.Floater(
            gridPage,
            text = 'Grid Size',
            min = 1.0,
            value = direct.grid.getGridSize())
        self.gridSize['command'] = direct.grid.setGridSize
        self.gridSize.pack(fill = X, expand = 0)

        self.gridSnapAngle = Dial.AngleDial(
            gridPage,
            text = 'Snap Angle',
            style = 'mini',
            value = direct.grid.getSnapAngle())
        self.gridSnapAngle['command'] = direct.grid.setSnapAngle
        self.gridSnapAngle.pack(fill = X, expand = 0)

        ## DEVICE PAGE ##
        Label(devicePage, text = 'DEVICES',
              font=('MSSansSerif', 14, 'bold')).pack(expand = 0)

        if direct.joybox != None:
            joyboxFrame = Frame(devicePage, borderwidth = 2, relief = 'sunken')
            Label(joyboxFrame, text = 'Joybox',
                  font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
            self.enableJoybox = BooleanVar()
            self.enableJoybox.set(1)
            self.enableJoyboxButton = Checkbutton(
                joyboxFrame,
                text = 'Enabled/Disabled',
                anchor = 'w', justify = LEFT,
                variable = self.enableJoybox,
                command = self.toggleJoybox)
            self.enableJoyboxButton.pack(fill = X, expand = 0)
            joyboxFrame.pack(fill = X, expand = 0)

            self.jbModeMenu = Pmw.ComboBox(
                joyboxFrame, labelpos = W, label_text = 'Joybox Mode:',
                label_width = 16, entry_width = 20,
                selectioncommand = self.selectJBModeNamed,
                scrolledlist_items = ['Joe Mode', 'Drive Mode', 'Orbit Mode',
                                      'Look At Mode', 'Look Around Mode',
                                      'Walkthru Mode', 'Demo Mode',
                                      'HPRXYZ Mode'])
            self.jbModeMenu.selectitem('Joe Mode')
            self.jbModeMenu.pack(fill = X, expand = 1)
            
            self.jbNodePathMenu = Pmw.ComboBox(
                joyboxFrame, labelpos = W, label_text = 'Joybox Node Path:',
                label_width = 16, entry_width = 20,
                selectioncommand = self.selectJBNodePathNamed,
                scrolledlist_items = self.jbNodePathNames)
            self.jbNodePathMenu.selectitem('camera')
            self.jbNodePathMenuEntry = (
                self.jbNodePathMenu.component('entryfield_entry'))
            self.jbNodePathMenuBG = (
                self.jbNodePathMenuEntry.configure('background')[3])
            self.jbNodePathMenu.pack(fill = X, expand = 1)
            self.bind(self.jbNodePathMenu,
                      'Select node path to manipulate using the joybox')

            self.jbXyzSF = Slider.Slider(
                joyboxFrame,
                text = 'XYZ Scale Factor',
                value = 1.0,
                hull_relief = RIDGE, hull_borderwidth = 2,
                min = 1.0, max = 100.0)
            self.jbXyzSF['command'] = (
                lambda v: direct.joybox.setXyzMultiplier(v))
            self.jbXyzSF.pack(fill = X, expand = 0)
            self.bind(self.jbXyzSF, 'Set joybox XYZ speed multiplier')

            self.jbHprSF = Slider.Slider(
                joyboxFrame,
                text = 'HPR Scale Factor',
                value = 1.0,
                hull_relief = RIDGE, hull_borderwidth = 2,
                min = 1.0, max = 100.0)
            self.jbHprSF['command'] = (
                lambda v: direct.joybox.setHprMultiplier(v))
            self.jbHprSF.pack(fill = X, expand = 0)
            self.bind(self.jbHprSF, 'Set joybox HPR speed multiplier')

        ## TASKS PAGE ##
        Label(tasksPage, text = 'TASKS',
              font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
        self.taskMgrPanel = TaskManagerWidget(tasksPage, taskMgr)
        self.taskMgrPanel.taskListBox['listbox_height'] = 10

        notebook.setnaturalsize()

        framePane.pack(expand = 1, fill = BOTH)
        mainFrame.pack(fill = 'both', expand = 1)
コード例 #4
0
    def createLightsPage(self, lightsPage):
        # Lights #
        lightFrame = Frame(lightsPage, borderwidth = 2, relief = 'sunken')
        self.lightsButton = Menubutton(lightFrame, text = 'Lights',
                                       font=('MSSansSerif', 14, 'bold'),
                                       activebackground = '#909090')
        lightsMenu = Menu(self.lightsButton)
        lightsMenu.add_command(label = 'Add Ambient Light',
                            command = self.addAmbient)
        lightsMenu.add_command(label = 'Add Directional Light',
                            command = self.addDirectional)
        lightsMenu.add_command(label = 'Add Point Light',
                            command = self.addPoint)
        lightsMenu.add_command(label = 'Add Spotlight',
                            command = self.addSpot)

        self.lightsButton.pack(expand = 0)
        self.lightsButton['menu'] = lightsMenu

        # Notebook pages for light specific controls
        self.lightNotebook = Pmw.NoteBook(lightFrame, tabpos = None,
                                          borderwidth = 0)
        ambientPage = self.lightNotebook.add('Ambient')
        directionalPage = self.lightNotebook.add('Directional')
        pointPage = self.lightNotebook.add('Point')
        spotPage = self.lightNotebook.add('Spot')
        # Put this here so it isn't called right away
        self.lightNotebook['raisecommand'] = self.updateLightInfo

        # Main light switch
        mainSwitchFrame = Frame(lightFrame)
        Label(mainSwitchFrame,
              text = 'Lighting:').pack(side = LEFT, expand = 0)
        self.enableLights = BooleanVar()
        self.enableLightsButton = Checkbutton(
            mainSwitchFrame,
            text = 'Enabled/Disabled',
            variable = self.enableLights,
            command = self.toggleLights)
        self.enableLightsButton.pack(side = LEFT, fill = X, expand = 0)
        mainSwitchFrame.pack(fill = X, expand = 0)

        # Widget to select a light to configure
        nameList = base.direct.lights.getNameList()
        lightMenuFrame = Frame(lightFrame)

        self.lightMenu = Pmw.ComboBox(
            lightMenuFrame, labelpos = W, label_text = 'Light:',
            entry_width = 20,
            selectioncommand = self.selectLightNamed,
            scrolledlist_items = nameList)
        self.lightMenu.pack(side = LEFT, fill = X, expand = 0)
        self.bind(self.lightMenu, 'Select light to configure')

        self.lightActive = BooleanVar()
        self.lightActiveButton = Checkbutton(
            lightMenuFrame,
            text = 'On/Off',
            variable = self.lightActive,
            command = self.toggleActiveLight)
        self.lightActiveButton.pack(side = LEFT, fill = X, expand = 0)

        # Pack light menu
        lightMenuFrame.pack(fill = X, expand = 0, padx = 2)

        self.lightColor = VectorWidgets.ColorEntry(
            lightFrame, text = 'Light Color')
        self.lightColor['command'] = self.setLightColor
        self.lightColor.pack(fill = X, expand = 0, padx = 4)
        self.bind(self.lightColor, 'Set active light color')

        # Directional light controls
        self.dSpecularColor = VectorWidgets.ColorEntry(
            directionalPage, text = 'Specular Color')
        self.dSpecularColor['command'] = self.setSpecularColor
        self.dSpecularColor.pack(fill = X, expand = 0)
        self.bind(self.dSpecularColor,
                  'Set directional light specular color')

        # Point light controls
        self.pSpecularColor = VectorWidgets.ColorEntry(
            pointPage, text = 'Specular Color')
        self.pSpecularColor['command'] = self.setSpecularColor
        self.pSpecularColor.pack(fill = X, expand = 0)
        self.bind(self.pSpecularColor,
                  'Set point light specular color')

        self.pConstantAttenuation = Slider.Slider(
            pointPage,
            text = 'Constant Attenuation',
            min = 0.0, max = 1.0, value = 1.0)
        self.pConstantAttenuation['command'] = self.setConstantAttenuation
        self.pConstantAttenuation.pack(fill = X, expand = 0)
        self.bind(self.pConstantAttenuation,
                  'Set point light constant attenuation')

        self.pLinearAttenuation = Slider.Slider(
            pointPage,
            text = 'Linear Attenuation',
            min = 0.0, max = 1.0, value = 0.0)
        self.pLinearAttenuation['command'] = self.setLinearAttenuation
        self.pLinearAttenuation.pack(fill = X, expand = 0)
        self.bind(self.pLinearAttenuation,
                  'Set point light linear attenuation')

        self.pQuadraticAttenuation = Slider.Slider(
            pointPage,
            text = 'Quadratic Attenuation',
            min = 0.0, max = 1.0, value = 0.0)
        self.pQuadraticAttenuation['command'] = self.setQuadraticAttenuation
        self.pQuadraticAttenuation.pack(fill = X, expand = 0)
        self.bind(self.pQuadraticAttenuation,
                  'Set point light quadratic attenuation')

        # Spot light controls
        self.sSpecularColor = VectorWidgets.ColorEntry(
            spotPage, text = 'Specular Color')
        self.sSpecularColor['command'] = self.setSpecularColor
        self.sSpecularColor.pack(fill = X, expand = 0)
        self.bind(self.sSpecularColor,
                  'Set spot light specular color')

        self.sConstantAttenuation = Slider.Slider(
            spotPage,
            text = 'Constant Attenuation',
            min = 0.0, max = 1.0, value = 1.0)
        self.sConstantAttenuation['command'] = self.setConstantAttenuation
        self.sConstantAttenuation.pack(fill = X, expand = 0)
        self.bind(self.sConstantAttenuation,
                  'Set spot light constant attenuation')

        self.sLinearAttenuation = Slider.Slider(
            spotPage,
            text = 'Linear Attenuation',
            min = 0.0, max = 1.0, value = 0.0)
        self.sLinearAttenuation['command'] = self.setLinearAttenuation
        self.sLinearAttenuation.pack(fill = X, expand = 0)
        self.bind(self.sLinearAttenuation,
                  'Set spot light linear attenuation')

        self.sQuadraticAttenuation = Slider.Slider(
            spotPage,
            text = 'Quadratic Attenuation',
            min = 0.0, max = 1.0, value = 0.0)
        self.sQuadraticAttenuation['command'] = self.setQuadraticAttenuation
        self.sQuadraticAttenuation.pack(fill = X, expand = 0)
        self.bind(self.sQuadraticAttenuation,
                  'Set spot light quadratic attenuation')

        self.sExponent = Slider.Slider(
            spotPage,
            text = 'Exponent',
            min = 0.0, max = 1.0, value = 0.0)
        self.sExponent['command'] = self.setExponent
        self.sExponent.pack(fill = X, expand = 0)
        self.bind(self.sExponent,
                  'Set spot light exponent')

        # MRM: Add frustum controls

        self.lightNotebook.setnaturalsize()
        self.lightNotebook.pack(expand = 1, fill = BOTH)

        lightFrame.pack(expand = 1, fill = BOTH)
コード例 #5
0
    def createEnvPage(self, envPage):
        bkgrdFrame = Frame(envPage, borderwidth = 2, relief = 'sunken')

        Label(bkgrdFrame, text = 'Background',
              font=('MSSansSerif', 14, 'bold')).pack(expand = 0)

        self.backgroundColor = VectorWidgets.ColorEntry(
            bkgrdFrame, text = 'Background Color')
        self.backgroundColor['command'] = self.setBackgroundColorVec
        self.backgroundColor.pack(fill = X, expand = 0)
        self.bind(self.backgroundColor, 'Set background color')
        bkgrdFrame.pack(fill = BOTH, expand = 0)

        drFrame = Frame(envPage, borderwidth = 2, relief = 'sunken')
        Label(drFrame, text = 'Display Region',
              font=('MSSansSerif', 14, 'bold')).pack(expand = 0)

        nameList = map(lambda x: 'Display Region ' + `x`,
                       range(len(base.direct.drList)))
        self.drMenu = Pmw.ComboBox(
            drFrame, labelpos = W, label_text = 'Display Region:',
            entry_width = 20,
            selectioncommand = self.selectDisplayRegionNamed,
            scrolledlist_items = nameList)
        self.drMenu.pack(fill = X, expand = 0)
        self.bind(self.drMenu, 'Select display region to configure')

        self.nearPlane = Floater.Floater(
            drFrame,
            text = 'Near Plane',
            min = 0.01)
        self.nearPlane['command'] = self.setNear
        self.nearPlane.pack(fill = X, expand = 0)
        self.bind(self.nearPlane, 'Set near plane distance')

        self.farPlane = Floater.Floater(
            drFrame,
            text = 'Far Plane',
            min = 0.01)
        self.farPlane['command'] = self.setFar
        self.farPlane.pack(fill = X, expand = 0)
        self.bind(self.farPlane, 'Set far plane distance')

        fovFrame = Frame(drFrame)
        fovFloaterFrame = Frame(fovFrame)
        self.hFov = Slider.Slider(
            fovFloaterFrame,
            text = 'Horizontal FOV',
            min = 0.01, max = 170.0)
        self.hFov['command'] = self.setHFov
        self.hFov.pack(fill = X, expand = 0)
        self.bind(self.hFov, 'Set horizontal field of view')

        self.vFov = Slider.Slider(
            fovFloaterFrame,
            text = 'Vertical FOV',
            min = 0.01, max = 170.0)
        self.vFov['command'] = self.setVFov
        self.vFov.pack(fill = X, expand = 0)
        self.bind(self.vFov, 'Set vertical field of view')
        fovFloaterFrame.pack(side = LEFT, fill = X, expand = 1)

        frame = Frame(fovFrame)
        self.lockedFov = BooleanVar()
        self.lockedFov.set(1)
        self.lockedFovButton = Checkbutton(
            frame,
            text = 'Locked',
            anchor = 'w', justify = LEFT,
            variable = self.lockedFov)
        self.lockedFovButton.pack(fill = X, expand = 0)

        self.resetFovButton = Button(
            frame,
            text = 'Reset',
            command = self.resetFov)
        self.resetFovButton.pack(fill = X, expand = 0)
        frame.pack(side = LEFT, fill = X, expand = 0)
        fovFrame.pack(fill = X, expand = 1)

        drFrame.pack(fill = BOTH, expand = 0)

        ## Render Style ##
        toggleFrame = Frame(envPage, borderwidth = 2, relief = 'sunken')
        Label(toggleFrame, text = 'Toggle Render Style',
              font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
        self.toggleBackfaceButton = Button(
            toggleFrame,
            text = 'Backface',
            command = base.toggleBackface)
        self.toggleBackfaceButton.pack(side = LEFT, fill = X, expand = 1)

        self.toggleLightsButton = Button(
            toggleFrame,
            text = 'Lights',
            command = base.direct.lights.toggle)
        self.toggleLightsButton.pack(side = LEFT, fill = X, expand = 1)

        self.toggleTextureButton = Button(
            toggleFrame,
            text = 'Texture',
            command = base.toggleTexture)
        self.toggleTextureButton.pack(side = LEFT, fill = X, expand = 1)

        self.toggleWireframeButton = Button(
            toggleFrame,
            text = 'Wireframe',
            command = base.toggleWireframe)
        self.toggleWireframeButton.pack(fill = X, expand = 1)
        toggleFrame.pack(side = LEFT, fill = X, expand = 1)
コード例 #6
0
    def createInterface(self):
        # The interior of the toplevel panel
        interior = self.interior()
        mainFrame = Frame(interior)
        ## Creat NoteBook
        self.notebookFrame = Pmw.NoteBook(mainFrame)
        self.notebookFrame.pack(fill=BOTH, expand=1)
        sgePage = self.notebookFrame.add('Tree Graph')
        envPage = self.notebookFrame.add('World Setting')
        self.notebookFrame['raisecommand'] = self.updateInfo

        ## Tree Grapgh Page
        self.SGE = seSceneGraphExplorer.seSceneGraphExplorer(
            sgePage,
            nodePath=render,
            scrolledCanvas_hull_width=270,
            scrolledCanvas_hull_height=570)
        self.SGE.pack(fill=BOTH, expand=0)

        ## World Setting Page
        envPage = Frame(envPage)
        pageFrame = Frame(envPage)
        self.LightingVar = IntVar()
        self.LightingVar.set(self.lightEnable)
        self.LightingButton = Checkbutton(pageFrame,
                                          text='Enable Lighting',
                                          variable=self.LightingVar,
                                          command=self.toggleLights)
        self.LightingButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.CollisionVar = IntVar()
        self.CollisionVar.set(self.collision)
        self.CollisionButton = Checkbutton(pageFrame,
                                           text='Show Collision Object',
                                           variable=self.CollisionVar,
                                           command=self.showCollision)
        self.CollisionButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.ParticleVar = IntVar()
        self.ParticleVar.set(self.ParticleEnable)
        self.ParticleButton = Checkbutton(pageFrame,
                                          text='Show Particle Dummy',
                                          variable=self.ParticleVar,
                                          command=self.enableParticle)
        self.ParticleButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.baseUseDriveVar = IntVar()
        self.baseUseDriveVar.set(self.basedriveEnable)
        self.baseUseDriveButton = Checkbutton(pageFrame,
                                              text='Enable base.usedrive',
                                              variable=self.baseUseDriveVar,
                                              command=self.enablebaseUseDrive)
        self.baseUseDriveButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.backfaceVar = IntVar()
        self.backfaceVar.set(self.backface)
        self.backfaceButton = Checkbutton(pageFrame,
                                          text='Enable BackFace',
                                          variable=self.backfaceVar,
                                          command=self.toggleBackface)
        self.backfaceButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.textureVar = IntVar()
        self.textureVar.set(self.texture)
        self.textureButton = Checkbutton(pageFrame,
                                         text='Enable Texture',
                                         variable=self.textureVar,
                                         command=self.toggleTexture)
        self.textureButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.wireframeVar = IntVar()
        self.wireframeVar.set(self.wireframe)
        self.wireframeButton = Checkbutton(pageFrame,
                                           text='Enable Wireframe',
                                           variable=self.wireframeVar,
                                           command=self.toggleWireframe)
        self.wireframeButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.gridVar = IntVar()
        self.gridVar.set(self.grid)
        self.gridButton = Checkbutton(pageFrame,
                                      text='Enable Grid',
                                      variable=self.gridVar,
                                      command=self.toggleGrid)
        self.gridButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.widgetVisVar = IntVar()
        self.widgetVisVar.set(self.widgetVis)
        self.widgetVisButton = Checkbutton(pageFrame,
                                           text='Enable WidgetVisible',
                                           variable=self.widgetVisVar,
                                           command=self.togglewidgetVis)
        self.widgetVisButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.enableAutoCameraVar = IntVar()
        self.enableAutoCameraVar.set(self.enableAutoCamera)
        self.enableAutoCameraButton = Checkbutton(
            pageFrame,
            text='Enable Auto Camera Movement for Loading Objects',
            variable=self.enableAutoCameraVar,
            command=self.toggleAutoCamera)
        self.enableAutoCameraButton.pack(side=LEFT, expand=False)
        pageFrame.pack(side=TOP, fill=X, expand=True)

        pageFrame = Frame(envPage)
        self.backgroundColor = VectorWidgets.ColorEntry(pageFrame,
                                                        text='BG Color',
                                                        value=self.worldColor)
        self.backgroundColor['command'] = self.setBackgroundColorVec
        self.backgroundColor['resetValue'] = [0, 0, 0, 0]
        self.backgroundColor.pack(side=LEFT, expand=False)
        self.bind(self.backgroundColor, 'Set background color')
        pageFrame.pack(side=TOP, fill=X, expand=True)

        envPage.pack(expand=False)

        ## Set all stuff done
        self.notebookFrame.setnaturalsize()
        mainFrame.pack(fill='both', expand=1)