コード例 #1
0
    def export(self, inputTransform, targetDirectory, displayReport=True):
        """
            Collect skin settings form a transform name.
            (specifically from its shape).

            args:
                inputTransform(string):Name of the transform with a shape deformed by a skincluster.

                targetDirectory(string):directory path for the exported data.

            kwargs:
                displayReport(bool). print time need to evaluate this operation.

            returns:
                (SkinSettings)
        """
        self.timeProcessing.report = ''

        self.timeProcessing.processObjectCount = 0

        validationUtils = validation.SkinValidator()
        inputSkinNodes = validationUtils.getSkinHistory(inputTransform)

        if len(inputSkinNodes) == 0:
            return None

        skinSettings = None

        skinSettings = settings.SkinSettings(inputSkinNodes[0])
        skinSettings.shape = maya.cmds.listRelatives(inputTransform,
                                                     s=True,
                                                     fullPath=True)[0]

        return skinSettings
コード例 #2
0
    def parseJsonFromArchive(self, sourceArchiveFile):
        if not os.path.exists(sourceArchiveFile):
            return False

        with zipfile.ZipFile(sourceArchiveFile, 'r') as archive:
            jsonList = [
                info.filename for info in archive.infolist()
                if info.filename.endswith('.json')
            ]

            jsonInput = [
                json.loads(archive.read(jsonElement))
                for jsonElement in jsonList
            ][0]

        self.jsonArray = []

        for jsonData in jsonInput:
            skinData = settings.SkinSettings(None, collectData=False)

            skinData.fromJson(jsonInput[jsonData])

            self.jsonArray.append(skinData)

        return True
コード例 #3
0
    def saveWeights(self, inputMesh, targetDirectory):
        targetFile = os.path.join(targetDirectory, '{0}.wgt'.format(inputMesh))

        skinNode = maya.mel.eval('findRelatedSkinCluster {}'.format(inputMesh))
        if skinNode is None:
            return

        skinSettings = settings.SkinSettings(skinNode)
        shapeSettings = settings.ShapeSettings(skinSettings.shape)

        with open(targetFile, 'w') as skinFile:
            for pointIndex in xrange(shapeSettings.pointCount):
                skinData = self.getWeights(inputMesh, skinSettings,
                                           shapeSettings)

                skinFile.write(skinData)
コード例 #4
0
    def collectAdditionalData(self, unpackDirectory):
        skinSettings = settings.SkinSettings(None, collectData=False)

        skinSettings.abcWeightsFile = posixpath.join(
            unpackDirectory, 'BinaryInjection_skinweight.mb')

        self.transferToDisk(self.skinNodeArray, skinSettings.abcWeightsFile)

        self.sceneWeights = [skinSettings]

        report = self.timeProcessing.report.replace('\n', '\n\t')

        report += '\n'
        report += "\n\t<End of BinaryExtraction>"

        self.batchProcessing.report += report
        self.batchProcessing.report += '\n\t Saving {} elements took {} seconds\n'.format(
            len(self.skinNodeArray), float(self.timeProcessing.timeRange))