示例#1
0
    def getRigOptions(self):
        if self.useRigify:
            from .mhx_rigify import RigifyOptions
            return RigifyOptions(self)

        rigOptions = super(MhxConfig, self).getRigOptions()
        if rigOptions is None:
            # No rig is selected from skeleton library, use custom MHX rig
            from armature.options import ArmatureOptions
            self.useAdvancedMHX = True  # TODO this is ugly, a getter modifying the state of the object, probably should set rigOptions.useAdvancedMHX
            rigOptions = ArmatureOptions()
            rigOptions.loadPreset("data/mhx/advanced.json", None)

            rigOptions.setExportOptions(
                useCustomShapes = "all",
                useConstraints = True,
                useBoneGroups = True,
                useLocks = True,
                useRotationLimits = self.useRotationLimits,
                useCorrectives = False,
                useFaceRig = self.useFaceRig,
                useExpressions = self.expressions,
                useLeftRight = False,
            )

        return rigOptions
示例#2
0
    def __init__(self, exporter):
        from armature.options import ArmatureOptions

        Config.__init__(self)
        self.selectedOptions(exporter)

        self.useRelPaths = True
        self.useNormals = True

        self.expressions = False
        #self.expressions = exporter.expressions.selected
        self.useCustomTargets = False
        #self.useCustomTargets = exporter.useCustomTargets.selected
        self.useTPose = False
        #self.useTPose = exporter.useTPose.selected

        self.yUpFaceZ = exporter.yUpFaceZ.selected
        self.yUpFaceX = exporter.yUpFaceX.selected
        self.zUpFaceNegY = exporter.zUpFaceNegY.selected
        self.zUpFaceX = exporter.zUpFaceX.selected

        self.localY = True  # exporter.localY.selected
        self.localX = False  # exporter.localX.selected
        self.localG = False  # exporter.localG.selected

        self.rigOptions = exporter.getRigOptions()
        if not self.rigOptions:
            return
            self.rigOptions = ArmatureOptions()
        self.rigOptions.setExportOptions(
            useExpressions = self.expressions,
            useTPose = self.useTPose,
        )
示例#3
0
def addRig(human, rigfile):
    if not os.path.isfile(rigfile):
        rigfile = getpath.findFile(
            rigfile,
            searchPaths=[getpath.getSysDataPath(),
                         getpath.getSysPath()])
        if not os.path.isfile(rigfile):
            #log.error("Rig file %s does not exist.", mhclofile)
            #return
            raise RuntimeError('Rig file "%s" does not exist.' % mhclofile)

    import skeleton
    from armature.options import ArmatureOptions

    armature_options = ArmatureOptions()

    descr = armature_options.loadPreset(
        rigfile, None)  # TODO update skeleton library when in gui mode
    # Load skeleton definition from options
    human._skeleton, boneWeights = skeleton.loadRig(armature_options,
                                                    human.meshData)
    human._skeleton.options = armature_options

    # TODO this should be resolved in the future
    def skeleton_getter():
        return human._skeleton

    human.getSkeleton = skeleton_getter
示例#4
0
def loadRig(options, mesh):
    """
    Initializes a skeleton from an option set
    Returns the skeleton and vertex-to-bone weights.
    Weights are of format: {"boneName": [ (vertIdx, weight), ...], ...}
    """
    from armature.options import ArmatureOptions

    #rigName = os.path.splitext(os.path.basename(filename))[0]
    if not isinstance(options, ArmatureOptions):
        options = ArmatureOptions()
    skel = Skeleton("python")
    weights = skel.fromOptions(options, mesh)
    return skel, weights
示例#5
0
    def __init__(self):
        from armature.options import ArmatureOptions

        Config.__init__(self)

        #Les 3 suivants dependent de l'export habituel, a corriger
        self.useTPose = False
        self.feetOnGround = True
        self.scale = 1.0
        self.unit = "dm"

        self.useRelPaths = False
        self.useNormals = True

        self.expressions = False
        self.useCustomTargets = False
        self.useTPose = False

        #Depend encore de l'export habituel, valeur a recuperer par defaut
        self.yUpFaceZ = False
        self.yUpFaceX = False
        self.zUpFaceNegY = True
        self.zUpFaceX = False

        self.localY = True  # exporter.localY.selected
        self.localX = False  # exporter.localX.selected
        self.localG = False  # exporter.localG.selected

        if not hasattr(G.app.selectedHuman, "getSkeleton"):
            self.rigOptions = None
        else:
            skel = G.app.selectedHuman.getSkeleton()
            if skel:
                self.rigOptions = skel.options
            else:
                self.rigOptions = None

        if not self.rigOptions:
            return
            self.rigOptions = ArmatureOptions()

        self.rigOptions.setExportOptions(
            useExpressions=self.expressions,
            useTPose=self.useTPose,
        )
示例#6
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Skeleton')
        self.debugLib = None
        self.amtOptions = ArmatureOptions()
        self.optionsSelector = None

        self.systemRigs = mh.getSysDataPath('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.selectedRig = None
        self.selectedBone = None

        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.selectedJoint = None

        self.oldHumanTransp = self.human.material.transparent
        self.oldHumanShader = self.human.material.shader

        #
        #   Display box
        #
        '''
        self.displayBox = self.addLeftWidget(gui.GroupBox('Display'))
        self.showHumanTggl = self.displayBox.addWidget(gui.CheckBox("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 = self.displayBox.addWidget(gui.CheckBox("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.sysDataPath = mh.getSysDataPath('rigs')
        self.homeDataPath = mh.getPath('data/rigs')
        if not os.path.exists(self.homeDataPath):
            os.makedirs(self.homeDataPath)
        self.paths = [self.homeDataPath, self.sysDataPath]

        #
        #   Preset box
        #

        self.presetChooser = self.addRightWidget(
            fc.IconListFileChooser(
                self.paths,
                'json',
                'thumb',
                name='Rig presets',
                notFoundImage=mh.getSysDataPath('notfound.thumb'),
                noneItem=True,
                doNotRecurse=True))
        self.presetChooser.setIconSize(50, 50)

        @self.presetChooser.mhEvent
        def onFileSelected(filename):
            self.rigPresetFileSelected(filename)

        self.infoBox = self.addLeftWidget(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)