コード例 #1
0
    def _Populate_t(self, gender, path, key, callBack):
        log.LogInfo('ResData: populating from ', path)
        if gender not in self.genderData:
            self.CreateGenderData(gender)
        genderData = self.genderData[gender]
        entries = genderData.GetEntries(key)
        pathsToEntries = genderData.GetPathsToEntries(key)
        path = path.lower()

        def processAsync(root, respath, dirs, files):
            self._AddEntry(gender, entries, pathsToEntries, root, respath,
                           dirs, files)

        try:
            i = 0
            for root, dirs, files in walk.walk(path):
                if dirs or files:
                    PD.BeFrameNice(300)
                    respath = root.split(path)[1]
                    t = uthread.new(processAsync, root, respath, dirs, files)
                    i += 1
                    self._tasklets.append(t)

        finally:
            log.LogInfo('ResData:', i, ' entries populated from ', path)
            uthread.new(self._CleanTasklets)
            if callBack:
                uthread.new(callBack)
コード例 #2
0
 def doLinkage(pathsToEntriesA, pathsToEntriesB):
     for path, entry in pathsToEntriesA.iteritems():
         siblingEntry = pathsToEntriesB.get(path)
         if siblingEntry:
             siblingEntry.siblings.add(entry)
             entry.siblings.add(siblingEntry)
             PD.BeFrameNice(100)
コード例 #3
0
 def TraverseLODCutoff(currentEntry, lodCutoff, entries):
     if not currentEntry:
         return
     if currentEntry.lodCutoff is not None:
         lodCutoff = currentEntry.lodCutoff
     elif lodCutoff is not None:
         currentEntry.lodCutoff = lodCutoff
     for childEntry in entries[currentEntry]:
         TraverseLODCutoff(childEntry, lodCutoff, entries)
         PD.BeFrameNice()
コード例 #4
0
ファイル: projectedDecals.py プロジェクト: R4M80MrX/eve-1
    def __CreateNudeAvatar(self, doll):
        if doll.gender == PD.GENDER.FEMALE:
            genderPath = self.femalePath
        else:
            genderPath = self.malePath
        self._gender = doll.gender
        avatar = trinity.Tr2IntSkinnedObject()
        avatar.visualModel = self.factory.CreateVisualModel(doll.gender)
        avatar.name = 'TattooBakingAvatar'
        bodyParts = []
        for nudePartModularPath in PD.DEFAULT_NUDE_PARTS:
            bodyPartTuple = None
            if PD.DOLL_PARTS.HEAD in nudePartModularPath:
                headMods = doll.buildDataManager.GetModifiersByCategory(
                    PD.DOLL_PARTS.HEAD)
                if headMods:
                    headMod = doll.buildDataManager.GetModifiersByCategory(
                        PD.DOLL_PARTS.HEAD)[0]
                    if headMod.redfile:
                        bodyPartTuple = (headMod.name,
                                         blue.resMan.LoadObject(
                                             headMod.redfile))
            if not bodyPartTuple:
                mod = self.factory.CollectBuildData(self._gender,
                                                    nudePartModularPath)
                bodyPartTuple = (mod.name, blue.resMan.LoadObject(mod.redfile))
            bodyParts.append(bodyPartTuple)

        PD.BeFrameNice()
        for bodyPartTuple in bodyParts:
            modname, bodyPart = bodyPartTuple
            if bodyPart:
                for mesh in bodyPart.meshes:
                    mesh.name = modname
                    if len(mesh.opaqueAreas) > 0:
                        areasCount = mesh.GetAreasCount()
                        for i in xrange(areasCount):
                            areas = mesh.GetAreas(i)
                            if areas and areas != mesh.opaqueAreas:
                                del areas[:]

                        avatar.visualModel.meshes.append(mesh)

        self.__avatar = avatar
        self.__DoBlendShapes(doll)
        if doll.gender == PD.GENDER.FEMALE:
            bindPose = self.femaleBindPose
        else:
            bindPose = self.maleBindPose
        avatar.animationUpdater = bindPose
        clip = bindPose.grannyRes.GetAnimationName(0)
        bindPose.PlayAnimationEx(clip, 0, 0, 0)
        avatar.ResetAnimationBindings()
        bindPose.EndAnimation()
コード例 #5
0
ファイル: paperDollTests.py プロジェクト: connoryang/1v1dec
def RunSymmetricalSingleDollLODTest(coldCache=True,
                                    iterations=20,
                                    respaths=None,
                                    printStatistics=True):
    def fun():
        results = PerformanceTestResults()
        key = 'Loading Factory'
        results.PunchIn(key)
        sTime = blue.os.GetWallclockTime()
        factory = PD.Factory()
        if respaths:
            factory.clothSimulationActive = True
        factory.WaitUntilLoaded()
        eTime = blue.os.GetWallclockTime()
        results.PunchOut(key)
        scene = SetupScene(usePrepass=True)
        onTestExecution = None
        if respaths:
            respathsIterator = itertools.cycle(respaths)

            def onTestExecution(x):
                x.resPath = respathsIterator.next()

        try:
            bm = Benchmarker(factory, scene, usePrepass=True)
            bm.clearCacheOnEachIteration = coldCache
            bm.iterations = iterations
            test0 = SingleDollTest(0, 2)
            bm.SetTest(test0)
            bm.ExecuteTest(onTestExecution)
            if printStatistics:
                import pprint
                pprint.pprint(bm.GetAnalyzedResults())
            test1 = SingleDollTest(2, 0)
            bm.SetTest(test1)
            bm.ExecuteTest(onTestExecution)
            if printStatistics:
                pprint.pprint(bm.GetAnalyzedResults())
                pprint.pprint(results)
        finally:
            trinity.renderJobs.UnscheduleByName(DEFAULT_PREPASS_RENDERJOB_NAME)

    testTasklet = uthread.new(fun)
    uthread.schedule(testTasklet)
    try:
        while testTasklet.alive:
            PD.Yield()

    except RuntimeError:
        PD.BeFrameNice()
コード例 #6
0
ファイル: paperDollTests.py プロジェクト: connoryang/1v1dec
def RunCrowdSpawnTest(coldCache=True,
                      iterations=20,
                      respaths=None,
                      maxLodQueueActive=1,
                      debugMode=False,
                      nrPerLod=None):
    def fun():
        results = PerformanceTestResults()
        key = 'Loading Factory'
        results.PunchIn(key)
        sTime = blue.os.GetWallclockTime()
        factory = PD.Factory()
        if respaths:
            factory.clothSimulationActive = True
        factory.WaitUntilLoaded()
        eTime = blue.os.GetWallclockTime()
        results.PunchOut(key)
        scene = SetupScene(usePrepass=True)
        onTestExecution = None
        try:
            import pprint
            bm = Benchmarker(factory, scene, usePrepass=True)
            bm.clearCacheOnEachIteration = coldCache
            bm.iterations = 1 if debugMode else iterations
            totalDolls = sum(nrPerLod) if nrPerLod else 32
            lod0Dolls = nrPerLod[0] if nrPerLod else 8
            lod1Dolls = nrPerLod[1] if nrPerLod else 8
            test0 = MultiDollTest(totalDolls,
                                  lod0Dolls,
                                  lod1Dolls,
                                  maxLodQueueActive=1,
                                  resPaths=respaths,
                                  debugMode=debugMode)
            bm.SetTest(test0)
            bm.ExecuteTest(onTestExecution)
            pprint.pprint(bm.GetAnalyzedResults())
        finally:
            if not debugMode:
                trinity.renderJobs.UnscheduleByName(
                    DEFAULT_PREPASS_RENDERJOB_NAME)

    testTasklet = uthread.new(fun)
    uthread.schedule(testTasklet)
    try:
        while testTasklet.alive:
            PD.Yield()

    except RuntimeError:
        PD.BeFrameNice()
コード例 #7
0
ファイル: paperDollTests.py プロジェクト: connoryang/1v1dec
def RunIncarnaCrowdTest(coldCache=True,
                        iterations=20,
                        respaths=None,
                        maxLodQueueActive=1,
                        debugMode=False):
    def fun():
        results = PerformanceTestResults()
        key = 'Loading Factory'
        results.PunchIn(key)
        sTime = blue.os.GetWallclockTime()
        factory = PD.Factory()
        if respaths:
            factory.clothSimulationActive = True
        factory.WaitUntilLoaded()
        eTime = blue.os.GetWallclockTime()
        results.PunchOut(key)
        scene = SetupScene(
            sceneFile=
            'res:/Graphics/Character/Global/DataUsedForTests/referenceEstablishment.red',
            usePrepass=True)
        onTestExecution = None
        try:
            import pprint
            bm = Benchmarker(factory, scene, usePrepass=True)
            bm.clearCacheOnEachIteration = coldCache
            bm.iterations = 1 if debugMode else iterations
            test0 = MultiDollTest(32,
                                  8,
                                  16,
                                  maxLodQueueActive=1,
                                  resPaths=respaths,
                                  debugMode=debugMode)
            bm.SetTest(test0)
            bm.ExecuteTest(onTestExecution)
            pprint.pprint(bm.GetAnalyzedResults())
        finally:
            if not debugMode:
                trinity.renderJobs.UnscheduleByName(
                    DEFAULT_PREPASS_RENDERJOB_NAME)

    testTasklet = uthread.new(fun)
    uthread.schedule(testTasklet)
    try:
        while testTasklet.alive:
            PD.Yield()

    except RuntimeError:
        PD.BeFrameNice()
コード例 #8
0
 def _AddEntry(self, gender, entries, pathsToEntries, root, respath, dirs,
               files):
     PD.BeFrameNice(100)
     if respath.startswith(PD.SEPERATOR_CHAR):
         respath = respath[1:]
     respath = str(respath)
     searchPath, stemPath = root.split(':')
     root = '{0}:{1}'.format(searchPath, stemPath.lower())
     resDataEntry = Entry(gender, root, respath, dirs, files)
     entries[resDataEntry] = []
     self.rootsToEntries[root] = resDataEntry
     pathsToEntries[respath] = resDataEntry
     parentEntry = self.GetParentEntry(resDataEntry)
     if parentEntry:
         entries[parentEntry].append(resDataEntry)
     return resDataEntry
コード例 #9
0
 def AddRandomizedResourcesToDoll(self, doll, randomizedResources):
     for category in randomizedResources:
         PD.BeFrameNice()
         for resType, res in randomizedResources[category]:
             if not res:
                 continue
             weight = self.weights.get(res, 1.0)
             if resType == self.RESOURCE_TYPE:
                 doll.AddItemType(self.modifierLoader, res, weight)
             else:
                 modifier = doll.AddResource(category + '/' + res, weight,
                                             self.modifierLoader)
                 variations = self.GetVariations(modifier)
                 colorVariations = self.GetColorVariations(modifier)
                 variation = AbstractRandomizer.SelectOneFromCollection(
                     variations, oddsOfSelectingNone=0.3)
                 if variation:
                     modifier.SetVariation(variation)
                 variation = AbstractRandomizer.SelectOneFromCollection(
                     colorVariations, oddsOfSelectingNone=0.3)
                 if variation:
                     modifier.SetColorVariation(variation)
                 modifier.weight = weight
コード例 #10
0
    def GetBlendshapeOptions(self):
        if not self.__blendshapeOptions:
            self.__blendshapeOptions = {}
            categories = PD.BLENDSHAPE_CATEGORIES - (
                PD.BLENDSHAPE_CATEGORIES.UTILITYSHAPES,
                PD.BLENDSHAPE_CATEGORIES.ARCHETYPES)
            for category in categories:
                PD.BeFrameNice()
                options = [option for option in self.ListOptions(category)]
                options = AbstractRandomizer.SelectManyFromCollection(
                    options, minElems=8)
                pairToElem = {}
                for key, group in itertools.groupby(options,
                                                    lambda x: x[:x.find('_')]):
                    elems = list(group)
                    if len(elems) > 0 and len(elems) < 2:
                        pairToElem[key] = elems[0]
                    else:
                        random.shuffle(elems)
                        for elem in elems:
                            for pair in PD.BLENDSHAPE_AXIS_PAIRS:
                                for pairElem in pair:
                                    if pairElem in elem:
                                        pairToElem[pair] = elem
                                        break

                options = pairToElem.values()
                self.__blendshapeOptions[category] = [
                    (self.RESOURCE_OPTION, option) for option in options
                ]
                for option in options:
                    lowerlimit, upperlimit = self.__blendshapeLimits.get(
                        option, (0.0, 1.0))
                    self.AddRandomizedWeightForOption(option, lowerlimit,
                                                      upperlimit)

        return self.__blendshapeOptions
コード例 #11
0
    def GetResources(self):
        if not self.__resources:
            catToResources = {}

            def ChooseResource(category, resourceList, isType):
                odds = 0.0 if category in self.categoriesThatMustHaveEntries else self.oddsOfSelectingNoneForCategory.get(
                    category, 0.22)
                res = AbstractRandomizer.SelectOneFromCollection(
                    resourceList, oddsOfSelectingNone=odds)
                if res:
                    resourceType = self.RESOURCE_TYPE if isType else self.RESOURCE_OPTION
                    catToResources[category] = [(resourceType, res)]
                    if category in self.__pathsToRandomizeWeights:
                        self.AddRandomizedWeightForOption(
                            res, *self.__pathsToRandomizeWeights[category])

            gender = self.GetGender()
            catPath = ''
            for category in self.dollCategories:
                PD.BeFrameNice()
                if self.filterCategoriesForRandomization:
                    continueOut = True
                    if category in (PD.DOLL_PARTS.ACCESSORIES,
                                    PD.HEAD_CATEGORIES.MAKEUP,
                                    PD.BODY_CATEGORIES.TATTOO,
                                    PD.BODY_CATEGORIES.SCARS):
                        for wCat in self.filterCategoriesForRandomization:
                            if category in wCat.split(PD.SEPERATOR_CHAR):
                                continueOut = False
                                break

                    else:
                        continueOut = category not in self.filterCategoriesForRandomization
                    if continueOut:
                        continue
                if category in (PD.DOLL_PARTS.ACCESSORIES,
                                PD.HEAD_CATEGORIES.MAKEUP,
                                PD.BODY_CATEGORIES.TATTOO,
                                PD.BODY_CATEGORIES.SCARS):
                    options = self.ListOptions(category)
                    for option in options:
                        subcategory = category + '/' + option
                        if not catPath or catPath and subcategory == catPath:
                            if self.filterCategoriesForRandomization:
                                if category in self.filterCategoriesForRandomization or subcategory in self.filterCategoriesForRandomization:
                                    if self.modifierLoader.CategoryHasTypes(
                                            subcategory):
                                        ChooseResource(
                                            subcategory,
                                            self.ListTypes(subcategory), True)
                                    else:
                                        ChooseResource(
                                            subcategory,
                                            self.ListOptions(subcategory),
                                            False)

                elif not catPath or catPath == category:
                    if self.modifierLoader.CategoryHasTypes(category) > 0:
                        ChooseResource(category, self.ListTypes(category),
                                       True)
                    else:
                        options = [
                            option for option in self.ListOptions(category)
                            if 'nude' not in option
                        ]
                        ChooseResource(category, options, False)

            self.__resources = catToResources
        return self.__resources