def _StartTest(self): BenchmarkTest._StartTest(self) pdc = PD.PaperDollCharacter(self.factory) pdc.doll = PD.Doll('TestDoll') if self.resPath: pdc.doll.Load(self.resPath, self.factory) pdc.doll.overrideLod = self.startLOD spawnKey = 'Spawning doll at LOD {0}'.format(self.startLOD) self.results.PunchIn(spawnKey) pdc.Spawn(self.scene, usePrepass=self.usePrepass) while pdc.doll.busyUpdating: PD.Yield() self.results.PunchOut(spawnKey) while pdc.doll.overrideLod != self.endLOD: nextLOD = pdc.doll.overrideLod + self.lodDelta spawnKey = 'Switching from LOD {0} to LOD {1}'.format(pdc.doll.overrideLod, nextLOD) self.results.PunchIn(spawnKey) pdc.doll.overrideLod = nextLOD pdc.Update() while pdc.doll.busyUpdating: PD.Yield() self.results.PunchOut(spawnKey) PD.Yield()
def LoadScene(self, sceneContainer): sceneContainer.PrepareInteriorScene(backgroundImage=self.background) apparel = GetPaperDollResource(self.typeID, gender=self.gender) if apparel is None: raise InvalidPreviewType( '%s (%s) does not have an associated paper doll resource' % (evetypes.GetName(self.typeID), self.typeID)) factory = pd.Factory() mannequin = pd.PaperDollCharacter(factory) self.mannequin = mannequin dollGender = GenderIDToPaperDollGender(apparel.resGender) mannequin.doll = pd.Doll('mannequin', gender=dollGender) mannequin.doll.Load(MANNEQUIN_RES_BY_GENDER[dollGender], factory) mannequin.WaitForUpdate() textureQuality = gfxsettings.Get(gfxsettings.GFX_CHAR_TEXTURE_QUALITY) resolution = ccConst.TEXTURE_RESOLUTIONS[textureQuality] mannequin.doll.textureResolution = resolution mannequin.doll.overrideLod = 0 mannequin.Spawn(sceneContainer.scene, usePrepass=False) mannequin.WaitForUpdate() with CaptureDollMeshChanges(mannequin.doll) as meshes: mannequin.doll.SetItemType(factory, apparel.resPath) typeData = factory.GetItemType(apparel.resPath, gender=dollGender) apparelCategory = sm.GetService( 'character').GetCategoryFromResPath(typeData[0]) coveringCategories = PAPERDOLL_CATEGORIES_COVERING.get( apparelCategory, []) for category in coveringCategories: mannequin.doll.buildDataManager.RemoveMeshContainingModifiers( category) mannequin.Update() mannequin.WaitForUpdate() newMeshes = set(filter(lambda m: m not in meshes.before, meshes.after)) assetGroupID = evetypes.GetGroupID(self.typeID) meshNameCheck = lambda mesh: any( map(lambda name: mesh.name.startswith(name), MESH_NAMES_BY_GROUPID[ assetGroupID])) groupMeshes = set(filter(meshNameCheck, meshes.after)) boundingBoxes = map(lambda m: m.geometry.GetBoundingBox(0), newMeshes | groupMeshes) if len(boundingBoxes) == 0: aabb = mannequin.visualModel.GetBoundingBoxInLocalSpace() else: aabb = reduce(MergeBoundingBoxes, boundingBoxes) animationRes = 'res:/Animation/MorphemeIncarna/Export/Mannequin/Mannequin.mor' animationUpdater = GWAnimation(animationRes) if animationUpdater is not None: animationSetIndex = 0 if dollGender == pd.GENDER.FEMALE else 1 animationUpdater.network.SetAnimationSetIndex(animationSetIndex) mannequin.avatar.animationUpdater = animationUpdater floorShadow = trinity.Load(ccConst.CUSTOMIZATION_FLOOR) sceneContainer.scene.dynamics.append(floorShadow) SetupInteriourCamera(sceneContainer, aabb)
def RenderMannequinAssets(self, camera, genderID, scene, tryout): mannequin = paperDoll.PaperDollCharacter(self.factory) mannequin.doll = paperDoll.Doll( 'mannequin', gender=ccUtil.GenderIDToPaperDollGender(genderID)) doll = mannequin.doll if genderID == ccConst.GENDERID_MALE: doll.Load(MALE_MANNEQUIN, self.factory) else: doll.Load(FEMALE_MANNEQUIN, self.factory) self.WaitForDoll(doll) doll.overrideLod = paperDoll.LOD_SKIN doll.textureResolution = self.resolution mannequin.Spawn(scene, usePrepass=False) avatar = mannequin.avatar networkPath = ccConst.CHARACTER_CREATION_NETWORK self.factory.CreateGWAnimation(avatar, networkPath) network = avatar.animationUpdater.network if network is not None: network.SetControlParameter('ControlParameters|BindPose', 1.0) if doll.gender == 'female': network.SetAnimationSetIndex(0) else: network.SetAnimationSetIndex(1) blue.pyos.synchro.SleepWallclock(500) self.FreezeCharacter(avatar) if self.renderSetsCb.GetValue(): self.LoadMannequinAndCamera(mannequin, genderID, ccConst.outer, camera, scene) setText = self.setTypeIDsEditField.GetValue() setText = setText.strip() if not setText.endswith(','): setText += ',' clothingSets = eval(setText) for eachSet in clothingSets: self.DoRenderMannequinAssetType(avatar, eachSet, genderID, mannequin, scene, 'set') return avatar for category in self.assetCategoriesToRender: self.LoadMannequinAndCamera(mannequin, genderID, category, camera, scene) typeData = self.characterSvc.GetAvailableTypesByCategory( category, genderID, -1) for itemType in typeData: wasRendered = self.RenderMannequinAssetType( avatar, genderID, mannequin, scene, itemType, category) if wasRendered and tryout: break return avatar
def SpawnDolls(self, lod, count): for i in xrange(count): pdc = PD.PaperDollCharacter(self.factory) pdc.disableDel = self.debugMode pdc.doll = PD.Doll('TestDoll') if self.respathsIterator: spawnKey = 'Loading doll #{0} at LOD {1}'.format(i, lod) self.results.PunchIn(spawnKey) pdc.doll.Load(self.respathsIterator.next(), self.factory) self.results.PunchOut(spawnKey) spawnKey = 'Spawning doll #{0} at LOD {1} without call to Update'.format(i, lod) self.results.PunchIn(spawnKey) pdc.Spawn(self.scene, point=self.points.pop(), lod=99999, updateDoll=False, usePrepass=self.usePrepass) self.results.PunchOut(spawnKey) self.paperDollCharacters.append(pdc) avatar = blue.BluePythonWeakRef(pdc.avatar) doll = weakref.ref(pdc.doll) factory = weakref.ref(pdc.factory) PD.LodQueue.instance.AddToQueue(avatar, doll, factory, lod)
def PreviewType(self, typeID, subsystems=None): if getattr(self, 'running', False): return self.running = True self.previewingWhat = 'type' if getattr(self, 'btnGroup', None): self.btnGroup.display = False self.SetCaption(localization.GetByLabel('UI/Preview/PreviewCaption')) self.sr.title.display = True self.sr.subtitle.display = True typeID = int(typeID) if typeID != self.typeID: self.CloseSubSystemWnd() isFirst = self.typeID is None typeOb = cfg.invtypes.Get(typeID) groupID = typeOb.groupID groupOb = cfg.invgroups.Get(groupID) categoryID = groupOb.categoryID self.categoryID = categoryID self.groupID = groupID self.typeID = typeID self.sr.title.text = cfg.invtypes.Get(typeID).name rad = 4.0 self.textCont.display = False self.SetMinSize([420, 320]) self.SetMaxSize([None, None]) self.sr.subtitle.text = '' godma = sm.GetService('godma') try: techLevel = godma.GetTypeAttribute(typeID, const.attributeTechLevel) except: techLevel = 1.0 self.loadingWheel.Show() if categoryID == const.categoryShip and techLevel == 3.0: self.sr.sceneContainer.PrepareSpaceScene() if subsystems is None: subsystems = {} subSystemsForType = {} for group in cfg.groupsByCategories.get( const.categorySubSystem, []): if group.groupID not in subSystemsForType: subSystemsForType[group.groupID] = [] for t in cfg.typesByGroups.get(group.groupID, []): if t.published and godma.GetTypeAttribute( t.typeID, const.attributeFitsToShipType) == typeID: subSystemsForType[group.groupID].append(t.typeID) for k, v in subSystemsForType.iteritems(): subsystems[k] = random.choice(v) model = sm.StartService('t3ShipSvc').GetTech3ShipFromDict( typeID, subsystems) radius = round(model.GetBoundingSphereRadius() * 2, 0) self.SetShipSubLabel(typeOb, groupOb, radius) kv = util.KeyVal(typeID=typeID) form.AssembleShip.Open(windowID='PreviewSubSystems', ship=kv, groupIDs=None, isPreview=True, setselected=subsystems) elif self.categoryID in paperDollCategories: desc = typeOb.description desc = desc or '' for each in ('<b>', '</b>', '\r'): desc = desc.replace(each, '') desc = desc.replace('\n', '<br>') self.desc.SetValue(desc) self.textCont.display = True self.SetMinSize([320, 470]) self.SetMaxSize([800, 950]) self.sr.sceneContainer.cameraParent.value = trinity.TriVector( 9.0, -1000, 0.0) self.sr.sceneContainer.PrepareInteriorScene() scene = self.sr.sceneContainer.scene factory = pd.Factory() asset = GetPaperDollResource(typeID) if asset is None: log.LogError('PreviewWnd::PreviewType - Invalid asset') self.loadingWheel.Hide() return path = asset.resPath genderID = asset.resGender self.mannequin = pd.PaperDollCharacter(factory) self.mannequin.doll = pd.Doll( 'mannequin', gender=ccUtil.GenderIDToPaperDollGender(genderID)) if genderID == ccConst.GENDERID_MALE: self.mannequin.doll.Load( 'res:/Graphics/Character/DNAFiles/Mannequin/MaleMannequin.prs', factory) else: self.mannequin.doll.Load( 'res:/Graphics/Character/DNAFiles/Mannequin/FemaleMannequin.prs', factory) while self.mannequin.doll.busyUpdating: blue.synchro.Yield() if self.mannequin is None: return textureQuality = settings.public.device.Get( 'charTextureQuality', sm.GetService('device').GetDefaultCharTextureQuality()) resolution = ccConst.TEXTURE_RESOLUTIONS[textureQuality] self.mannequin.doll.overrideLod = 0 self.mannequin.doll.textureResolution = resolution self.mannequin.Spawn(scene, usePrepass=False) while self.mannequin.doll.busyUpdating: blue.synchro.Yield() if self.mannequin is None: return meshListPre = self.mannequin.doll.buildDataManager.GetMeshes( includeClothMeshes=True) self.mannequin.doll.SetItemType(factory, path, weight=1.0) self.mannequin.Update() while self.mannequin.doll.busyUpdating: blue.synchro.Yield() if self.mannequin is None: return meshListPost = self.mannequin.doll.buildDataManager.GetMeshes( includeClothMeshes=True) animationUpdater = GameWorld.GWAnimation( 'res:/Animation/MorphemeIncarna/Export/Mannequin/Mannequin.mor' ) if animationUpdater is not None: self.mannequin.avatar.animationUpdater = animationUpdater if self.mannequin.doll.gender == pd.GENDER.FEMALE: animationUpdater.network.SetAnimationSetIndex(0) else: animationUpdater.network.SetAnimationSetIndex(1) bBox = (geo2.Vector(1000.0, 1000.0, 1000.0), geo2.Vector(-1000.0, -1000.0, -1000.0)) if groupID in MESH_NAMES_BY_GROUPID: meshName = MESH_NAMES_BY_GROUPID[groupID] found = False for mesh in meshListPost: if mesh.name.startswith( meshName) or mesh not in meshListPre: fromMesh = mesh.geometry.GetBoundingBox(0) bBox[0].x = min(bBox[0].x, fromMesh[0].x) bBox[0].y = min(bBox[0].y, fromMesh[0].y) bBox[0].z = min(bBox[0].z, fromMesh[0].z) bBox[1].x = max(bBox[1].x, fromMesh[1].x) bBox[1].y = max(bBox[1].y, fromMesh[1].y) bBox[1].z = max(bBox[1].z, fromMesh[1].z) found = True if not found: bBox = (geo2.Vector(-0.1, 1.6, -0.1), geo2.Vector(0.1, 1.8, 0.1)) center = ((bBox[1].x + bBox[0].x) / 2.0, (bBox[1].y + bBox[0].y) / 2.0, (bBox[1].z + bBox[0].z) / 2.0) rad = geo2.Vec3Length(bBox[0] - bBox[1]) rad = max(rad, 0.3) self.sr.sceneContainer.cameraParent.value = trinity.TriVector( *center) floor = trinity.Load(ccConst.CUSTOMIZATION_FLOOR) scene.dynamics.append(floor) model = None elif self.groupID in const.turretModuleGroups: self.sr.sceneContainer.PrepareSpaceScene( 0.0, 'res:/dx9/scene/fitting/previewTurrets.red') model = trinity.Load( 'res:/dx9/model/ship/IconPreview/PreviewTurretShip.red') tSet = turretSet.TurretSet.FitTurret(model, None, typeID, 1, checkSettings=False) if tSet is not None: boundingSphere = tSet.turretSets[0].boundingSphere model.boundingSphereRadius = boundingSphere[3] model.boundingSphereCenter = boundingSphere[:3] if model.boundingSphereCenter[1] < 2.0: model.boundingSphereCenter = (boundingSphere[0], 2.0, boundingSphere[2]) for ts in tSet.turretSets: ts.bottomClipHeight = 0.0 ts.FreezeHighDetailLOD() ts.ForceStateDeactive() ts.EnterStateIdle() self.sr.subtitle.text = localization.GetByLabel( 'UI/Preview/ShipSubLabelNoRace', groupName=groupOb.groupName, length=util.FmtDist(model.boundingSphereRadius)) elif self.groupID in const.turretAmmoGroups: self.sr.sceneContainer.PrepareSpaceScene( 0.0, 'res:/dx9/scene/fitting/previewAmmo.red') model = trinity.Load( 'res:/dx9/model/ship/IconPreview/PreviewAmmoShip.red') self.sr.sceneContainer.AddToScene(model) ammoRedFile = typeOb.GraphicFile() ammoRedFile = ammoRedFile[:-4] + '_hi' + ammoRedFile[-4:] ammo = trinity.Load(ammoRedFile) if ammo.__bluetype__ == 'trinity.EveMissile': floatHeight = ammo.boundingSphereRadius - ammo.boundingSphereCenter[ 2] floatHeight += 0.2 * ammo.boundingSphereRadius model.boundingSphereRadius = ammo.boundingSphereRadius + floatHeight model.boundingSphereCenter = (0.0, ammo.boundingSphereRadius + 0.5 * floatHeight, 0.0) warhead = ammo.warheads[0] warhead.rotation = geo2.QuaternionRotationAxis((1.0, 0.0, 0.0), -0.5 * math.pi) warhead.translation = (0.0, floatHeight, 0.0) warhead.startDataValid = True del warhead.children[:] model.children.append(warhead) warheadReflection = warhead.CopyTo() warheadReflection.rotation = geo2.QuaternionRotationAxis( (1.0, 0.0, 0.0), 0.5 * math.pi) warheadReflection.translation = (0.0, -floatHeight, 0.0) warheadReflection.startDataValid = True model.children.append(warheadReflection) self.sr.subtitle.text = localization.GetByLabel( 'UI/Preview/ShipSubLabelNoRace', groupName=groupOb.groupName, length=util.FmtDist(model.boundingSphereRadius)) else: log.LogWarn( 'type', typeID, ' is not an EveMissile but still wants to be previewed as one' ) model = None else: self.sr.sceneContainer.PrepareSpaceScene() fileName = typeOb.GraphicFile() if fileName == '': log.LogWarn('type', typeID, 'has no graphicFile') self.loadingWheel.Hide() return fileName = fileName.replace(':/Model', ':/dx9/Model').replace( '.blue', '.red') fileName = fileName.partition(' ')[0] model = trinity.Load(fileName) radius = round(model.GetBoundingSphereRadius() * 2, 0) self.SetShipSubLabel(typeOb, groupOb, radius) if model is None: self.sr.sceneContainer.ClearScene() self.loadingWheel.Hide() raise UserError('PreviewNoModel') if getattr(model, 'boosters', None) is not None: model.boosters = None if getattr(model, 'modelRotationCurve', None) is not None: model.modelRotationCurve = None if getattr(model, 'modelTranslationCurve', None) is not None: model.modelTranslationCurve = None if hasattr(model, 'ChainAnimationEx'): model.ChainAnimationEx('NormalLoop', 0, 0, 1.0) self.sr.sceneContainer.AddToScene(model) camera = self.sr.sceneContainer.camera navigation = self.sr.navigation spaceObject = False if hasattr(model, 'GetBoundingSphereRadius'): rad = model.GetBoundingSphereRadius() spaceObject = True minZoom = rad + self.sr.sceneContainer.frontClip alpha = self.sr.sceneContainer.fieldOfView / 2.0 if spaceObject: maxZoom = max(rad * (1 / math.tan(alpha)) * 2, 1.0) camera.translationFromParent = minZoom * 2 else: maxZoom = min(rad * (1 / math.tan(alpha * 1.5)), 7.0) camera.translationFromParent = minZoom * 3 navigation.SetMinMaxZoom(minZoom, maxZoom) self.sr.sceneContainer.UpdateViewPort() self.BringToFront() if isFirst: uthread.new(self.OrbitParent) self.loadingWheel.Hide() self.running = False
def RenderLoop(self, tryout=False, fromWebtools=False): uicore.device.ForceSize() if getattr(self, 'renderJob', None): if self.renderJob in trinity.renderJobs.recurring: trinity.renderJobs.recurring.remove(self.renderJob) self.renderJob = None characterSvc = sm.GetService('character') characterSvc.characters = {} characterSvc.TearDown() uicore.layer.charactercreation.OpenView() uicore.layer.charactercreation.Flush() trinity.SetRightHanded(True) charID = 0 for layerName, layer in uicore.layer.__dict__.iteritems(): if isinstance(layer, uicls.LayerCore): layer.display = False sm.GetService('sceneManager').SetSceneType(0) uicore.layer.charactercreation.SetupScene( ccConst.SCENE_PATH_CUSTOMIZATION) scene = uicore.layer.charactercreation.scene lightIntensity = 0.5 lightScene = trinity.Load( 'res:/Graphics/Character/Global/PaperdollSettings/LightSettings/Normal.red' ) lightColorScene = trinity.Load( 'res:/Graphics/Character/Global/PaperdollSettings/LightColors/Normal.red' ) ccUtil.SetupLighting(scene, lightScene, lightColorScene, lightIntensity) uicore.layer.charactercreation.cameraUpdateJob = None uicore.layer.charactercreation.camera = cameras.CharCreationCamera( None) uicore.layer.charactercreation.SetupCameraUpdateJob() camera = uicore.layer.charactercreation.camera for each in trinity.renderJobs.recurring: if each.name == 'cameraUpdate': trinity.renderJobs.recurring.remove(each) elif each.name == 'BaseSceneRenderJob': for child in each.steps: if isinstance(child, trinity.TriStepClear): child.enabled = False elif hasattr(child, 'name') and child.name == 'RENDER_BACKDROP': child.enabled = False rj = trinity.CreateRenderJob('Thumbnail RenderJob') updateScene = rj.Update(scene) updateScene.name = 'Update Scene' rj.Clear((0.0, 1.0, 0.0, 1.0), 1.0) rj.SetProjection(camera.projectionMatrix) rj.SetView(camera.viewMatrix) renderInteriorSceneStep = rj.RenderScene(scene) renderInteriorSceneStep.name = 'Render Scene' trinity.renderJobs.recurring.insert(0, rj) self.renderJob = rj if fromWebtools: rj.Clear(MANNEQUINBG, 1.0) else: for cb in (self.greenscreenCB, self.greyCB, self.blackCB, self.mannequinBGCB): if cb.GetValue(): rj.Clear(cb.color, 1.0) else: if self.otherCB.GetValue() and self.otherEdit.GetValue(): text = self.otherEdit.GetValue() evalText = eval(text) if text and type(evalText) is tuple and len(evalText) == 4: rj.Clear(evalText, 1.0) SWEETSPOTY = 1.7 blue.pyos.synchro.SleepWallclock(2000) for cb in self.altCheckboxes: if not cb.GetValue(): continue altCategory = cb.name for gender, genderID, genderCB in [ ('female', 0, getattr(self, 'femaleCB', None)), ('male', 1, getattr(self, 'maleCB', None)) ]: if genderCB and not genderCB.GetValue(): continue uicore.layer.charactercreation.genderID = genderID for bloodlineCB in self.bloodlines: if not bloodlineCB.GetValue(): continue characterSvc.RemoveCharacter(charID) bloodlineID = bloodlineCB.bloodlineID uicore.layer.charactercreation.ResetDna() characterSvc.AddCharacterToScene( charID, scene, ccUtil.GenderIDToPaperDollGender(genderID), bloodlineID=bloodlineID) doll = characterSvc.GetSingleCharactersDoll(charID) doll.overrideLod = paperDoll.LOD_SKIN doll.textureResolution = ccConst.TEXTURE_RESOLUTIONS[1] characterSvc.SetDollBloodline(charID, bloodlineID) characterSvc.ApplyItemToDoll( charID, 'head', paperDollUtil.bloodlineAssets[bloodlineID], doUpdate=False) characterSvc.UpdateDoll(charID, fromWhere='RenderLoop') for dcCategory in DRESSCODE[ccConst.hair]: dcTypeData = characterSvc.GetAvailableTypesByCategory( dcCategory, genderID, bloodlineID) if dcTypeData: dcItemType = dcTypeData[0] dcModifier = characterSvc.ApplyTypeToDoll( charID, dcItemType) character = characterSvc.GetSingleCharacter(charID) doll = character.doll while len(scene.dynamics) < 1: blue.synchro.Yield() blue.synchro.Yield() while doll.busyUpdating: blue.synchro.Yield() trinity.WaitForResourceLoads() camera.SetFieldOfView(0.3) if altCategory == 'poses': if genderID == 0: camera.SetPointOfInterest((0.0, 1.5, 0.0)) else: camera.SetPointOfInterest((0.0, 1.6, 0.0)) camera.distance = 2.0 camera.Update() characterSvc.StartPosing(charID) character.avatar.animationUpdater.network.SetControlParameter( 'ControlParameters|NetworkMode', 2) for i in xrange(ccConst.POSERANGE): characterSvc.ChangePose(i, charID) blue.pyos.synchro.SleepWallclock(100) outputPath = 'C:/Temp/Thumbnails/%s_g%s_b%s.png' % ( 'pose_%s' % i, genderID, bloodlineID) self.SaveScreenShot(outputPath) elif altCategory == 'lights': if genderID == 0: camera.SetPointOfInterest((0.0, 1.6, 0.0)) else: camera.SetPointOfInterest((0.0, 1.7, 0.0)) camera.distance = 1.4 camera.Update() lightingList = ccConst.LIGHT_SETTINGS_ID lightingColorList = ccConst.LIGHT_COLOR_SETTINGS_ID for each in lightingList: for color in lightingColorList: uicore.layer.charactercreation.SetLightsAndColor( each, color) blue.synchro.Yield() blue.resMan.Wait() trinity.WaitForResourceLoads() for i in xrange(10): blue.pyos.synchro.SleepWallclock(100) camera.Update() outputPath = 'C:/Temp/Thumbnails/%s_g%s_b%s.png' % ( 'light_%s_%s' % (each, color), genderID, bloodlineID) self.SaveScreenShot(outputPath) for gender, genderID, genderCB in [ ('Male', 1, getattr(self, 'maleCB', None)), ('Female', 0, getattr(self, 'femaleCB', None)) ]: if not fromWebtools and genderCB and not genderCB.GetValue(): continue if fromWebtools or getattr(self, 'mannequinCB', None) and self.mannequinCB.GetValue(): mannequin = paperDoll.PaperDollCharacter(self.factory) mannequin.doll = paperDoll.Doll( 'mannequin', gender=ccUtil.GenderIDToPaperDollGender(genderID)) if genderID == ccConst.GENDERID_MALE: mannequin.doll.Load( 'res:/Graphics/Character/DNAFiles/Mannequin/MaleMannequin.prs', self.factory) else: mannequin.doll.Load( 'res:/Graphics/Character/DNAFiles/Mannequin/FemaleMannequin.prs', self.factory) while mannequin.doll.busyUpdating: blue.synchro.Yield() doll = mannequin.doll resolution = ccConst.TEXTURE_RESOLUTIONS[1] doll.overrideLod = paperDoll.LOD_SKIN doll.textureResolution = resolution mannequin.Spawn(scene, usePrepass=False) avatar = mannequin.avatar networkPath = ccConst.CHARACTER_CREATION_NETWORK self.factory.CreateGWAnimation(avatar, networkPath) network = avatar.animationUpdater.network if network is not None: network.SetControlParameter('ControlParameters|BindPose', 1.0) if doll.gender == 'female': network.SetAnimationSetIndex(0) else: network.SetAnimationSetIndex(1) blue.pyos.synchro.SleepWallclock(500) avatar.animationUpdater.network.SetControlParameter( 'ControlParameters|isAlive', 0) avatar.animationUpdater.network.update = False blue.pyos.synchro.SleepWallclock(500) for checkBox in self.checkboxes: if not fromWebtools and not checkBox.GetValue(): continue if genderID == ccConst.GENDERID_MALE: mannequin.doll.Load( 'res:/Graphics/Character/DNAFiles/Mannequin/MaleMannequin.prs', self.factory) else: mannequin.doll.Load( 'res:/Graphics/Character/DNAFiles/Mannequin/FemaleMannequin.prs', self.factory) while mannequin.doll.busyUpdating: blue.synchro.Yield() lightScene = trinity.Load( 'res:/Graphics/Character/Global/PaperdollSettings/LightSettings/Normal.red' ) ccUtil.SetupLighting(scene, lightScene, lightColorScene, lightIntensity) category = checkBox.name typeData = characterSvc.GetAvailableTypesByCategory( category, genderID, -1) cameraSetup = self.SetUpCamera(camera, category, mannequin, SETUP, scene, lightColorScene, lightIntensity) for itemType in typeData: typeID = itemType[2] if typeID in (None, -1): continue asset = GetPaperDollResource(typeID, genderID) path = asset.resPath modifier = doll.SetItemType(self.factory, path, weight=1.0) mannequin.Update() while doll.busyUpdating: blue.synchro.Yield() if paperDoll.SkinSpotLightShadows.instance is not None: paperDoll.SkinSpotLightShadows.instance.Clear( killThread=True) del paperDoll.SkinSpotLightShadows.instance paperDoll.SkinSpotLightShadows.instance = None ss = paperDoll.SkinSpotLightShadows( scene, debugVisualize=False, size=2048) ss.SetupSkinnedObject(avatar) paperDoll.SkinSpotLightShadows.instance = ss blue.pyos.synchro.SleepWallclock(500) if fromWebtools: outputPath = '%s/EVE/capture/Screenshots/Renders/%s.png' % ( blue.win32.SHGetFolderPath( blue.win32.CSIDL_PERSONAL), typeID) else: assetResPath = path.replace('/', '_').replace( '.type', '') outputPath = 'C:/Temp/Thumbnails/%s_%s.png' % ( gender, assetResPath) self.SaveScreenShot(outputPath) doll.RemoveResource(modifier.GetResPath(), self.factory) if tryout: break if avatar and avatar in scene.dynamics: scene.dynamics.remove(avatar) for bloodlineCB in self.bloodlines: if fromWebtools or not bloodlineCB.GetValue(): continue characterSvc.RemoveCharacter(charID) bloodlineID = bloodlineCB.bloodlineID uicore.layer.charactercreation.ResetDna() characterSvc.AddCharacterToScene( charID, scene, ccUtil.GenderIDToPaperDollGender(genderID), bloodlineID=bloodlineID) doll = characterSvc.GetSingleCharactersDoll(charID) doll.overrideLod = paperDoll.LOD_SKIN doll.textureResolution = ccConst.TEXTURE_RESOLUTIONS[1] characterSvc.SetDollBloodline(charID, bloodlineID) characterSvc.ApplyItemToDoll( charID, 'head', paperDollUtil.bloodlineAssets[bloodlineID], doUpdate=False) characterSvc.UpdateDoll(charID, fromWhere='RenderLoop') character = characterSvc.GetSingleCharacter(charID) character.avatar.translation = (0.0, 0.0, 0.0) doll = character.doll while len(scene.dynamics) < 1: blue.synchro.Yield() blue.synchro.Yield() while doll.busyUpdating: blue.synchro.Yield() character.avatar.animationUpdater.network.SetControlParameter( 'ControlParameters|isAlive', 0) character.avatar.animationUpdater.network.update = False trinity.WaitForResourceLoads() for checkBox in self.checkboxes: lightScene = trinity.Load( 'res:/Graphics/Character/Global/PaperdollSettings/LightSettings/Normal.red' ) ccUtil.SetupLighting(scene, lightScene, lightColorScene, lightIntensity) if not checkBox.GetValue(): continue category = checkBox.name typeData = characterSvc.GetAvailableTypesByCategory( category, genderID, bloodlineID) cameraSetup = self.SetUpCamera(camera, category, character, SETUP, scene, lightColorScene, lightIntensity) removeDcModifers = [] if category in DRESSCODE: for dcCategory in DRESSCODE[category]: dcTypeData = characterSvc.GetAvailableTypesByCategory( dcCategory, genderID, bloodlineID) if dcTypeData: useIndex = DRESSCODEINDEX.get(dcCategory, 0) if type(useIndex) in types.StringTypes: for _idx, _itemType in enumerate( dcTypeData): if useIndex in _itemType[1][0]: useIndex = _idx break else: useIndex = -1 dcItemType = dcTypeData[useIndex] var = None if dcCategory == ccConst.hair: var = self.GetHairColor( genderID, bloodlineID) dcModifier = characterSvc.ApplyTypeToDoll( charID, dcItemType, rawColorVariation=var) if dcModifier: removeDcModifers.append( dcModifier.GetResPath()) while doll.busyUpdating: blue.synchro.Yield() blue.resMan.Wait() for itemType in typeData: modifer = characterSvc.ApplyTypeToDoll( charID, itemType) if not modifer: continue typeInfo = itemType[1] if typeInfo[0].startswith('scars'): self.SetCameraForScar(typeInfo, character, camera) if typeInfo[0].startswith(PIERCINGCATEGORIES): self.SetCameraAndLightPiercings( category, typeInfo, character, camera, scene, lightColorScene, lightIntensity) if category in TUCKINDEX: tuckPath, requiredModifier, subKey = ccConst.TUCKMAPPING[ category] tuckModifier = sm.GetService( 'character').GetModifierByCategory( charID, tuckPath) if tuckModifier: tuckVariations = tuckModifier.GetVariations() tuckStyle = tuckModifier.GetResPath().split( '/')[-1] characterSvc.ApplyItemToDoll( charID, category, tuckStyle, variation=tuckVariations[ TUCKINDEX[category]]) cat = category if category in (ccConst.beard, ccConst.hair, ccConst.eyebrows): cat = ccConst.hair try: if not typeInfo[1] and not typeInfo[2]: categoryColors = characterSvc.GetAvailableColorsForCategory( cat, genderID, bloodlineID) if categoryColors: primary, secondary = categoryColors primaryVal = (primary[1][0], primary[1][2]) if primary and secondary: secondaryVal = (secondary[1][0], secondary[1][2]) characterSvc.SetColorValueByCategory( charID, cat, primaryVal, secondaryVal) else: characterSvc.SetColorValueByCategory( charID, cat, primaryVal, None) except: pass if category in (ccConst.beard, ccConst.hair, ccConst.eyebrows): sm.GetService('character').SetHairDarkness(0, 0.5) if (category, genderID) in EXAGGERATE: if getattr(modifer, 'weight', None) is not None: modifer.weight = 1.5 * modifer.weight characterSvc.UpdateDoll(charID, fromWhere='RenderLoop') while doll.busyUpdating: blue.synchro.Yield() blue.resMan.Wait() trinity.WaitForResourceLoads() if paperDoll.SkinSpotLightShadows.instance is not None: paperDoll.SkinSpotLightShadows.instance.Clear( killThread=True) del paperDoll.SkinSpotLightShadows.instance paperDoll.SkinSpotLightShadows.instance = None ss = paperDoll.SkinSpotLightShadows( scene, debugVisualize=False, size=2048) ss.SetupSkinnedObject(character.avatar) paperDoll.SkinSpotLightShadows.instance = ss if tryout: break blue.pyos.synchro.SleepWallclock(500) outputPath = 'C:/Temp/Thumbnails/%s_g%s_b%s.png' % ( '_'.join(list(itemType[1])).replace( '/', '_'), genderID, bloodlineID) self.SaveScreenShot(outputPath) doll.RemoveResource(modifer.GetResPath(), characterSvc.factory) for dcResPath in removeDcModifers: doll.RemoveResource(dcResPath, characterSvc.factory) if tryout: break if tryout: break uicore.layer.main.display = True print 'DONE' prefs.NoRandomize = self.oldNonRandomize