def onHumanChanged(self, event):
        if event.change == 'proxyChange':
            if event.proxy != 'clothes':
                return
            proxy = event.proxy_obj
            if not proxy:
                return
            foot_pose = proxy.special_pose.get("foot", None)
            if not foot_pose:
                return
            filename = getpath.thoroughFindFile(foot_pose, self.paths)
            if not os.path.isfile(filename):
                log.error("Could not find a file for special_pose foot %s, file does not exist.", filename)
                return
            if event.action == 'add':
                self.loadFootPose(filename)
            elif event.action == 'remove':
                if self.selectedFile and getpath.isSamePath(filename, self.selectedFile):
                    self.loadFootPose(None)

        if event.change == 'poseChange' and not self._setting_pose:
            if self.selectedPose:
                self.applyFootPose(self.selectedPose)
        if event.change == 'reset':
            # Update GUI after reset (if tab is currently visible)
            self._setting_pose = False
            self.loadFootPose(None)
Example #2
0
    def chooseSkeleton(self, filename):
        log.debug("Loading skeleton from %s", filename)
        self.selectedRig = filename

        if not filename:
            if self.human.skeleton:
                # Unload current skeleton
                self.human.setSkeleton(None)

            if self.skelObj:
                # Remove old skeleton mesh
                self.removeObject(self.skelObj)
                self.human.removeBoundMesh(self.skelObj.name)
                self.skelObj = None
                self.skelMesh = None
            self.boneCountLbl.setTextFormat(["Bones", ": %s"], "")
            self.descrLbl.setText("")
            self.filechooser.selectItem(None)
            return

        if getpath.isSamePath(filename, REF_RIG_PATH):
            skel = self.referenceRig.createFromPose()
        else:
            # Load skeleton definition from options
            skel = skeleton.load(filename, self.human.meshData)

            # Ensure vertex weights of skel are initialized
            skel.autoBuildWeightReferences(
                self.referenceRig
            )  # correct weights references if only (pose) references were defined
            vertexWeights = skel.getVertexWeights(
                self.referenceRig.getVertexWeights(), force_remap=False)
            log.message("Skeleton %s has %s weights per vertex.", skel.name,
                        vertexWeights.getMaxNumberVertexWeights())

            # Remap bone orientation planes from reference rig
            skel.addReferencePlanes(
                self.referenceRig
            )  # Not strictly needed for the new way in which we determine bone normals

        # Update description
        descr = skel.description
        self.descrLbl.setText(descr)
        self.boneCountLbl.setTextFormat(["Bones", ": %s"], skel.getBoneCount())

        # Assign to human
        self.human.setSkeleton(skel)

        # (Re-)draw the skeleton
        self.drawSkeleton()

        self.filechooser.selectItem(filename)
Example #3
0
    def chooseSkeleton(self, filename):
        log.debug("Loading skeleton from %s", filename)
        self.selectedRig = filename

        if self.referenceRig is None:
            log.message("Loading reference skeleton for weights remapping.")
            self.referenceRig = skeleton.load(REF_RIG_PATH, self.human.meshData)

        if not filename:
            if self.human.getSkeleton():
                # Unload current skeleton
                self.human.setSkeleton(None)

            if self.skelObj:
                # Remove old skeleton mesh
                self.removeObject(self.skelObj)
                self.human.removeBoundMesh(self.skelObj.name)
                self.skelObj = None
                self.skelMesh = None
            self.boneCountLbl.setTextFormat(["Bones",": %s"], "")
            self.descrLbl.setText("")
            self.filechooser.selectItem(None)
            return

        if getpath.isSamePath(filename, REF_RIG_PATH):
            skel = self.referenceRig.clone()
            vertexWeights = self.referenceRig.getVertexWeights()
        else:
            # Load skeleton definition from options
            skel = skeleton.load(filename, self.human.meshData)

            # Ensure vertex weights of skel are initialized
            skel.autoBuildWeightReferences(self.referenceRig)  # correct weights references if only (pose) references were defined
            vertexWeights = skel.getVertexWeights(self.referenceRig.getVertexWeights())
            log.message("Skeleton %s has %s weights per vertex.", skel.name, vertexWeights.getMaxNumberVertexWeights())

            # Remap bone orientation planes from reference rig
            skel.addReferencePlanes(self.referenceRig)

        # Update description
        descr = skel.description
        self.descrLbl.setText(descr)
        self.boneCountLbl.setTextFormat(["Bones",": %s"], skel.getBoneCount())

        # (Re-)draw the skeleton (before setting skeleton on human so it is automatically re-posed)
        self.drawSkeleton(skel)

        # Assign to human
        self.human.setSkeleton(skel)

        self.filechooser.selectItem(filename)
    def chooseSkeleton(self, filename):
        log.debug("Loading skeleton from %s", filename)
        self.selectedRig = filename

        if not filename:
            if self.human.skeleton:
                # Unload current skeleton
                self.human.setSkeleton(None)

            if self.skelObj:
                # Remove old skeleton mesh
                self.removeObject(self.skelObj)
                self.human.removeBoundMesh(self.skelObj.name)
                self.skelObj = None
                self.skelMesh = None
            self.boneCountLbl.setTextFormat(["Bones",": %s"], "")
            self.descrLbl.setText("")
            self.filechooser.selectItem(None)
            return

        if getpath.isSamePath(filename, REF_RIG_PATH):
            skel = self.referenceRig.createFromPose()
        else:
            # Load skeleton definition from options
            skel = skeleton.load(filename, self.human.meshData)

            # Ensure vertex weights of skel are initialized
            skel.autoBuildWeightReferences(self.referenceRig)  # correct weights references if only (pose) references were defined
            vertexWeights = skel.getVertexWeights(self.referenceRig.getVertexWeights(), force_remap=False)
            log.message("Skeleton %s has %s weights per vertex.", skel.name, vertexWeights.getMaxNumberVertexWeights())

            # Remap bone orientation planes from reference rig
            skel.addReferencePlanes(self.referenceRig)  # Not strictly needed for the new way in which we determine bone normals

        # Update description
        descr = skel.description
        self.descrLbl.setText(descr)
        self.boneCountLbl.setTextFormat(["Bones",": %s"], skel.getBoneCount())

        # Assign to human
        self.human.setSkeleton(skel)

        # (Re-)draw the skeleton
        self.drawSkeleton()

        self.filechooser.selectItem(filename)