Exemplo n.º 1
0
    def onShow(self, event):
        gui3d.TaskView.onShow(self, event)
        if gui3d.app.settings.get('cameraAutoZoom', True):
            gui3d.app.setGlobalCamera()

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

        self.oldHumanTransp = self.human.material.transparent
        self.oldHumanShader = self.human.material.shader
        self.human.material.shader = mh.getSysDataPath('shaders/glsl/xray')
        self.setHumanTransparency(True)
        self.human.meshData.setPickable(False)

        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
        mh.redraw()
Exemplo n.º 2
0
    def onShow(self, event):
        gui3d.TaskView.onShow(self, event)
        if gui3d.app.settings.get('cameraAutoZoom', True):
            gui3d.app.setGlobalCamera()

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

        self.oldHumanMat = self.human.material.clone()
        self.oldPxyMats = dict()
        xray_mat = material.fromFile(mh.getSysDataPath('materials/xray.mhmat'))
        self.human.material = xray_mat
        for pxy, obj in self.human.getProxiesAndObjects():
            self.oldPxyMats[pxy.uuid] = obj.material.clone()
            obj.material = xray_mat

        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
        mh.redraw()
Exemplo n.º 3
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

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

        self.jointsMesh = skeleton_drawing.meshFromJoints(jointPositions, jointGroupNames)
        self.jointsMesh.priority = 100
        self.jointsMesh.setPickable(False)
        self.jointsObj = self.addObject( gui3d.Object(self.jointsMesh, self.human.getPosition()) )
        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()

        mh.redraw()
Exemplo n.º 4
0
    def onShow(self, event):
        gui3d.TaskView.onShow(self, event)
        if gui3d.app.settings.get('cameraAutoZoom', True):
            gui3d.app.setGlobalCamera()

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

        self.oldHumanMat = self.human.material.clone()
        self.oldPxyMats = dict()
        xray_mat = material.fromFile(mh.getSysDataPath('materials/xray.mhmat'))
        self.human.material = xray_mat
        for pxy in self.human.getProxies(includeHumanProxy=False):
            obj = pxy.object
            self.oldPxyMats[pxy.uuid] = obj.material.clone()
            obj.material = xray_mat

        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
        mh.redraw()
    def onHide(self, event):

        gui3d.TaskView.onHide(self, event)
        self.human.setShadeless(0)

        self.human.mesh.configureShading(diffuse = self.oldDiffuseShaderSetting)
        mh.redraw()
    def projectBackground(self):
        if not self.backgroundChooserView.isBackgroundShowing():
            gui3d.app.prompt("Warning", "You need to load a background for the current view before you can project it.", "OK")
            return

        mesh = self.human.getSeedMesh()

        # for all quads, project vertex to screen
        # if one vertex falls in bg rect, project screen quad into uv quad
        # warp image region into texture
        ((x0,y0,z0), (x1,y1,z1)) = self.backgroundImage.mesh.calcBBox()
        camera = mh.cameras[self.backgroundImage.mesh.cameraMode]
        x0, y0, _ = camera.convertToScreen(x0, y0, z0, self.backgroundImage.mesh)
        x1, y1, _ = camera.convertToScreen(x1, y1, z1, self.backgroundImage.mesh)
        leftTop = (x0, y1)
        rightBottom = (x1, y0)

        dstImg = projection.mapImage(self.backgroundImage, mesh, leftTop, rightBottom)
        texPath = mh.getPath('data/skins/projection.png')
        if os.path.isfile(texPath):
            oldImg = mh.Image(texPath)
        else:
            oldImg = None

        gui3d.app.do(ProjectionAction("Change projected background texture",
                self.human.getTexture(),
                texPath,
                oldImg,
                dstImg))
        log.debug("Enabling shadeless rendering on body")
        self.shadelessButton.setChecked(True)
        self.human.setShadeless(1)
        mh.redraw()
Exemplo n.º 7
0
    def drawSkeleton(self, skel):
        if self.skelObj:
            # Remove old skeleton mesh
            self.removeObject(self.skelObj)
            self.human.removeBoundMesh(self.skelObj.name)
            self.skelObj = None
            self.skelMesh = None
            self.selectedBone = None

        if not skel:
            return

        # 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.name = 'SkeletonMesh-poseLibrary'
        self.skelMesh.priority = 100
        self.skelMesh.setPickable(False)
        self.skelObj = self.addObject(
            gui3d.Object(self.skelMesh, self.human.getPosition()))
        self.skelObj.setShadeless(0)
        self.skelObj.setSolid(0)
        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.addBoundMesh(self.skelMesh, mapping)

        # Store a reference to the skeleton mesh object for other plugins
        self.human.getSkeleton().object = self.skelObj
        mh.redraw()
Exemplo n.º 8
0
 def applyTarget(self, targetName, power):
     log.message("SCRIPT: applyTarget(" + targetName + ", " + str(power) +
                 ")")
     self.human.setDetail(
         mh.getSysDataPath("targets/" + targetName + ".target"), power)
     self.human.applyAllTargets()
     mh.redraw()
Exemplo n.º 9
0
    def projectBackground(self):
        if not self.backgroundChooserView.isBackgroundShowing():
            gui3d.app.prompt("Warning", "You need to load a background for the current view before you can project it.", "OK")
            return

        mesh = self.human.getSeedMesh()

        # for all quads, project vertex to screen
        # if one vertex falls in bg rect, project screen quad into uv quad
        # warp image region into texture
        ((x0,y0,z0), (x1,y1,z1)) = self.backgroundImage.mesh.calcBBox()
        camera = mh.cameras[self.backgroundImage.mesh.cameraMode]
        x0, y0, _ = camera.convertToScreen(x0, y0, z0, self.backgroundImage.mesh)
        x1, y1, _ = camera.convertToScreen(x1, y1, z1, self.backgroundImage.mesh)
        leftTop = (x0, y1)
        rightBottom = (x1, y0)

        dstImg = projection.mapImage(self.backgroundImage, mesh, leftTop, rightBottom)
        texPath = mh.getPath('data/skins/projection.png')
        if os.path.isfile(texPath):
            oldImg = mh.Image(texPath)
        else:
            oldImg = None

        gui3d.app.do(ProjectionAction("Change projected background texture",
                self.human.getTexture(),
                texPath,
                oldImg,
                dstImg))
        log.debug("Enabling shadeless rendering on body")
        self.shadelessButton.setChecked(True)
        self.human.setShadeless(1)
        mh.redraw()
Exemplo n.º 10
0
    def drawSkeleton(self):
        self._unloadSkeletonMesh()

        skel = self.human.getSkeleton()
        if not skel:
            return

        # Create a mesh from the user-selected skeleton in its current pose (so we use the base skeleton for actually posing)
        self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism")
        self.skelMesh.name = self.skelMesh.name + '-skeletonDebug'
        self.skelMesh.priority = 100
        self.skelMesh.setPickable(False)
        self.skelObj = self.addObject(
            gui3d.Object(self.skelMesh, self.human.getPosition()))
        self.skelObj.setShadeless(0)
        self.skelObj.setSolid(0)
        self.skelObj.setRotation(self.human.getRotation())
        self.skelMesh.setVisibility(self.showBonesTggl.selected)

        self.axisMesh = skeleton_drawing.meshFromSkeleton(skel, "axis")
        self.axisMesh.name = self.axisMesh.name + '-axis-skeletonDebug'
        self.axisMesh.priority = 100
        self.axisMesh.setPickable(False)
        self.axisObj = self.addObject(
            gui3d.Object(self.axisMesh, self.human.getPosition()))
        self.axisObj.material.ambientColor = [0.2, 0.2, 0.2]
        self.axisObj.material.configureShading(vertexColors=True)
        self.axisObj.material.depthless = True
        self.axisObj.setRotation(self.human.getRotation())
        self.axisObj.setVisibility(self.showAxisTggl.selected)

        self.drawPlanes(skel)

        mh.redraw()
    def onMouseMoved(self, event):
        human = gui3d.app.selectedHuman

        groups = []

        if self.micro:
            log.debug("%s", event.group)
            groups.append(event.group)
            if human.symmetryModeEnabled:
                sg = human.getSymmetryGroup(event.group)
                if sg:
                    groups.append(sg)
        else:
            part = human.getPartNameForGroupName(event.group.name)
            for g in human.mesh.faceGroups:
                if part in g.name:
                    groups.append(g)
                    if human.symmetryModeEnabled:
                        sg = human.getSymmetryGroup(g)
                        if sg:
                            groups.append(sg)

        for g in self.selectedGroups:
            if g not in groups:
                g.setColor([255, 255, 255, 255])

        for g in groups:
            if g not in self.selectedGroups:
                g.setColor([0, 255, 0, 255])

        self.selectedGroups = groups
        mh.redraw()
Exemplo n.º 12
0
    def onShow(self, event):
        gui3d.TaskView.onShow(self, event)
        self.human.setShadeless(1 if self.shadelessButton.selected else 0)

        self.oldDiffuseShaderSetting = self.human.material.shaderConfig['diffuse']
        self.human.mesh.configureShading(diffuse = True)
        mh.redraw()
Exemplo n.º 13
0
def updateModelingParameters(dictOfParameterNameAndValue):
    human = gui3d.app.selectedHuman
    for key, value in iter(dictOfParameterNameAndValue.items()):
        modifier = human.getModifier(key)
        modifier.setValue(value)
    human.applyAllTargets()
    mh.redraw()
Exemplo n.º 14
0
    def drawSkeleton(self):
        self._unloadSkeletonMesh()

        skel = self.human.getSkeleton()
        if not skel:
            return

        # 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.name = self.skelMesh.name + '-skeletonDebug'
        self.skelMesh.priority = 100
        self.skelMesh.setPickable(False)
        self.skelObj = self.addObject(
            gui3d.Object(self.skelMesh, self.human.getPosition()))
        self.skelObj.setShadeless(0)
        self.skelObj.setSolid(0)
        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.addBoundMesh(self.skelMesh, mapping)

        self.human.refreshPose()  # Pose drawn skeleton if human is posed
        mh.redraw()
    def drawSkeleton(self):
        self._unloadSkeletonMesh()

        skel = self.human.getSkeleton()
        if not skel:
            return

        # Create a mesh from the user-selected skeleton in its current pose (so we use the base skeleton for actually posing)
        self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism")
        self.skelMesh.name = self.skelMesh.name + '-skeletonDebug'
        self.skelMesh.priority = 100
        self.skelMesh.setPickable(False)
        self.skelObj = self.addObject(gui3d.Object(self.skelMesh, self.human.getPosition()) )
        self.skelObj.setShadeless(0)
        self.skelObj.setSolid(0)
        self.skelObj.setRotation(self.human.getRotation())
        self.skelMesh.setVisibility(self.showBonesTggl.selected)

        self.axisMesh = skeleton_drawing.meshFromSkeleton(skel, "axis")
        self.axisMesh.name = self.axisMesh.name + '-axis-skeletonDebug'
        self.axisMesh.priority = 100
        self.axisMesh.setPickable(False)
        self.axisObj = self.addObject(gui3d.Object(self.axisMesh, self.human.getPosition()) )
        self.axisObj.material.ambientColor = [0.2, 0.2, 0.2]
        self.axisObj.material.configureShading(vertexColors=True)
        self.axisObj.material.depthless = True
        self.axisObj.setRotation(self.human.getRotation())
        self.axisObj.setVisibility(self.showAxisTggl.selected)

        self.drawPlanes(skel)

        mh.redraw()
Exemplo n.º 16
0
 def setAge(self, age):
     log.message("SCRIPT: setAge(" + str(age) + ")")
     self.human.setAge(age)
     humanmodifier.MacroModifier('macrodetails', None, 'Age', 0.0,
                                 1.0).setValue(gui3d.app.selectedHuman, age)
     self.human.applyAllTargets()
     mh.redraw()
Exemplo n.º 17
0
    def drawSkeleton(self, skel):
        if self.skelObj:
            # Remove old skeleton mesh
            self.removeObject(self.skelObj)
            self.human.removeBoundMesh(self.skelObj.name)
            self.skelObj = None
            self.skelMesh = None

        if not skel:
            return

        # 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(False)
        self.skelObj = self.addObject(gui3d.Object(self.skelMesh, self.human.getPosition()) )
        self.skelObj.setShadeless(0)
        self.skelObj.setSolid(0)
        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.addBoundMesh(self.skelMesh, mapping)

        mh.redraw()
Exemplo n.º 18
0
        def onFileSelected(filename):

            if self.bgImageFrontRadioButton.selected:
                self.filenames["front"] = filename
            elif self.bgImageBackRadioButton.selected:
                self.filenames["back"] = filename
            elif self.bgImageLeftRadioButton.selected:
                self.filenames["left"] = filename
            elif self.bgImageRightRadioButton.selected:
                self.filenames["right"] = filename
            elif self.bgImageTopRadioButton.selected:
                self.filenames["top"] = filename
            elif self.bgImageBottomRadioButton.selected:
                self.filenames["bottom"] = filename

            self.texture.loadImage(mh.Image(os.path.join(self.backgroundsFolder, filename)))

            bg = self.backgroundImage
            bg.mesh.setTexture(os.path.join(self.backgroundsFolder, filename))

            aspect = 1.0 * self.texture.width / self.texture.height
            bg.setPosition([-aspect, -1, 0])
            bg.mesh.resize(2.0 * aspect, 2.0)

            # Switch to orthogonal view
            gui3d.app.modelCamera.switchToOrtho()

            bg.show()
            self.backgroundImageToggle.setChecked(True)

            mh.changeTask("Modelling", "Background")
            mh.redraw()
Exemplo n.º 19
0
    def onShow(self, event):
        gui3d.TaskView.onShow(self, event)
        self.human.setShadeless(1 if self.shadelessButton.selected else 0)

        self.oldDiffuseShaderSetting = self.human.material.shaderConfig['diffuse']
        self.human.mesh.configureShading(diffuse = True)
        mh.redraw()
    def onMouseMoved(self, event):
        human = gui3d.app.selectedHuman

        groups = []

        if self.micro:
            log.debug("%s", event.group)
            groups.append(event.group)
            if human.symmetryModeEnabled:
                sg = human.getSymmetryGroup(event.group)
                if sg:
                    groups.append(sg)
        else:
            part = human.getPartNameForGroupName(event.group.name)
            for g in human.mesh.faceGroups:
                if part in g.name:
                    groups.append(g)
                    if human.symmetryModeEnabled:
                        sg = human.getSymmetryGroup(g)
                        if sg:
                            groups.append(sg)

        for g in self.selectedGroups:
            if g not in groups:
                g.setColor([255, 255, 255, 255])

        for g in groups:
            if g not in self.selectedGroups:
                g.setColor([0, 255, 0, 255])

        self.selectedGroups = groups
        mh.redraw()
Exemplo n.º 21
0
    def onHide(self, event):

        gui3d.TaskView.onHide(self, event)
        self.human.setShadeless(0)

        self.human.mesh.configureShading(diffuse = self.oldDiffuseShaderSetting)
        mh.redraw()
Exemplo n.º 22
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

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

        self.jointsMesh = skeleton_drawing.meshFromJoints(jointPositions, jointGroupNames)
        self.jointsMesh.priority = 100
        self.jointsMesh.setPickable(False)
        self.jointsObj = self.addObject( gui3d.Object(self.jointsMesh, self.human.getPosition()) )
        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()

        mh.redraw()
Exemplo n.º 23
0
 def applyTarget(self,targetName,power, assumeThreading = False):
     self.human.setDetail(mh.getSysDataPath("targets/" + targetName + ".target"), power)
     if assumeThreading:
         self._threadSafeApplyAllTargets()
     else:
         self.human.applyAllTargets()
     mh.redraw()
Exemplo n.º 24
0
 def updateModelingParameters(self, dictOfParameterNameAndValue):
     log.message("SCRIPT: updateModelingParameters("+str(dictOfParameterNameAndValue)+")")
     for key, value in dictOfParameterNameAndValue.iteritems():
         modifier = self.human.getModifier(key)
         modifier.setValue(value)
     self.human.applyAllTargets()
     mh.redraw()
Exemplo n.º 25
0
 def setWeight(self, weight):
     log.message("SCRIPT: setWeight(" + str(weight) + ")")
     self.human.setWeight(weight)
     humanmodifier.MacroModifier('macrodetails', 'universal', 'Weight', 0.0,
                                 1.0).setValue(gui3d.app.selectedHuman,
                                               weight)
     self.human.applyAllTargets()
     mh.redraw()
Exemplo n.º 26
0
def updateModelingParameters(dictOfParameterNameAndValue):
    human = gui3d.app.selectedHuman
    for key, value in dictOfParameterNameAndValue.iteritems():
        modifier = human.getModifier(key)
        modifier.setValue(value)
    human.applyAllTargets()
    mhmain.SymmetryAction(human, 1).do()
    mh.redraw()
Exemplo n.º 27
0
 def applyModifier(self, modifierName, power, assumeThreading = False):
     modifier = self.human.getModifier(modifierName)
     modifier.setValue(power)
     if assumeThreading:
         self._threadSafeApplyAllTargets()
     else:
         self.human.applyAllTargets()
     mh.redraw()
Exemplo n.º 28
0
 def setShowBgInFront(self, enabled):
     if enabled:
         priority = 100
     else:
         priority = -90
     for obj in self.planeMeshes.values():
         obj.mesh.priority = priority
     mh.redraw()
Exemplo n.º 29
0
 def setShowBgInFront(self, enabled):
     if enabled:
         priority = 100
     else:
         priority = -90
     for obj in self.planeMeshes.values():
         obj.mesh.priority = priority
     mh.redraw()
Exemplo n.º 30
0
def updateModelingParameters(dictOfParameterNameAndValue):
    human = gui3d.app.selectedHuman
    log.message("SCRIPT: updateModelingParameters("+str(dictOfParameterNameAndValue)+")")
    for key, value in dictOfParameterNameAndValue.iteritems():
        modifier = human.getModifier(key)
        modifier.setValue(value)
    human.applyAllTargets()
    mh.redraw()
Exemplo n.º 31
0
 def toggleBackground(self):
     if not self.backgroundImageToggle.isChecked():
         self.backgroundImage.hide()
         mh.redraw()
     elif self.backgroundImage.hasTexture():
         self.backgroundImage.show()
         mh.redraw()
     else:
         mh.changeTask("Library", "Background")
Exemplo n.º 32
0
    def onShow(self, event):

        gui3d.TaskView.onShow(self, event)
        self.filechooser.setPaths([self.fileentry.directory])
        self.filechooser.setFocus()

        # HACK: otherwise the toolbar background disappears for some weird reason

        mh.redraw()
Exemplo n.º 33
0
    def onHide(self, event):
        gui3d.TaskView.onHide(self, event)

        self.human.material = self.oldHumanMat
        for pxy in self.human.getProxies(includeHumanProxy=False):
            if pxy.uuid in self.oldPxyMats:
                pxy.object.material = self.oldPxyMats[pxy.uuid]

        mh.redraw()
Exemplo n.º 34
0
    def onHide(self, event):
        gui3d.TaskView.onHide(self, event)

        self.human.material = self.oldHumanMat
        for pxy in self.human.getProxies(includeHumanProxy=False):
            if pxy.uuid in self.oldPxyMats:
                pxy.object.material = self.oldPxyMats[pxy.uuid]

        mh.redraw()
Exemplo n.º 35
0
    def refresh(self, keepSelections=True):
        self.clearList()

        files = set(self.sort.sort(self.sortBy, list(self.search())))
        self.loadHandler.refresh(files)

        self.applyTagFilter()

        mh.redraw()
        self.callEvent('onRefresh', self)
 def makeImage(self,rot):
     try:
         self.human.setRotation(rot)
         mh.redraw()
         ret = mh.grabScreen(0, 0, G.windowWidth, G.windowHeight).data
         self.human.setRotation([0, 0, 0])
         mh.redraw()
         return ret
     except Exception as e:
         return None
Exemplo n.º 37
0
    def refresh(self, keepSelections=True):
        self.clearList()

        files = self.sort.sort(self.sortBy, list(self.search()))
        self.loadHandler.refresh(files)

        self.applyTagFilter()

        mh.redraw()
        self.callEvent('onRefresh', self)
Exemplo n.º 38
0
    def onShow(self, event):

        # When the task gets shown, set the focus to the file chooser

        gui3d.app.selectedHuman.hide()
        gui3d.TaskView.onShow(self, event)
        self.filechooser.setFocus()

        # HACK: otherwise the toolbar background disappears for some weird reason

        mh.redraw()
Exemplo n.º 39
0
    def onShow(self, event):

        # When the task gets shown, set the focus to the file chooser

        gui3d.app.selectedHuman.hide()
        gui3d.TaskView.onShow(self, event)
        self.filechooser.setFocus()

        # HACK: otherwise the toolbar background disappears for some weird reason

        mh.redraw()
Exemplo n.º 40
0
    def onHide(self, event):
        gui3d.TaskView.onHide(self, event)

        self.human.material = self.human._backUpMaterial.clone()
        self.human._backUpMaterial = None
        for pxy in self.human.getProxies(includeHumanProxy=False):
            if pxy._backUpMaterial:
                pxy.object.material = pxy._backUpMaterial
                pxy._backUpMaterial = None

        mh.redraw()
Exemplo n.º 41
0
 def setBackgroundEnabled(self, enable):
     if enable:
         if self.isBackgroundSet():
             self.setBackgroundImage(self.getCurrentSide())
             self.backgroundImageToggle.setChecked(True)
             mh.redraw()
         else:
             gui3d.app.prompt('Background', 'No background image is set.\nTo show a background, choose an image from the Background tab\nin Settings.', 'Ok', None, None, None, 'backgroundChooseInfo')
     else: # Disable
         self.backgroundImage.hide()
         self.backgroundImageToggle.setChecked(False)
         mh.redraw()
Exemplo n.º 42
0
 def setBackgroundEnabled(self, enable):
     if enable:
         if self.isBackgroundSet():
             self.setBackgroundImage(self.getCurrentSide())
             self.backgroundImageToggle.setChecked(True)
             mh.redraw()
         else:
             gui3d.app.prompt('Background', 'No background image is set.\nTo show a background, choose an image from the Background tab\nin Settings.', 'Ok', None, None, None, 'backgroundChooseInfo')
     else: # Disable
         self.backgroundImage.hide()
         self.backgroundImageToggle.setChecked(False)
         mh.redraw()
 def setBackgroundEnabled(self, enable):
     if enable:
         if self.isBackgroundSet():
             self.setBackgroundImage(self.getCurrentSide())
             self.backgroundImageToggle.setChecked(True)
             mh.redraw()
         else:
             mh.changeTask('Textures', 'Background')
     else:  # Disable
         self.backgroundImage.hide()
         self.backgroundImageToggle.setChecked(False)
         mh.redraw()
Exemplo n.º 44
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.redraw()

        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()
 def setBackgroundEnabled(self, enable):
     if enable:
         if self.isBackgroundSet():
             self.setBackgroundImage(self.getCurrentSide())
             self.backgroundImageToggle.setChecked(True)
             mh.redraw()
         else:
             mh.changeTask('Textures', 'Background')
     else: # Disable
         self.backgroundImage.hide()
         self.backgroundImageToggle.setChecked(False)
         mh.redraw()
Exemplo n.º 46
0
    def symmetrize(self, direction='r'):
        """
        This method applies either left to right or right to left symmetry to
        the currently selected body parts.


        Parameters
        ----------

        direction:
            *string*. A string indicating whether to apply left to right
            symmetry (\"r\") or right to left symmetry (\"l\").

        """

        if direction == 'l':
            prefix1 = 'l-'
            prefix2 = 'r-'
        else:
            prefix1 = 'r-'
            prefix2 = 'l-'

        # Remove current values

        for target in list(self.targetsDetailStack.keys()):
            targetName = os.path.basename(target)

            # Reset previous targets on symm side

            if targetName[:2] == prefix2:
                targetVal = self.targetsDetailStack[target]
                algos3d.loadTranslationTarget(self.meshData, target, -targetVal, None, 1, 0)
                del self.targetsDetailStack[target]

        # Apply symm target. For horiz movement the value must be inverted

        for target in list(self.targetsDetailStack.keys()):
            targetName = os.path.basename(target)
            if targetName[:2] == prefix1:
                targetSym = os.path.join(os.path.dirname(target), prefix2 + targetName[2:])
                targetSymVal = self.targetsDetailStack[target]
                if 'trans-in' in targetSym:
                    targetSym = targetSym.replace('trans-in', 'trans-out')
                elif 'trans-out' in targetSym:
                    targetSym = targetSym.replace('trans-out', 'trans-in')
                algos3d.loadTranslationTarget(self.meshData, targetSym, targetSymVal, None, 1, 1)
                self.targetsDetailStack[targetSym] = targetSymVal

        self.updateProxyMesh()
        if self.isSubdivided():
            self.getSubdivisionMesh()

        mh.redraw()
Exemplo n.º 47
0
        def onFileSelected(filename):
            side = self.getSelectedSideCheckbox()

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

            mh.redraw()
    def onShow(self, event):
        gui3d.TaskView.onShow(self, event)

        self.modelPath = gui3d.app.currentFile.dir
        if self.modelPath is None:
            self.modelPath = gui3d.app.getSetting("loaddir")

        self.fileentry.directory = self.modelPath
        self.filechooser.setPaths(self.modelPath)
        self.filechooser.setFocus()

        # HACK: otherwise the toolbar background disappears for some weird reason
        mh.redraw()
Exemplo n.º 49
0
    def onHide(self, event):
        gui3d.TaskView.onHide(self, event)

        if self.skelObj:
            self.skelObj.hide()
        self.human.material = self.oldHumanMat
        for pxy in self.human.getProxies(includeHumanProxy=False):
            if pxy.uuid in self.oldPxyMats:
                pxy.object.material = self.oldPxyMats[pxy.uuid]

        # Reset smooth setting
        self.human.setSubdivided(self.oldSmoothValue)
        mh.redraw()
Exemplo n.º 50
0
        def onFileSelected(filename):
            side = self.getSelectedSideCheckbox()

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

            mh.redraw()
Exemplo n.º 51
0
    def refresh(self):
        for i in xrange(self.children.count()):
            child = self.children.itemAt(0)
            self.children.removeItem(child)
            child.widget().hide()
            child.widget().destroy()

        # Create icons
        for file in self.sort.sort(self.sortBy, list(self.search())):
            label = os.path.basename(file)
            if isinstance(self.extension, str):
                label = os.path.splitext(label)[0]
            self.children.addWidget(FileChooserRectangle(self, file, label, self.getPreview(file)))

        mh.redraw()
Exemplo n.º 52
0
    def onShow(self, event):
        self.filechooser.refresh()
        self.filechooser.selectItem(self.currentPose)
        self.drawSkeleton(self.human.getSkeleton())
        self.human.refreshPose()

        # Set X-ray material
        self.oldHumanMat = self.human.material.clone()
        self.oldPxyMats = dict()
        xray_mat = material.fromFile(mh.getSysDataPath('materials/xray.mhmat'))
        self.human.material = xray_mat
        for pxy in self.human.getProxies(includeHumanProxy=False):
            obj = pxy.object
            self.oldPxyMats[pxy.uuid] = obj.material.clone()
            obj.material = xray_mat
        mh.redraw()
Exemplo n.º 53
0
    def projectUV(self):
        dstImg = projection.mapUV()
        #dstImg.resize(128, 128)
        texPath = mh.getPath('data/skins/uvtopo.png')
        if os.path.isfile(texPath):
            oldImg = mh.Image(texPath)
        else:
            oldImg = None

        gui3d.app.do(ProjectionAction("Change projected UV map texture",
                self.human.getTexture(),
                texPath,
                oldImg,
                dstImg))
        log.debug("Enabling shadeless rendering on body")
        self.shadelessButton.setChecked(True)
        self.human.setShadeless(1)
        mh.redraw()
        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()
    def setBackgroundImage(self, side):
        if not side:
            self.backgroundImage.hide()
            return

        if self.filenames.get(side):
            (filename, aspect) = self.filenames.get(side)
        else:
            filename = aspect = None
        if filename:
            self.backgroundImage.show()
            self.backgroundImage.setPosition(gui3d.app.selectedHuman.getPosition())
            (posX, posY), scale = self.transformations[side]
            self.setBackgroundPosition(posX, posY)
            self.setBackgroundScale(scale)
            self.backgroundImage.mesh.setTexture(filename)
        else:
            self.backgroundImage.hide()
        mh.redraw()
Exemplo n.º 56
0
    def onMouseDragged(self, event):
        self.updatePosition(event.x, event.y)

        if self.start is None or self.center is None or self.depth is None:
            return

        human = gui3d.app.selectedHuman

        dist = (event.x - self.start[0]) / 100.0

        if self.norm.selected:
            coord = self.original + dist * self.weights[:,None] * self.normals
        elif self.scalex.selected:
            coord = self.scale([1, 0, 0], dist)
        elif self.scaley.selected:
            coord = self.scale([0, 1, 0], dist)
        elif self.scalez.selected:
            coord = self.scale([0, 0, 1], dist)
        elif self.rotate.selected:
            mat = matrix.rotate(-dist * 90, self.axis)
            mat = np.asarray(mat)[:3,:3]
            coor = self.original - self.center
            coor = np.dot(mat, coor.T).T
            coor += self.center
            delta = coor - self.original
            coord = self.original + self.weights[:,None] * delta
        elif self.smooth.selected:
            if self.smoothed is None:
                self.smoothed = self.makeSmoothed()
            dist = min(1.0, max(0.0, dist))
            coord = self.original + self.weights[:,None] * dist * (self.smoothed - self.original)
        else:
            x, y, z = gui3d.app.modelCamera.convertToWorld3D(event.x, event.y, self.depth, human.mesh)
            pos = np.array([x, y, z])
            delta = pos - self.center
            coord = self.original + delta[None,:] * self.weights[:,None]

        human.meshData.changeCoords(coord, self.verts)
        human.meshData.calcNormals(True, True, self.verts, self.faces)
        human.meshData.update()
        mh.redraw()
Exemplo n.º 57
0
    def setBackgroundImage(self, side):
        for obj in self.planeMeshes.values():
            obj.hide()

        if not side:
            return

        if self.filenames.get(side):
            (filename, aspect) = self.filenames.get(side)
        else:
            filename = aspect = None
        if filename:
            self.backgroundImage.show()
            self.backgroundImage.setPosition(self.human.getPosition())
            (posX, posY), scale = self.transformations[side]
            self.setBackgroundPosition(posX, posY)
            self.setBackgroundScale(scale)
            self.backgroundImage.setTexture(filename)
        else:
            self.backgroundImage.hide()
        mh.redraw()