コード例 #1
0
    def onShow(self, event):
        gui3d.TaskView.onShow(self, event)

        # Disable smoothing in skeleton library
        self.oldSmoothValue = self.human.isSubdivided()
        self.human.setSubdivided(False)

        self.oldHumanTransp = self.human.meshData.transparentPrimitives
        self.setHumanTransparency(True)
        self.human.meshData.setPickable(False)
        mh.updatePickingBuffer()

        if self.skelObj:
            self.skelObj.show()

        if not self.jointsObj:
            self.drawJointHelpers()

        self.filechooser.refresh()

        # Make sure skeleton is updated when human has changed
        self.human.getSkeleton()

        # Re-draw joints positions if human has changed
        if self.humanChanged:
            self.drawJointHelpers()
            self.humanChanged = False
コード例 #2
0
    def drawJointHelpers(self):
        """
        Draw the joint helpers from the basemesh that define the default or
        reference rig.
        """
        if self.jointsObj:
            self.removeObject(self.jointsObj)
            self.jointsObj = None
            self.jointsMesh = None
            self.selectedJoint = None

        jointGroupNames = [group.name for group in self.human.meshData.faceGroups if group.name.startswith("joint-")]
        # TODO maybe define a getter for this list in the skeleton module
        jointPositions = []
        for groupName in jointGroupNames:
            jointPositions.append(skeleton.getHumanJointPosition(self.human.meshData, groupName))

        self.jointsMesh = skeleton_drawing.meshFromJoints(jointPositions, jointGroupNames)
        self.jointsMesh.priority = 100
        self.jointsMesh.setPickable(True)
        mh.updatePickingBuffer()
        self.jointsObj = self.addObject( gui3d.Object(self.human.getPosition(), self.jointsMesh) )
        self.jointsObj.setRotation(self.human.getRotation())

        color = np.asarray([255, 255, 0, 255], dtype=np.uint8)
        self.jointsMesh.color[:] = color[None,:]
        self.jointsMesh.markCoords(colr=True)
        self.jointsMesh.sync_color()

        '''
コード例 #3
0
    def drawSkeleton(self, skel):
        if self.skelObj:
            # Remove old skeleton mesh
            gui3d.app.removeObject(self.skelObj)
            self.skelObj = None
            self.skelMesh = None
            self.selectedBone = None

        # Create a mesh from the skeleton in rest pose
        skel.setToRestPose() # Make sure skeleton is in rest pose when constructing the skeleton mesh
        self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism")
        self.skelMesh.priority = 100
        self.skelMesh.setPickable(True)
        mh.updatePickingBuffer()
        self.skelObj = gui3d.app.addObject(gui3d.Object(self.human.getPosition(), self.skelMesh) )
        self.skelObj.setRotation(self.human.getRotation())

        # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton
        # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives
        # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone)
        mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh)
        self.human.animated.addMesh(self.skelMesh, mapping)

        # Store a reference to the skeleton mesh object for other plugins
        self.human._skeleton.object = self.skelObj

        '''
コード例 #4
0
    def onHide(self, event):

        gui3d.TaskView.onHide(self, event)
        gui3d.app.selectedHuman.mesh.setShadeless(0)
        self.backgroundImage.mesh.setPickable(False)
        gui3d.app.selectedHuman.mesh.setPickable(True)
        mh.updatePickingBuffer()
コード例 #5
0
    def onShow(self, event):

        gui3d.TaskView.onShow(self, event)
        self.backgroundImage.mesh.setPickable(self.dragButton.selected)
        gui3d.app.selectedHuman.mesh.setPickable(not self.dragButton.selected)
        mh.updatePickingBuffer()
        gui3d.app.selectedHuman.mesh.setShadeless(1 if self.shadelessButton.selected else 0)
        self.opacitySlider.setValue(self.backgroundChooserView.opacity)
        self.foregroundTggl.setChecked(self.backgroundChooserView.isShowBgInFront())
コード例 #6
0
    def drawJointHelpers(self):
        """
        Draw the joint helpers from the basemesh that define the default or
        reference rig.
        """
        if self.jointsObj:
            self.removeObject(self.jointsObj)
            self.jointsObj = None
            self.jointsMesh = None
            self.selectedJoint = None

        jointGroupNames = [group.name for group in self.human.meshData.faceGroups if group.name.startswith("joint-")]
        # TODO maybe define a getter for this list in the skeleton module
        jointPositions = []
        for groupName in jointGroupNames:
            jointPositions.append(skeleton.getHumanJointPosition(self.human.meshData, groupName))

        self.jointsMesh = skeleton_drawing.meshFromJoints(jointPositions, jointGroupNames)
        self.jointsMesh.priority = 100
        self.jointsMesh.setPickable(True)
        mh.updatePickingBuffer()
        self.jointsObj = self.addObject( gui3d.Object(self.human.getPosition(), self.jointsMesh) )
        self.jointsObj.setRotation(self.human.getRotation())

        color = np.asarray([255, 255, 0, 255], dtype=np.uint8)
        self.jointsMesh.color[:] = color[None,:]
        self.jointsMesh.markCoords(colr=True)
        self.jointsMesh.sync_color()

        # Add event listeners to joint mesh for joint highlighting
        @self.jointsObj.mhEvent
        def onMouseEntered(event):
            """
            Event fired when mouse hovers over a joint mesh facegroup
            """
            gui3d.TaskView.onMouseEntered(self, event)

            # Highlight joint
            self.selectedJoint = event.group
            setColorForFaceGroup(self.jointsMesh, self.selectedJoint.name, [216, 110, 39, 255])
            gui3d.app.statusPersist(event.group.name)
            gui3d.app.redraw()

        @self.jointsObj.mhEvent
        def onMouseExited(event):
            """
            Event fired when mouse hovers off of a joint mesh facegroup
            """
            gui3d.TaskView.onMouseExited(self, event)
            
            # Disable highlight on joint
            if self.selectedJoint:
                setColorForFaceGroup(self.jointsMesh, self.selectedJoint.name, [255,255,0,255])
                gui3d.app.statusPersist('')
                gui3d.app.redraw()
コード例 #7
0
    def drawSkeleton(self, skel):
        if self.skelObj:
            # Remove old skeleton mesh
            gui3d.app.removeObject(self.skelObj)
            self.skelObj = None
            self.skelMesh = None
            self.selectedBone = None

        # Create a mesh from the skeleton in rest pose
        skel.setToRestPose() # Make sure skeleton is in rest pose when constructing the skeleton mesh
        self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism")
        self.skelMesh.priority = 100
        self.skelMesh.setPickable(True)
        mh.updatePickingBuffer()
        self.skelObj = gui3d.app.addObject(gui3d.Object(self.human.getPosition(), self.skelMesh) )
        self.skelObj.setRotation(self.human.getRotation())

        # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton
        # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives
        # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone)
        mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh)
        self.human.animated.addMesh(self.skelMesh, mapping)

        # Store a reference to the skeleton mesh object for other plugins
        self.human._skeleton.object = self.skelObj

        # Add event listeners to skeleton mesh for bone highlighting
        @self.skelObj.mhEvent
        def onMouseEntered(event):
            """
            Event fired when mouse hovers over a skeleton mesh facegroup
            """
            gui3d.TaskView.onMouseEntered(self, event)
            try:
                self.removeBoneHighlights()
            except:
                pass
            self.highlightBone(event.group.name)

        @self.skelObj.mhEvent
        def onMouseExited(event):
            """
            Event fired when mouse hovers off of a skeleton mesh facegroup
            """
            gui3d.TaskView.onMouseExited(self, event)
            try:
                self.removeBoneHighlights()
            except:
                pass

            # Highlight bone selected in bone explorer again
            for rdio in self.boneSelector:
                if rdio.selected:
                    self.clearBoneWeights()
                    self.highlightBone(str(rdio.text()))
コード例 #8
0
    def onShow(self, event):
        gui3d.TaskView.onShow(self, event)

        if not self.human.getSkeleton():
            gui3d.app.statusPersist("No skeleton selected. Please select a skeleton rig from the Skeleton library first.")
            return

        # Detect when skeleton (rig type) has changed
        if self.human.getSkeleton() and self.human.getSkeleton().name != self.lastSkeleton:
            # Remove cached animation tracks (as they are mapped to a specific skeleton)
            self.human.animated.removeAnimations()
            self.anim = None
            self.animTrack = None
            # NOTE that animation tracks only need to be removed when the rig
            # structure changes, not when only joint positions are translated
            # a bit because of a change to the human model.

        self.lastSkeleton = self.human.getSkeleton().name

        # Disable smoothing in animation library
        self.oldSmoothValue = self.human.isSubdivided()
        self.human.setSubdivided(False)

        self.oldHumanTransp = self.human.meshData.transparentPrimitives
        self.human.meshData.setPickable(False)
        mh.updatePickingBuffer()

        self.skelObj = self.human.getSkeleton().object
        if self.skelObj:
            self.skelMesh = self.skelObj.mesh

            if self.showSkeletonTggl.selected:
                self.skelObj.show()
                # Show skeleton through human 
                self.setHumanTransparency(True)
            else:
                self.skelObj.hide()
        else:
            self.skelMesh = None

        self.setupProxySkinning()

        self.frameSlider.setValue(0)

        if self.anim:
            # Start playing previously highlighted animation
            self.highlightAnimation(self.anim)
            self.startPlayback()

        self.printAnimationsStatus()
コード例 #9
0
    def onHide(self, event):
        gui3d.TaskView.onHide(self, event)

        if self.skelObj:
            self.skelObj.hide()
        self.setHumanTransparency(False)
        self.human.meshData.setPickable(True)
        mh.updatePickingBuffer()
        try:
            self.removeBoneHighlights()
        except:
            pass

        # Reset smooth setting
        self.human.setSubdivided(self.oldSmoothValue)
コード例 #10
0
ファイル: mhmain.py プロジェクト: Iffar/makehuman_datagen
    def loadFinish(self):

        self.selectedHuman.applyAllTargets(gui3d.app.progress)
        self.selectedHuman.callEvent('onChanged', events3d.HumanEvent(self.selectedHuman, 'reset'))

        self.prompt('Warning', 'This is an alpha release, which means that there are still bugs present and features missing. Use at your own risk.',
            'OK', helpId='alphaWarning')
        # self.splash.hide()

        gui3d.app.setFilenameCaption("Untitled")
        self.setFileModified(False)

        #printtree(self)

        mh.updatePickingBuffer();
        self.redraw()
コード例 #11
0
    def onHide(self, event):
        gui3d.TaskView.onHide(self, event)

        self.setToRestPose()
        self.setHumanTransparency(False)
        self.human.meshData.setPickable(True)
        mh.updatePickingBuffer()

        if self.skelObj:
            self.skelObj.hide()

        self.skelObj = None
        self.skelMesh = None

        # Restore possible hidden proxies (clothes and hair)
        for (name, obj) in self.human.clothesObjs.items():
            obj.show()
        if self.human.hairObj:
            self.human.hairObj.show()

        # Reset smooth setting
        self.human.setSubdivided(self.oldSmoothValue)
コード例 #12
0
    def drawJointHelpers(self):
        """
        Draw the joint helpers from the basemesh that define the default or
        reference rig.
        """
        if self.jointsObj:
            self.removeObject(self.jointsObj)
            self.jointsObj = None
            self.jointsMesh = None
            self.selectedJoint = None

        jointGroupNames = [
            group.name for group in self.human.meshData.faceGroups
            if group.name.startswith("joint-")
        ]
        # TODO maybe define a getter for this list in the skeleton module
        jointPositions = []
        for groupName in jointGroupNames:
            jointPositions.append(
                skeleton.getHumanJointPosition(self.human.meshData, groupName))

        self.jointsMesh = skeleton_drawing.meshFromJoints(
            jointPositions, jointGroupNames)
        self.jointsMesh.priority = 100
        self.jointsMesh.setPickable(True)
        mh.updatePickingBuffer()
        self.jointsObj = self.addObject(
            gui3d.Object(self.human.getPosition(), self.jointsMesh))
        self.jointsObj.setRotation(self.human.getRotation())

        color = np.asarray([255, 255, 0, 255], dtype=np.uint8)
        self.jointsMesh.color[:] = color[None, :]
        self.jointsMesh.markCoords(colr=True)
        self.jointsMesh.sync_color()

        # Add event listeners to joint mesh for joint highlighting
        @self.jointsObj.mhEvent
        def onMouseEntered(event):
            """
            Event fired when mouse hovers over a joint mesh facegroup
            """
            gui3d.TaskView.onMouseEntered(self, event)

            # Highlight joint
            self.selectedJoint = event.group
            setColorForFaceGroup(self.jointsMesh, self.selectedJoint.name,
                                 [216, 110, 39, 255])
            gui3d.app.statusPersist(event.group.name)
            gui3d.app.redraw()

        @self.jointsObj.mhEvent
        def onMouseExited(event):
            """
            Event fired when mouse hovers off of a joint mesh facegroup
            """
            gui3d.TaskView.onMouseExited(self, event)

            # Disable highlight on joint
            if self.selectedJoint:
                setColorForFaceGroup(self.jointsMesh, self.selectedJoint.name,
                                     [255, 255, 0, 255])
                gui3d.app.statusPersist('')
                gui3d.app.redraw()
コード例 #13
0
 def onClicked(event):
     self.backgroundImage.mesh.setPickable(self.dragButton.selected)
     gui3d.app.selectedHuman.mesh.setPickable(
         not self.dragButton.selected)
     mh.updatePickingBuffer()
コード例 #14
0
 def onClicked(event):
     self.backgroundImage.mesh.setPickable(self.dragButton.selected)
     mh.updatePickingBuffer()