예제 #1
0
    def DumpGender(path):
        import CCP_P4
        entries = {}
        AddBlendshapeEntries(path + '/head', entries,
                             BLENDSHAPE_CATEGORIES.FACEMODIFIERS)
        finalOrder = dict()
        for each in entries:
            key = each.split('/')[0]
            items = finalOrder.get(key, set())
            items.add(entries[each][0])
            finalOrder[key] = items

        for each in finalOrder:
            listData = list(finalOrder[each])
            listData.sort()
            filePath = blue.paths.ResolvePath(path + '/' + each +
                                              '/modifierNames.yaml')
            fileDir = os.path.dirname(filePath)
            if not os.path.exists(fileDir):
                os.mkdir(fileDir)
            CCP_P4.P4Add(filePath)
            CCP_P4.P4Edit(filePath)
            f = file(filePath, mode)
            for item in listData:
                f.write(item + '\n')

            f.flush()
            f.close()
def SerializeMaterialRes(ob, materialRes, p4c=None, path=None):
    """
    Given an object and its associated materialRes,
    store out the materialRes.
    
    TODO: Pass in the ob's res path rather than the whole object
    """
    import CCP_P4 as P4
    if path is None:
        resPath = GetResPath(ob)
        path = GetMaterialPathFromGeometryPath(resPath)
    if not path:
        return
    p4path = blue.paths.ResolvePathForWriting(path)
    destFolder = os.path.dirname(p4path)
    if not os.path.exists(destFolder):
        os.makedirs(destFolder)
    p4Root = P4.getRoot().lower()
    p4Root = p4Root.replace('/', '\\')
    osPath = os.path.abspath(path).lower()
    osPath = osPath.replace('/', '\\')
    inDepot = p4Root in osPath
    if inDepot and ENABLE_P4 is True:
        if not P4.P4FileInDepot(p4path, p4c):
            P4.P4Add2(p4path, p4c)
        else:
            P4.P4Edit2(p4path, p4c)
    if not blue.resMan.SaveObject(materialRes, path):
        log.LogWarn('===== SAVING FAILED for file %s =====' % p4path)
예제 #3
0
    def _SaveUVData(self, cell, cellName):
        import selectionTypes
        self.cellData[cellName] = {}
        cellData = self.cellData[cellName]
        for system in cell.systems:
            for static in system.statics:
                spawnID = cef.Spawn.GetByRecipeID(
                    selectionTypes.replaceObjects[static].recipeID).spawnID
                cellData[spawnID] = (static.uvLinearTransform,
                                     static.uvTranslation,
                                     static.instanceInSystemIdx)

        marshalData = blue.marshal.Save(cellData)
        import CCP_P4 as p4
        import os
        fileName = blue.paths.ResolvePathForWriting(INTERIOR_RES_PATH +
                                                    str(self.id) + '_' +
                                                    str(cellName) + '.uv')
        p4.PrepareFileForSave(fileName)
        if not os.path.exists(
                blue.paths.ResolvePathForWriting(INTERIOR_RES_PATH)):
            os.makedirs(blue.paths.ResolvePathForWriting(INTERIOR_RES_PATH))
        file = open(fileName, 'wb')
        file.write(marshalData)
        file.close()
        p4.AddFilesToP4()
    def BuildEnlightenScene(self):
        trinity.WaitForResourceLoads()
        import CCP_P4 as p4
        import os
        for cell in self.cells:
            p4.PrepareFileForSave(blue.paths.ResolvePathForWriting(cell.shProbeResPath))
            for system in cell.systems:
                p4.PrepareFileForSave(blue.paths.ResolvePathForWriting(system.radSystemPath))

            cell.RebuildInternalData()
            lightVolumeRes = [ int(v) + 1 for v in geo2.Vec3Subtract(cell.maxBounds, cell.minBounds) ]
            cell.BuildLightVolume(*lightVolumeRes)
            uvResPath = 'res:/interiorCache/' + str(self.id) + '_' + str(cell.name) + '.uv'
            uvFileName = blue.paths.ResolvePathForWriting(uvResPath)
            p4.PrepareFileForSave(uvFileName)

        import app.Interior.EnlightenBuildProgressDialog as progress
        dlg = progress.EnlightenBuildDialog()
        if dlg.BuildEnlighten(self):
            self.SaveEnlighten()
            revisionsDB = INTERIOR_RES_PATH + str(self.id) + '.revisions'
            revisionsDB = blue.paths.ResolvePathForWriting(revisionsDB)
            p4.PrepareFileForSave(revisionsDB)
            currentRevs = sm.GetService('jessicaWorldSpaceClient').GetWorldSpace(self.id).GetWorldSpaceSpawnRevisionsList()
            if not os.access(revisionsDB, os.F_OK):
                file = open(revisionsDB, 'w')
                yaml.dump(currentRevs, file)
                file.close()
            else:
                with open(revisionsDB, 'w') as DB:
                    yaml.dump(currentRevs, DB)
        p4.AddFilesToP4()
        for cell in self.cells:
            self._SaveUVData(cell, cell.name)
예제 #5
0
def SerializeMaterialStore(resPath, materialStore):
    import CCP_P4 as P4
    p4path = blue.paths.ResolvePathForWriting(resPath)
    destFolder = os.path.dirname(p4path)
    if not os.path.exists(destFolder):
        os.makedirs(destFolder)
    if ENABLE_P4 is True:
        if not P4.P4FileInDepot(p4path):
            P4.P4Add(p4path)
        else:
            P4.P4Edit(p4path)
    blue.resMan.SaveObject(materialStore, resPath)
예제 #6
0
 def DumpGenderOption(traversePath, traverseTestPath, optionFilePath):
     optionFilePath = blue.paths.ResolvePath(optionFilePath)
     CCP_P4.P4Add(optionFilePath)
     CCP_P4.P4Edit(optionFilePath)
     f = file(optionFilePath, 'w')
     entries = CreateEntries(traversePath)
     yaml.dump(entries, f, default_flow_style=False)
     f.close()
     if DUMP_MODULAR_TEST_CASES_TO_OPTIONS:
         f = file(optionFilePath, 'a')
         entries = CreateEntries(traverseTestPath)
         yaml.dump(entries, f, default_flow_style=False)
         f.close()
def SerializeMaterialStore(resPath, materialStore):
    """
    Store out a single material store.
    Mostly used to export base material definitions
    """
    import CCP_P4 as P4
    p4path = blue.paths.ResolvePathForWriting(resPath)
    destFolder = os.path.dirname(p4path)
    if not os.path.exists(destFolder):
        os.makedirs(destFolder)
    if ENABLE_P4 is True:
        if not P4.P4FileInDepot(p4path):
            P4.P4Add(p4path)
        else:
            P4.P4Edit(p4path)
    blue.resMan.SaveObject(materialStore, resPath)
예제 #8
0
    def fun():
        femalePath = FEMALE_BASE_PATH
        femaleTestPath = femalePath.replace('Modular',
                                            MODULAR_TEST_CASES_FOLDER)
        femaleOptionsPath = FEMALE_OPTION_FILE_PATH
        malePath = MALE_BASE_PATH
        maleTestPath = malePath.replace('Modular', MODULAR_TEST_CASES_FOLDER)
        maleOptionsPath = MALE_OPTION_FILE_PATH
        DumpBlendshapes(malePath, femalePath)
        if DUMP_MODULAR_TEST_CASES_TO_OPTIONS:
            DumpBlendshapes(maleTestPath, femaleTestPath, mode='a')

        def DumpGenderOption(traversePath, traverseTestPath, optionFilePath):
            optionFilePath = blue.paths.ResolvePath(optionFilePath)
            CCP_P4.P4Add(optionFilePath)
            CCP_P4.P4Edit(optionFilePath)
            f = file(optionFilePath, 'w')
            entries = CreateEntries(traversePath)
            yaml.dump(entries, f, default_flow_style=False)
            f.close()
            if DUMP_MODULAR_TEST_CASES_TO_OPTIONS:
                f = file(optionFilePath, 'a')
                entries = CreateEntries(traverseTestPath)
                yaml.dump(entries, f, default_flow_style=False)
                f.close()

        DumpGenderOption(femalePath, femaleTestPath, femaleOptionsPath)
        DumpGenderOption(malePath, maleTestPath, maleOptionsPath)
        if GENDER_ROOT:
            root = blue.paths.ResolvePath(
                'res:{0}\\Character'.format(BASE_GRAPHICS_FOLDER))
        else:
            root = blue.paths.ResolvePath(
                'res:\\{0}\\Character\\Modular'.format(BASE_GRAPHICS_FOLDER))
        patternsPath = os.path.abspath(root + '\\PatternOptions.yaml')
        CCP_P4.P4Edit(patternsPath)
        CCP_P4.P4Add(patternsPath)
        pf = file(patternsPath, 'w')
        yaml.dump(GetPatternList(), pf, default_flow_style=False)
        pf.close()
        if DUMP_MODULAR_TEST_CASES_TO_OPTIONS:
            patternsPath = root + '\\PatternOptions.yaml'
            pf = file(patternsPath, 'a')
            yaml.dump(GetPatternList(), pf, default_flow_style=False)
            pf.close()
예제 #9
0
def SerializeMaterialRes(ob, materialRes, p4c = None, path = None):
    import CCP_P4 as P4
    if path is None:
        resPath = GetResPath(ob)
        path = GetMaterialPathFromGeometryPath(resPath)
    if not path:
        return
    p4path = blue.paths.ResolvePathForWriting(path)
    destFolder = os.path.dirname(p4path)
    if not os.path.exists(destFolder):
        os.makedirs(destFolder)
    p4Root = P4.getRoot().lower()
    p4Root = p4Root.replace('/', '\\')
    osPath = os.path.abspath(path).lower()
    osPath = osPath.replace('/', '\\')
    inDepot = p4Root in osPath
    if inDepot and ENABLE_P4 is True:
        if not P4.P4FileInDepot(p4path, p4c):
            P4.P4Add2(p4path, p4c)
        else:
            P4.P4Edit2(p4path, p4c)
    if not blue.resMan.SaveObject(materialRes, path):
        log.LogWarn('===== SAVING FAILED for file %s =====' % p4path)