コード例 #1
0
    def createPlaybackControl(self):
        self.playbackBox = self.addRightWidget(gui.GroupBox('Playback'))
        self.frameSlider = self.playbackBox.addWidget(
            gui.Slider(value=0, min=0, max=1, label='Frame: %d'))
        # TODO make slider use time instead of frames?
        @self.frameSlider.mhEvent
        def onChanging(value):
            self.updateAnimation(value)

        @self.frameSlider.mhEvent
        def onChange(value):
            self.updateAnimation(value)

        self.playPauseBtn = self.playbackBox.addWidget(gui.Button("Play"))

        @self.playPauseBtn.mhEvent
        def onClicked(value):
            if self.playPauseBtn.text() == 'Play':
                self.startPlayback()
            else:
                self.stopPlayback()

        self.animateInPlaceTggl = self.playbackBox.addWidget(
            gui.ToggleButton("In-place animation"))

        @self.animateInPlaceTggl.mhEvent
        def onClicked(event):
            self.human.animated.setAnimateInPlace(
                self.animateInPlaceTggl.selected)
            self.updateAnimation(self.currFrame)

        self.animateInPlaceTggl.setSelected(True)

        self.restPoseBtn = self.playbackBox.addWidget(
            gui.Button("Set to Rest Pose"))

        @self.restPoseBtn.mhEvent
        def onClicked(value):
            self.setToRestPose()

        self.interpolateTggl = self.playbackBox.addWidget(
            gui.ToggleButton("Interpolate animation"))

        @self.interpolateTggl.mhEvent
        def onClicked(event):
            self.interpolate = self.interpolateTggl.selected

        self.interpolateTggl.setSelected(True)
コード例 #2
0
    def createPlaybackControl(self):
        if self.anim:
            maxFrames = self.anim.nFrames
            if maxFrames < 1:
                maxFrames = 1
        else:
            maxFrames = 1

        if self.playbackBox:
            self.frameSlider.setMin(0)
            self.frameSlider.setMax(maxFrames)
            self.currFrame = 0
            self.frameSlider.setValue(0)
            return

        self.playbackBox = self.addRightWidget(gui.GroupBox('BVH playback'))
        self.frameSlider = self.playbackBox.addWidget(gui.Slider(value = 0, min = 0, max = maxFrames, label = 'Frame: %d', vertical=False, valueConverter=None, image=None, scale=100000))
        @self.frameSlider.mhEvent
        def onChanging(value):
            self.updateAnimation(value)
        @self.frameSlider.mhEvent
        def onChange(value):
            self.updateAnimation(value)
            
        self.playPause = self.playbackBox.addWidget(gui.Button("Play"))
        @self.playPause.mhEvent
        def onClicked(value):
            if self.playPause.text() == 'Play':
                self.startPlayback()
            else:
                self.stopPlayback()

        self.animateInPlaceTggl = self.playbackBox.addWidget(gui.ToggleButton("In-place animation"))
        @self.animateInPlaceTggl.mhEvent
        def onClicked(event):
            if not self.animated:
                return
            if self.animated:
                self.animated.setAnimateInPlace(self.animateInPlaceTggl.selected)
            if self.bvhAnimated:
                self.bvhAnimated.setAnimateInPlace(self.animateInPlaceTggl.selected)
            self.updateAnimation(self.currFrame)
        self.animateInPlaceTggl.setSelected(True)

        self.restPoseBtn = self.playbackBox.addWidget(gui.Button("Set to Rest Pose"))
        @self.restPoseBtn.mhEvent
        def onClicked(value):
            self.setToRestPose()
コード例 #3
0
    def __init__(self, category):
        # Setup GUI elements
        gui3d.TaskView.__init__(self, category, 'Actions')

        box = self.addLeftWidget(gui.GroupBox('Export'))
        self.rigButton = box.addWidget(FileSelectView('Load BVH'))
        self.rigButton.setDirectory(DATA_PATH)
        self.rigButton.setFilter('Biovision Motion Hierarchy (*.bvh)')
        self.exportButton = box.addWidget(gui.Button('Export animation'))
        self.exportAllButton = box.addWidget(gui.Button('Export all'))

        self.window = None
        @self.rigButton.mhEvent
        def onFilesSelected(filenames):
            if not self.skel:
                self.loadRig()
            loadFirst = (self.animationList.rowCount() == 0)
            for filename in filenames:
                if filename not in self.selectedBVHs:
                    item = self.animationList.addItem(os.path.splitext(os.path.basename(filename))[0])
                    item.filename = filename
                    self.selectedBVHs.add(filename)
            if loadFirst:
                self.loadAnimation(filenames[0])

        @self.exportButton.mhEvent
        def onClicked(event):
            self.export()

        @self.exportAllButton.mhEvent
        def onClicked(event):
            self.exportAll()

        self.human = gui3d.app.selectedHuman
        self.humanChanged = False
        self.humanTransparent = False

        self.selectedBVHs = set()

        self.skel = None
        self.animated = None

        self.bvhAnimated = None

        self.skelMesh = None
        self.skelObj = None

        self.bvhMesh = None
        self.bvhObj = None

        self.timer = None
        self.currFrame = 0
        self.anim = None

        self.bvhAnim = None

        self.oldHumanTransp = self.human.meshData.transparentPrimitives

        optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.kinectCamTggle = optionsBox.addWidget(gui.ToggleButton("Kinect camera"))
        self.kinectCamTggle.setSelected(True)

        self.useMHCamTggl = optionsBox.addWidget(gui.ToggleButton("Use camera pos"))
        self.useMHCamTggl.setSelected(False)

        mesh = BackPlane(20, 20, centered=True)
        self.bgPlane = self.addObject(gui3d.Object([0, 0, 0], mesh))
        mesh.setColor([255, 255, 255, 255])
        mesh.setShadeless(True)
        mesh.priority = -90

        mesh = GroundPlane(20, 20, centered=True)
        self.groundPlane = self.addObject(gui3d.Object([0, 0, 0], mesh))
        mesh.setColor([0, 0, 0, 255])
        mesh.setShadeless(True)
        mesh.priority = -90

        yOffset = self.getFeetOnGroundOffset()
        self.groundposSlider = optionsBox.addWidget(gui.Slider(value=int(yOffset), min=-125,max=125, label = "Ground Pos: %d"))
        self.groundposVal = int(yOffset)
        self.groundPlane.mesh.move(0,yOffset,0)

        @self.groundposSlider.mhEvent
        def onChanging(value):
            val = value - self.groundposVal
            self.groundPlane.mesh.move(0,val,0)
            self.groundposVal = self.groundposVal + val
        @self.groundposSlider.mhEvent
        def onChange(value):
            val = value - self.groundposVal
            self.groundPlane.mesh.move(0,val,0)
            self.groundposVal = self.groundposVal + val

        self.backposSlider = optionsBox.addWidget(gui.Slider(value=-9, min=-125,max=125, label = "Back Pos: %d"))
        self.backposVal = -9

        @self.backposSlider.mhEvent
        def onChanging(value):
            val = value - self.backposVal
            self.bgPlane.mesh.move(0,0,val)
            self.backposVal = self.backposVal + val
        @self.backposSlider.mhEvent
        def onChange(value):
            val = value - self.backposVal
            self.bgPlane.mesh.move(0,0,val)
            self.backposVal = self.backposVal + val

        self.bgPlane.mesh.move(0,0,self.backposVal)
        
        displayBox = self.addRightWidget(gui.GroupBox('Display'))
        self.showHumanTggl = displayBox.addWidget(gui.ToggleButton("Show human"))
        @self.showHumanTggl.mhEvent
        def onClicked(event):
            if self.showHumanTggl.selected:
                self.human.show()
            else:
                self.human.hide()
        self.showHumanTggl.setSelected(True)

        self.showMHXRigTggl = displayBox.addWidget(gui.ToggleButton("Show human Rig"))
        @self.showMHXRigTggl.mhEvent
        def onClicked(event):
            self.setShowRig(self.showMHXRigTggl.selected)
        self.showMHXRigTggl.setSelected(True)
 
        self.showBVHRigTggl = displayBox.addWidget(gui.ToggleButton("Show BVH Rig"))
        @self.showBVHRigTggl.mhEvent
        def onClicked(event):
            self.setShowBVHRig(self.showBVHRigTggl.selected)
        self.showBVHRigTggl.setSelected(False)

        self.imageExported = False

        self.playbackBox = None
        self.playPause = None

        self.createPlaybackControl()
        animationListBox = self.addRightWidget(gui.GroupBox('BVHs'))
        self.animationList = animationListBox.addWidget(gui.ListView())
        self.animationList.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.MinimumExpanding)
        self.animationList.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        @self.animationList.mhEvent
        def onClicked(item):
            self.loadAnimation(item.filename)
        self.removeAnimBtn = animationListBox.addWidget(gui.Button('Remove selected'))
        @self.removeAnimBtn.mhEvent
        def onClicked(item):
            print "remove clicked"
            if len(self.animationList.selectedItems()) > 0:
                print "taking action"
                item = self.animationList.selectedItems()[0]
                self.removeAnimation(item.filename)
コード例 #4
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Skeleton')

        self.systemRigs = os.path.join('data', 'rigs')
        self.userRigs = os.path.join(mh.getPath(''), 'data', 'rigs')
        self.rigPaths = [self.userRigs, self.systemRigs]
        if not os.path.exists(self.userRigs):
            os.makedirs(self.userRigs)
        self.extension = "rig"

        self.human = gui3d.app.selectedHuman
        self.human._skeleton = None
        self.human.animated = None
        # Attach getter to human to access the skeleton, that takes care of deferred
        # updating when the skeleton should change
        import types
        self.human.getSkeleton = types.MethodType(_getSkeleton, self.human,
                                                  self.human.__class__)
        self.human.getVertexWeights = types.MethodType(_getVertexWeights,
                                                       self.human,
                                                       self.human.__class__)

        self.oldSmoothValue = False

        self.humanChanged = False  # Used for determining when joints need to be redrawn

        self.skelMesh = None
        self.skelObj = None

        self.jointsMesh = None
        self.jointsObj = None

        self.selectedBone = None
        self.selectedJoint = None

        self.oldHumanTransp = self.human.meshData.transparentPrimitives

        self.filechooser = self.addRightWidget(
            fc.ListFileChooser(self.rigPaths, self.extension, 'Skeleton rig'))
        self.addLeftWidget(self.filechooser.createSortBox())

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            if self.human.getSkeleton():
                oldSkelFile = self.human.getSkeleton().file
            else:
                oldSkelFile = None
            gui3d.app.do(
                SkeletonAction("Change skeleton", self, oldSkelFile, filename))

        @self.filechooser.mhEvent
        def onRefresh(fileChooser):
            noSkelPath = os.path.join(self.rigPaths[0], 'clear.rig')
            fileChooser.addItem(noSkelPath, 'No skeleton', None)
            if not self.human.getSkeleton():
                self.filechooser.selectItem(noSkelPath)

        self.filechooser.refresh()

        displayBox = self.addLeftWidget(gui.GroupBox('Display'))
        self.showHumanTggl = displayBox.addWidget(
            gui.ToggleButton("Show human"))

        @self.showHumanTggl.mhEvent
        def onClicked(event):
            if self.showHumanTggl.selected:
                self.human.show()
            else:
                self.human.hide()

        self.showHumanTggl.setSelected(True)

        self.showJointsTggl = displayBox.addWidget(
            gui.ToggleButton("Show joints"))

        @self.showJointsTggl.mhEvent
        def onClicked(event):
            if not self.jointsObj:
                return
            if self.showJointsTggl.selected:
                self.jointsObj.show()
            else:
                self.jointsObj.hide()

        self.showJointsTggl.setSelected(True)

        self.showWeightsTggl = displayBox.addWidget(
            gui.ToggleButton("Show bone weights"))

        @self.showWeightsTggl.mhEvent
        def onClicked(event):
            if self.showWeightsTggl.selected:
                # Highlight bone selected in bone explorer again
                for rdio in self.boneSelector:
                    if rdio.selected:
                        self.highlightBone(str(rdio.text()))
            else:
                self.clearBoneWeights()

        self.showWeightsTggl.setSelected(True)

        self.boneBox = self.addLeftWidget(gui.GroupBox('Bones'))
        self.boneSelector = []

        self.infoBox = self.addRightWidget(gui.GroupBox('Rig info'))
        self.boneCountLbl = self.infoBox.addWidget(gui.TextView('Bones: '))
        self.descrLbl = self.infoBox.addWidget(gui.TextView('Description: '))
        self.descrLbl.setSizePolicy(gui.QtGui.QSizePolicy.Ignored,
                                    gui.QtGui.QSizePolicy.Preferred)
        self.descrLbl.setWordWrap(True)

        self.rigDescriptions = {
            "soft1":
            "Soft skinned rig. Simple version of the MHX reference rig containing only its deforming bones.",
            "xonotic":
            "Rig compatible with the open-source game Xonotic.",
            "second_life":
            "Rig compatible with Second Life.",
            "game":
            "A simple rig with a minimal amount of bones. Has limited expressivity in hands and face.",
            "humanik":
            "Rig compatible with the HumanIK software.",
            "rigid":
            "Same as soft1 a simple version of the MHX reference rig, but with rigid weighting.",
        }
コード例 #5
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Background')

        self.backgroundsFolder = os.path.join(mh.getPath(''), 'backgrounds')
        if not os.path.exists(self.backgroundsFolder):
            os.makedirs(self.backgroundsFolder)

        self.backgroundsFolders = [
            os.path.join('data', 'backgrounds'), self.backgroundsFolder
        ]
        self.extensions = ['bmp', 'png', 'tif', 'tiff', 'jpg', 'jpeg', 'clear']

        self.texture = mh.Texture()

        self.sides = {
            'front': [0, 0, 0],
            'back': [0, 180, 0],
            'left': [0, 90, 0],
            'right': [0, -90, 0],
            'top': [90, 0, 0],
            'bottom': [-90, 0, 0],
            'other': None
        }

        self.filenames = {}  # Stores (filename, aspect)
        self.transformations = {}  # Stores ((posX,posY), scaleY)
        for side in self.sides.keys():
            self.filenames[side] = None
            self.transformations[side] = [(0.0, 0.0), 1.0]

        mesh = geometry3d.RectangleMesh(20, 20, centered=True)
        self.backgroundImage = gui3d.app.addObject(
            gui3d.Object([0, 0, 1], mesh, visible=False))
        self.backgroundImage.mesh.setCameraProjection(0)  # Set to model camera
        self.opacity = 100
        mesh.setColor([255, 255, 255, self.opacity])
        mesh.setPickable(False)
        mesh.setShadeless(True)
        mesh.setDepthless(True)
        mesh.priority = -90

        self.backgroundImageToggle = gui.Action('background',
                                                'Background',
                                                self.toggleBackground,
                                                toggle=True)
        gui3d.app.main_toolbar.addAction(self.backgroundImageToggle)
        gui3d.app.actions.background = self.backgroundImageToggle

        #self.filechooser = self.addTopWidget(fc.FileChooser(self.backgroundsFolders, self.extensions, None))
        #self.addLeftWidget(self.filechooser.sortBox)
        self.filechooser = self.addRightWidget(
            fc.IconListFileChooser(self.backgroundsFolders, self.extensions,
                                   None, None, 'Background'))
        self.filechooser.setIconSize(50, 50)
        self.addLeftWidget(self.filechooser.createSortBox())

        self.backgroundBox = self.addLeftWidget(gui.GroupBox('Side'))
        self.bgSettingsBox = self.addLeftWidget(
            gui.GroupBox('Background settings'))

        self.radioButtonGroup = []
        for side in [
                'front', 'back', 'left', 'right', 'top', 'bottom', 'other'
        ]:
            radioBtn = self.backgroundBox.addWidget(
                gui.RadioButton(self.radioButtonGroup,
                                label=side.capitalize(),
                                selected=len(self.radioButtonGroup) == 0))
            radioBtn.side = side

        self.opacitySlider = self.bgSettingsBox.addWidget(
            gui.Slider(value=self.opacity, min=0, max=255,
                       label="Opacity: %d"))
        self.foregroundTggl = self.bgSettingsBox.addWidget(
            gui.ToggleButton("Show in foreground"))

        @self.opacitySlider.mhEvent
        def onChanging(value):
            self.backgroundImage.mesh.setColor([255, 255, 255, value])

        @self.opacitySlider.mhEvent
        def onChange(value):
            self.opacity = value
            self.backgroundImage.mesh.setColor([255, 255, 255, value])

        @self.foregroundTggl.mhEvent
        def onClicked(value):
            self.setShowBgInFront(self.foregroundTggl.selected)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            side = self.getSelectedSideCheckbox()

            if os.path.splitext(filename)[1] == ".clear":
                filename = None

            if self.filenames[side]:
                oldBg = self.filenames[side][0]
            else:
                oldBg = None
            gui3d.app.do(
                BackgroundAction("Change background", self, side, oldBg,
                                 filename))

            if self.sides[side]:
                gui3d.app.selectedHuman.setRotation(self.sides[side])
            mh.redraw()
コード例 #6
0
    def __init__(self, category, backgroundChooserView):

        self.backgroundImage = backgroundChooserView.backgroundImage
        self.texture = backgroundChooserView.texture

        self.backgroundChooserView = backgroundChooserView

        gui3d.TaskView.__init__(self, category, 'Projection')

        self.projectionBox = self.addLeftWidget(gui.GroupBox('Projection'))

        self.backgroundBox = self.addLeftWidget(
            gui.GroupBox('Background settings'))

        # sliders
        self.opacitySlider = self.backgroundBox.addWidget(
            gui.Slider(value=backgroundChooserView.opacity,
                       min=0,
                       max=255,
                       label="Opacity: %d"))
        self.foregroundTggl = self.backgroundBox.addWidget(
            gui.ToggleButton("Show in foreground"))

        @self.opacitySlider.mhEvent
        def onChanging(value):
            self.backgroundImage.mesh.setColor([255, 255, 255, value])

        @self.opacitySlider.mhEvent
        def onChange(value):
            backgroundChooserView.opacity = value
            self.backgroundImage.mesh.setColor([255, 255, 255, value])

        @self.foregroundTggl.mhEvent
        def onClicked(value):
            self.backgroundChooserView.setShowBgInFront(
                self.foregroundTggl.selected)

        @self.backgroundImage.mhEvent
        def onMouseDragged(event):
            if event.button in [mh.Buttons.LEFT_MASK, mh.Buttons.MIDDLE_MASK]:
                dx = float(event.dx) / 30.0
                dy = float(-event.dy) / 30.0
                self.backgroundChooserView.moveBackground(dx, dy)
            elif event.button == mh.Buttons.RIGHT_MASK:
                scale = self.backgroundChooserView.getBackgroundScale()
                scale += float(event.dy) / 100.0

                self.backgroundChooserView.setBackgroundScale(scale)

        self.dragButton = self.backgroundBox.addWidget(
            gui.ToggleButton('Move && Resize'))

        @self.dragButton.mhEvent
        def onClicked(event):
            self.backgroundImage.mesh.setPickable(self.dragButton.selected)
            gui3d.app.selectedHuman.mesh.setPickable(
                not self.dragButton.selected)
            mh.updatePickingBuffer()

        self.chooseBGButton = self.backgroundBox.addWidget(
            gui.Button('Choose background'))

        @self.chooseBGButton.mhEvent
        def onClicked(event):
            mh.changeTask('Textures', 'Background')

        self.projectBackgroundButton = self.projectionBox.addWidget(
            gui.Button('Project background'))

        @self.projectBackgroundButton.mhEvent
        def onClicked(event):
            self.projectBackground()

        self.projectLightingButton = self.projectionBox.addWidget(
            gui.Button('Project lighting'))

        @self.projectLightingButton.mhEvent
        def onClicked(event):
            self.projectLighting()

        self.projectUVButton = self.projectionBox.addWidget(
            gui.Button('Project UV topology'))

        @self.projectUVButton.mhEvent
        def onClicked(event):
            self.projectUV()

        displayBox = self.addRightWidget(gui.GroupBox('Display settings'))
        self.shadelessButton = displayBox.addWidget(
            gui.ToggleButton('Shadeless'))

        @self.shadelessButton.mhEvent
        def onClicked(event):
            gui3d.app.selectedHuman.mesh.setShadeless(
                1 if self.shadelessButton.selected else 0)
コード例 #7
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'BVH')

        self.BVH = bvh.BVH()

        #self.systemAnims = os.path.join('data', 'animations')
        #self.userAnims = os.path.join(mh.getPath(''), 'data', 'animations')
        #self.animPaths = [self.userAnims, self.systemAnims]
        #if not os.path.exists(self.userAnims):
        #    os.makedirs(self.userAnims)
        #self.extension = "mhanim"

        self.skelObj = None  # indicates skeleton object attached
        self.lastSkeleton = None

        self.human = gui3d.app.selectedHuman
        self.oldHumanTransp = self.human.meshData.transparentPrimitives

        displayBox = self.addLeftWidget(gui.GroupBox('Display'))

        self.showHumanTggl = displayBox.addWidget(
            gui.ToggleButton("Show human"))

        @self.showHumanTggl.mhEvent
        def onClicked(event):
            if self.showHumanTggl.selected:
                self.human.show()
            else:
                self.human.hide()

        self.showHumanTggl.setSelected(True)

        self.showSkeletonTggl = displayBox.addWidget(
            gui.ToggleButton("Show skeleton"))

        @self.showSkeletonTggl.mhEvent
        def onClicked(event):
            if not self.skelObj:
                return
            if self.showSkeletonTggl.selected:
                self.skelObj.show()
                self.setHumanTransparency(True)
            else:
                self.skelObj.hide()
                self.setHumanTransparency(False)

        self.showSkeletonTggl.setSelected(True)

        self.skinProxiesTggl = displayBox.addWidget(
            gui.ToggleButton("Skin clothes and hair"))

        @self.skinProxiesTggl.mhEvent
        def onClicked(event):
            self.setupProxySkinning()

        self.skinProxiesTggl.setSelected(False)

        pathBox = self.addLeftWidget(gui.GroupBox('BVH  path'))
        self.path = pathBox.addWidget(gui.TextEdit('/'), 0, 0, 1, 2)
        self.file = pathBox.addWidget(gui.BrowseButton('open'), 1, 0, 1, 1)
        self.file.setLabel("Select BVH")

        @self.path.mhEvent
        def onChange(value):
            print '[BVHAnimLibrary: onChange] Path value changed:' + value

        @self.file.mhEvent
        def onClicked(file):
            #if os.path.isdir(path):
            print '[BVHAnimLibrary: onClicked] File value changed:' + file
            self.path.setText(file)
            if os.path.isfile(file):
                self.BVH = bvh.load(file)
                #self.BVH.fromFile(file)
                print '[BVHAnimLibrary: onClicked] Loaded BVH file'
コード例 #8
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Example')

        box = self.addLeftWidget(gui.GroupBox('Example'))
        
        # We add a button to the current task
        # A button just fires an event when it is clicked, if a selected texture is specified,
        # it is used while the mouse is down on the button

        self.aButton = box.addWidget(gui.Button('Button'))
        
        self.pushed = 0
        self.aButtonLabel = box.addWidget(gui.TextView('Pushed 0 times'))

        @self.aButton.mhEvent
        def onClicked(event):
            self.pushed += 1
            self.aButtonLabel.setText('Pushed %d times' % self.pushed)

        # We add a toggle button to the current task
        # A toggle button fires an event when it is clicked but retains its selected state after the mouse is up,
        # if a selected texture is specified, it is used to show whether the button is toggled

        self.aToggleButton = box.addWidget(gui.ToggleButton('ToggleButton'))

        self.aToggleButtonLabel = box.addWidget(gui.TextView('Not selected'))

        @self.aToggleButton.mhEvent
        def onClicked(event):
            if self.aToggleButton.selected:
                self.aToggleButtonLabel.setText('Selected')
            else:
                self.aToggleButtonLabel.setText('Not selected')

        # Next we will add some radio buttons. For this we need a group, since only one in the group can be selected
        # A radio button fires an event when it is clicked but retains its selected state after the mouse is up, and deselects all other buttons in the group
        # If a selected texture is specified, it is used to show whether the button is selected

        self.aRadioButtonGroup = []

         # We make the first one selected
        self.aRadioButton1 = box.addWidget(gui.RadioButton(self.aRadioButtonGroup, 'RadioButton1', selected=True))
        self.aRadioButton2 = box.addWidget(gui.RadioButton(self.aRadioButtonGroup, 'RadioButton2'))

        self.aRadioButtonLabel = box.addWidget(gui.TextView('Button 1 is selected'))

        @self.aRadioButton1.mhEvent
        def onClicked(event):
            self.aRadioButtonLabel.setText('Button 1 is selected')

        @self.aRadioButton2.mhEvent
        def onClicked(event):
            self.aRadioButtonLabel.setText('Button 2 is selected')

        # When the slider is dragged and released, an onChange event is fired
        # By default a slider goes from 0.0 to 1.0, and the initial position will be 0.0 unless specified

        # We want the slider to start from the middle
        self.aSlider = box.addWidget(gui.Slider(value=0.5, label='Slider %.2f'))

        self.aSliderLabel = box.addWidget(gui.TextView('Value is 0.5'))

        @self.aSlider.mhEvent
        def onChange(value):
            self.aSliderLabel.setText('Value is %f' % value)
            self.aProgressBar.setProgress(value, 1)

        # we also create a progressbar, which is updated as the slider moves

        self.aProgressBar = box.addWidget(gui.ProgressBar())
        self.aProgressBar.setProgress(0.5, 0)
        
        # A text edit

        self.aTextEdit = box.addWidget(gui.TextEdit(text='Some text'))
        
        self.meshSlider = box.addWidget(gui.Slider(value=0.5, label='Mesh distort %0.2f'))
        
        self.meshStored = False
        @self.meshSlider.mhEvent
        def onChanging(value):
            human = gui3d.app.selectedHuman
            if self.meshStored:
                human.restoreMesh()
            else:
                human.storeMesh()
                self.meshStored = True
            human.mesh.coord += human.mesh.vnorm * value
            human.mesh.markCoords(coor=True)
            human.mesh.update()
    
        @self.meshSlider.mhEvent
        def onChange(value):
            human = gui3d.app.selectedHuman
            human.applyAllTargets()
            self.meshStored = False
            human.mesh.coord += human.mesh.vnorm * value
            human.mesh.markCoords(coor=True)
            human.mesh.update()
コード例 #9
0
    def __init__(self, category):

        self.systemClothes = os.path.join('data', 'clothes')
        self.userClothes = os.path.join(mh.getPath(''), 'data', 'clothes')

        self.taggedClothes = {}
        self.clothesList = []
        self.highlightedPiece = None

        self.cache = {}
        self.meshCache = {}
        
        gui3d.TaskView.__init__(self, category, 'Clothes')
        if not os.path.exists(self.userClothes):
            os.makedirs(self.userClothes)
        self.paths = [self.systemClothes, self.userClothes]
        #self.filechooser = self.addTopWidget(fc.FileChooser(self.paths, 'mhclo', 'thumb', 'data/clothes/notfound.thumb'))
        #self.filechooser = self.addRightWidget(fc.ListFileChooser(self.paths, 'mhclo', 'Clothes', True))
        self.filechooser = self.addRightWidget(fc.IconListFileChooser(self.paths, 'mhclo', 'thumb', 'data/clothes/notfound.thumb', 'Clothes', True))
        self.filechooser.setIconSize(50,50)
        self.filechooser.setFileLoadHandler(fc.MhcloFileLoader())
        self.optionsBox = self.addLeftWidget(gui.GroupBox('Options'))
        self.addLeftWidget(self.filechooser.createSortBox())
        self.addLeftWidget(self.filechooser.createTagFilter())
        #self.update = self.filechooser.sortBox.addWidget(gui.Button('Check for updates'))
        self.mediaSync = None

        @self.filechooser.mhEvent
        def onFileHighlighted(filename):
            if self.highlightedPiece:
                if self.highlightedPiece and self.highlightedPiece.file == filename:
                    return
                if not self.highlightedPiece.toggleEnabled:
                    # Remove previously highlighted clothes
                    self.setClothes(gui3d.app.selectedHuman, self.highlightedPiece.file)

            if filename in self.cache and self.cache[filename].toggleEnabled:
                self.highlightedPiece = self.cache[filename]
                return

            # Add highlighted clothes
            self.setClothes(gui3d.app.selectedHuman, filename)
            self.highlightedPiece = self.cache[filename]

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            gui3d.app.do(ClothesAction("Add clothing piece",
                gui3d.app.selectedHuman,
                self,
                filename,
                True))

        @self.filechooser.mhEvent
        def onFileDeselected(filename):
            gui3d.app.do(ClothesAction("Remove clothing piece",
                gui3d.app.selectedHuman,
                self,
                filename,
                False))

        #@self.update.mhEvent
        #def onClicked(event):
        #    self.syncMedia()

        self.originalHumanMask = gui3d.app.selectedHuman.meshData.getFaceMask().copy()
        self.faceHidingTggl = self.optionsBox.addWidget(gui.ToggleButton("Hide faces under clothes"))
        @self.faceHidingTggl.mhEvent
        def onClicked(event):
            self.updateFaceMasks(self.faceHidingTggl.selected)
        self.faceHidingTggl.setSelected(True)
コード例 #10
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Animations')

        self.systemAnims = os.path.join('data', 'animations')
        self.userAnims = os.path.join(mh.getPath(''), 'data', 'animations')
        self.animPaths = [self.userAnims, self.systemAnims]
        if not os.path.exists(self.userAnims):
            os.makedirs(self.userAnims)
        self.extension = "mhanim"

        # Test config param
        self.perFramePlayback = False  # Set to false to use time for playback

        self.interpolate = True  # Only useful when using time for playback

        self.skelMesh = None
        self.skelObj = None

        self.bvhRig = None
        self.animations = []
        self.anim = None
        self.animTrack = None
        self.collections = {}

        self.tags = set()

        self.oldSmoothValue = False

        self.lastSkeleton = None
        self.human = gui3d.app.selectedHuman
        self.oldHumanTransp = self.human.meshData.transparentPrimitives

        # Stores all selected animations and makes them available globally
        self.human.animations = []

        if not hasattr(self.human, 'animated'):
            self.human.animated = None

        self.timer = None
        self.currFrame = 0

        displayBox = self.addLeftWidget(gui.GroupBox('Display'))
        self.playbackBox = None
        self.frameSlider = None
        self.playPauseBtn = None
        self.animateInPlaceTggl = None

        self.showHumanTggl = displayBox.addWidget(
            gui.ToggleButton("Show human"))

        @self.showHumanTggl.mhEvent
        def onClicked(event):
            if self.showHumanTggl.selected:
                self.human.show()
            else:
                self.human.hide()

        self.showHumanTggl.setSelected(True)

        self.showSkeletonTggl = displayBox.addWidget(
            gui.ToggleButton("Show skeleton"))

        @self.showSkeletonTggl.mhEvent
        def onClicked(event):
            if not self.skelObj:
                return
            if self.showSkeletonTggl.selected:
                self.skelObj.show()
                self.setHumanTransparency(True)
            else:
                self.skelObj.hide()
                self.setHumanTransparency(False)

        self.showSkeletonTggl.setSelected(True)

        self.skinProxiesTggl = displayBox.addWidget(
            gui.ToggleButton("Skin clothes and hair"))

        @self.skinProxiesTggl.mhEvent
        def onClicked(event):
            self.setupProxySkinning()

        self.skinProxiesTggl.setSelected(False)

        self.createPlaybackControl()

        self.filechooser = self.addRightWidget(
            filechooser.ListFileChooser(self.animPaths, self.extension,
                                        'Animations', True))

        self.filechooser.setFileLoadHandler(MhAnimLoader(self))
        self.addLeftWidget(self.filechooser.createSortBox())
        self.addLeftWidget(self.filechooser.createTagFilter())
        #self.update = self.filechooser.sortBox.addWidget(gui.Button('Check for updates'))
        self.mediaSync = None

        @self.filechooser.mhEvent
        def onFileHighlighted(animId):
            collectionUuid, animName = animId
            self.anim = self.getAnimation(collectionUuid, animName)
            self.highlightAnimation(self.anim)
            self.startPlayback()

        @self.filechooser.mhEvent
        def onFileSelected(animId):
            collectionUuid, animName = animId
            anim = self.getAnimation(collectionUuid, animName)
            gui3d.app.do(AnimationAction("Add animation", self, True, anim))

        @self.filechooser.mhEvent
        def onFileDeselected(animId):
            collectionUuid, animName = animId
            anim = self.getAnimation(collectionUuid, animName)
            gui3d.app.do(AnimationAction("Remove animation", self, False,
                                         anim))