Example #1
0
 def DoPreProcessEffectForPhotoSvc(self, size):
     renderTarget = trinity.Tr2RenderTarget(2 * size, size, 0, trinity.PIXEL_FORMAT.B8G8R8A8_UNORM)
     vp = trinity.TriViewport()
     vp.width = 2 * size
     vp.height = size
     if not self.LoadRedFiles():
         return
     trinity.WaitForResourceLoads()
     heightMapParam1 = self.__GetBakeShaderParameter('NormalHeight1', 'trinity.TriTextureParameter')
     if heightMapParam1 is not None:
         heightMapParam1.resourcePath = self.heightMapResPath1
     heightMapParam2 = self.__GetBakeShaderParameter('NormalHeight2', 'trinity.TriTextureParameter')
     if heightMapParam2 is not None:
         heightMapParam2.resourcePath = self.heightMapResPath2
     renderTargetSizeParam = self.__GetBakeShaderParameter('TargetTextureHeight', 'trinity.TriTextureParameter')
     if renderTargetSizeParam is not None:
         renderTargetSizeParam.value = size
     trinity.WaitForResourceLoads()
     rj = trinity.CreateRenderJob('Height normal Compositing')
     rj.PushRenderTarget(renderTarget)
     rj.SetViewport(vp)
     rj.PushDepthStencil(None)
     rj.Clear((0.0, 0.0, 0.0, 0.0))
     rj.RenderEffect(self.effectHeight)
     rj.PopDepthStencil()
     rj.PopRenderTarget()
     rj.GenerateMipMaps(renderTarget)
     rj.ScheduleOnce()
     rj.WaitForFinish()
     tex = trinity.TriTextureRes()
     tex.CreateAndCopyFromRenderTarget(renderTarget)
     heightMapParamList = self.__GetPlanetShaderParameters('HeightMap', 'trinity.TriTextureParameter')
     for heightMapParam in heightMapParamList:
         heightMapParam.SetResource(tex)
Example #2
0
    def DoPreProcessEffect(self, size, format, renderTarget):
        if renderTarget is None:
            self.model.resourceActionPending = False
            self.model.ready = True
            return
        vp = trinity.TriViewport()
        vp.width = 2 * size
        vp.height = size
        trinity.WaitForResourceLoads()
        if self.model is None:
            return
        if len(self.modelRes) == 0:
            if not self.LoadRedFiles():
                self.model.resourceActionPending = False
                self.model.ready = True
                return
        else:
            self.__ReloadLargeResources()
        heightMapParam1 = self.__GetBakeShaderParameter('NormalHeight1', 'trinity.TriTextureParameter')
        if heightMapParam1 is not None:
            heightMapParam1.resourcePath = self.heightMapResPath1
        heightMapParam2 = self.__GetBakeShaderParameter('NormalHeight2', 'trinity.TriTextureParameter')
        if heightMapParam2 is not None:
            heightMapParam2.resourcePath = self.heightMapResPath2
        renderTargetSizeParam = self.__GetBakeShaderParameter('TargetTextureHeight', 'trinity.TriTextureParameter')
        if renderTargetSizeParam is not None:
            renderTargetSizeParam.value = size
        trinity.WaitForResourceLoads()
        if self.model is None:
            return
        rj = trinity.CreateRenderJob('Height normal Compositing')
        rj.PushRenderTarget(renderTarget)
        rj.SetViewport(vp)
        rj.PushDepthStencil(None)
        step = rj.Clear((0.0, 0.0, 0.0, 0.0), 1.0)
        step.isDepthCleared = False
        rj.RenderEffect(self.effectHeight)
        rj.PopDepthStencil()
        rj.PopRenderTarget()
        rj.GenerateMipMaps(renderTarget)
        rj.ScheduleOnce()
        rj.WaitForFinish()
        if self.model is None:
            return
        tex = trinity.TriTextureRes()
        tex.CreateAndCopyFromRenderTargetWithSize(renderTarget, size * 2, size)
        if heightMapParam1 is not None:
            heightMapParam1.resourcePath = ''
            heightMapParam1.SetResource(None)
        if heightMapParam2 is not None:
            heightMapParam2.resourcePath = ''
            heightMapParam2.SetResource(None)
        heightMapParamList = self.__GetPlanetShaderParameters('HeightMap', 'trinity.TriTextureParameter')
        for heightMapParam in heightMapParamList:
            heightMapParam.SetResource(tex)

        self.model.ready = True
        self.model.resourceActionPending = False
    def ApplyMaterials(self, entity, component):
        if component.renderObject is None:
            return
        placeableRes = component.renderObject.placeableRes
        if placeableRes is None:
            return
        if placeableRes.visualModel is None:
            return
        isLoading = False
        for m in placeableRes.visualModel.meshes:
            if m.geometry is not None and not m.geometry.isGood:
                isLoading = True
                break

        if isLoading:
            trinity.WaitForResourceLoads()
        if component.minSpecOverideMetaMaterialPath is not None and component.minSpecOverideMetaMaterialPath != 'None' and sm.GetService(
                'device').GetAppFeatureState(
                    'Interior.lowSpecMaterialsEnabled', False):
            materialRes = metaMaterials.LoadMaterialRes(
                component.minSpecOverideMetaMaterialPath)
            metaMaterials.ApplyMaterialRes(component.renderObject, materialRes)
        elif component.overrideMetaMaterialPath is not None and component.minSpecOverideMetaMaterialPath != 'None':
            materialRes = metaMaterials.LoadMaterialRes(
                component.overrideMetaMaterialPath)
            metaMaterials.ApplyMaterialRes(component.renderObject, materialRes)
        else:
            metaMaterials.LoadAndApplyMaterialRes(component.renderObject)
Example #4
0
def _RebuildTurret(turret):
    turret.FreezeHighDetailLOD()
    trinity.WaitForResourceLoads()
    turret.boundingSphere = (-1, -1, -1, -1)
    turret.RebuildBoundingSphere()
    if turret.boundingSphere[3] <= 0:
        raise BoundingSphereRadiusZeroError(turret.geometryResPath)
Example #5
0
 def LoadScene(self, sceneContainer):
     sceneContainer.PrepareSpaceScene(scenePath=self.scenePath)
     resFile = inventorycommon.typeHelpers.GetGraphicFile(self.typeID)
     modelDNA = None
     if evetypes.GetCategoryID(
             self.typeID) == invconst.categoryStation and self.itemID:
         stations = cfg.mapSolarSystemContentCache.npcStations
         npcStation = stations.get(self.itemID, None)
         if npcStation:
             graphicID = npcStation.graphicID
             modelDNA = gfxutils.BuildSOFDNAFromGraphicID(graphicID)
     if modelDNA is None:
         modelDNA = gfxutils.BuildSOFDNAFromTypeID(
             self.typeID, materialSetID=self.materialSetID)
     if modelDNA is not None:
         spaceObjectFactory = sm.GetService('sofService').spaceObjectFactory
         model = spaceObjectFactory.BuildFromDNA(modelDNA)
     else:
         model = trinity.Load(resFile)
     if model is None:
         raise InvalidPreviewType(
             '%s (%s) failed to load associated model' %
             (evetypes.GetName(self.typeID), self.typeID))
     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
     SetupAnimations(model, self.typeID)
     model.FreezeHighDetailMesh()
     trinity.WaitForResourceLoads()
     sceneContainer.AddToScene(model)
     SetupSpaceCamera(sceneContainer, model)
def YamlStrToTrinObj(yamlstr):
    """Returns a trinity object loaded from a yaml string and does some other
    cargo cult stuff (waits for resource loads,
    tests prune/pop on tr2effects, etc.)."""
    trinobj = trinparser.DictToTrinityParser(yamlext.loads(yamlstr))
    trinity.WaitForResourceLoads()
    return trinobj
Example #7
0
    def _LoadSpherePinResources(self):
        """
        This thread bulk loads EveSpherePin resources, so we don't have to yield during
        the creation of UI pins, which was causing nasty race conditions
        """
        while True:
            trinity.WaitForResourceLoads()
            while self.spherePinsPendingLoad:
                spherePin, textureName = self.spherePinsPendingLoad.pop()
                spherePin.pinEffect.PopulateParameters()
                for res in spherePin.pinEffect.resources:
                    if res.name == 'Layer1Map':
                        res.resourcePath = textureName
                    elif res.name == 'Layer2Map':
                        res.resourcePath = 'res:/dx9/texture/UI/pinCircularRamp.dds'

                spherePin.pickEffect.PopulateParameters()
                for res in spherePin.pickEffect.resources:
                    if res.name == 'Layer1Map':
                        res.resourcePath = textureName

                spherePin.pinColor = spherePin.pinColor
                spherePin.geometryResPath = 'res:/dx9/model/worldobject/planet/PlanetSphere.gr2'

            blue.pyos.synchro.Yield()
Example #8
0
def CreateMaterialResFromAreas(ob, defaultMetatype):
    trinity.WaitForResourceLoads()
    meshes = GetMeshList(ob)
    if not meshes:
        return
    materialRes = trinity.Tr2MaterialRes()
    for mesh in meshes:
        geo = mesh.geometry
        meshStore = trinity.Tr2MaterialMesh()
        materialRes.meshes[mesh.name] = meshStore
        for areaIdx in xrange(geo.GetMeshAreaCount(mesh.meshIndex)):
            areaName = geo.GetMeshAreaName(mesh.meshIndex, areaIdx)
            areaStore = trinity.Tr2MaterialArea()
            areaStore.metatype = str(defaultMetatype)
            areaStore.material = trinity.Tr2MaterialParameterStore()
            meshStore.areas[areaName] = areaStore
            params = GetParametersFromMeshArea(mesh, areaIdx, None)
            for p in params:
                if params[p].value is not None:
                    try:
                        if params[p].value is not params[p].default:
                            areaStore.material.parameters[p] = params[p].value
                    except TypeError:
                        pass

    return materialRes
Example #9
0
    def LoadPlanet(self):
        self.LogInfo('LoadPlanet planet', self.planetID, 'type', self.typeID,
                     'system', self.solarSystemID)
        planet = Planet()
        graphicFile = inventorycommon.typeHelpers.GetGraphicFile(self.typeID)
        planet.typeData['graphicFile'] = graphicFile
        planet.typeID = self.typeID
        planet.LoadPlanet(self.planetID,
                          forPhotoService=True,
                          rotate=False,
                          hiTextures=True)
        self.trinityPlanet = planet
        if planet.model is None or planet.model.highDetail is None:
            return
        planetTransform = trinity.EveTransform()
        planetTransform.name = 'planet'
        planetTransform.scaling = (PLANET_SCALE, PLANET_SCALE, PLANET_SCALE)
        planetTransform.children.append(planet.model.highDetail)
        self.PreProcessPlanet()
        scene = self.planetScene
        trinity.WaitForResourceLoads()
        for t in planet.model.highDetail.children:
            if t.mesh is not None:
                if len(t.mesh.transparentAreas) > 0:
                    t.sortValueMultiplier = 2.0

        scene.sunDirection = (0.0, 0.0, 1.0)
        scene.sunDiffuseColor = (1.0, 1.0, 1.0, 1.0)
        self.planetTransform = planetTransform
        self.planetRoot.children.append(self.planetTransform)
Example #10
0
    def EnableResourceLayer(self):
        if self.planetTransform is not None:
            if self.resourceLayer is None:
                self.LogInfo(
                    '_ShowResource no resourceLayer found. Loading resource layer'
                )
                self.resourceLayer = trinity.Load(
                    'res:/dx9/model/worldobject/planet/uiplanet.red')
                trinity.WaitForResourceLoads()
                effect = self.resourceLayer.mesh.transparentAreas[0].effect
                for resource in effect.resources:
                    if resource.name == 'ColorRampMap':
                        resource.resourcePath = 'res:/dx9/model/worldobject/planet/resource_colorramp.dds'

                for param in effect.parameters:
                    if param.name == 'MainColor':
                        param.value = RESOURCE_BASE_COLOR
                    elif param.name == 'ResourceTextureInfo':
                        param.value = (PLANET_RESOURCE_TEX_WIDTH,
                                       PLANET_RESOURCE_TEX_HEIGHT, 0, 0)

                offset = trinity.Tr2FloatParameter()
                offset.name = 'HeatOffset'
                offset.value = 0.0
                effect.parameters.append(offset)
                stretch = trinity.Tr2FloatParameter()
                stretch.name = 'HeatStretch'
                stretch.value = 1.0
                effect.parameters.append(stretch)
                self.planetTransform.children.append(self.resourceLayer)
            else:
                self.resourceLayer.display = True
            low, hi = settings.char.ui.Get('planet_resource_display_range',
                                           (0.0, 1.0))
            self.SetResourceDisplayRange(low, hi)
    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)
Example #12
0
 def GetZoomValues(self, model, thread):
     rad = 300
     camera = self.sceneManager.GetRegisteredCamera(self.name)
     trinity.WaitForResourceLoads()
     rad = model.GetBoundingSphereRadius()
     center = model.boundingSphereCenter
     localBB = model.GetLocalBoundingBox()
     if localBB[0] is None or localBB[1] is None:
         log.LogError(
             "Failed to get bounding info for ship. Odds are the ship wasn't loaded properly."
         )
         localBB = (trinity.TriVector(0, 0, 0), trinity.TriVector(0, 0, 0))
     model.translationCurve = trinity.TriVectorCurve()
     negativeCenter = (-center[0], -localBB[0].y + 180.0, -center[2])
     model.translationCurve.value = negativeCenter
     cameraparent = self.GetCameraParent()
     if cameraparent.translationCurve is not None:
         keyValue = cameraparent.translationCurve.keys[1].value
         if self.staticEnv:
             keyValue = (keyValue[0], -localBB[0].y + 180.0, keyValue[2])
         cameraparent.translationCurve.keys[0].value = keyValue
         key1Value = cameraparent.translationCurve.keys[1].value
         key1Value = (key1Value[0], -localBB[0].y + 180.0, key1Value[2])
         cameraparent.translationCurve.keys[1].value = key1Value
         cameraparent.translationCurve.start = blue.os.GetSimTime()
     zoomMultiplier = 1.0
     aspectRatio = trinity.GetAspectRatio()
     if aspectRatio > 1.6:
         zoomMultiplier = aspectRatio / 1.6
     self.minZoom = (rad + camera.frontClip + 50) * zoomMultiplier
     self.maxZoom = 2050.0
     self.layer.maxZoom = self.maxZoom
     self.layer.minZoom = self.minZoom
     return (rad + camera.frontClip) * 2
Example #13
0
 def TakeSnapShot_Render(self, scene, size, view, projection, transparentBackground = False, bgColor = None):
     self.LogInfo('TakeSnapShot_Render')
     if transparentBackground:
         bbFormat = trinity.PIXEL_FORMAT.B8G8R8A8_UNORM
         clearColor = bgColor or (0.0, 0.0, 0.0, 0.0)
     else:
         bbFormat = trinity.PIXEL_FORMAT.B8G8R8X8_UNORM
         clearColor = bgColor or (0.0, 0.0, 0.0, 1.0)
     dsFormat = trinity.DEPTH_STENCIL_FORMAT.AUTO
     renderTarget = trinity.Tr2RenderTarget(size, size, 1, bbFormat)
     depthStencil = trinity.Tr2DepthStencil(size, size, dsFormat)
     self.LogInfo('TakeSnapShot_Render_After_Resource_Creation')
     renderJob = trinity.CreateRenderJob('TakeSnapShot')
     renderJob.PushRenderTarget(renderTarget)
     renderJob.SetProjection(projection)
     renderJob.SetView(view)
     renderJob.PushDepthStencil(depthStencil)
     renderJob.Clear(clearColor, 1.0)
     renderJob.Update(scene)
     renderJob.RenderScene(scene)
     renderJob.PopDepthStencil()
     renderJob.PopRenderTarget()
     trinity.WaitForResourceLoads()
     renderJob.ScheduleOnce()
     renderJob.WaitForFinish()
     hostCopy = trinity.Tr2HostBitmap(renderTarget)
     hostCopy.name = 'TakeSnapeShot_Render'
     return hostCopy
 def DelayedRemove(self, model, delay):
     """In X ms delete the model, this allows for lazy unloading of assets. """
     model.name = model.name + '_removing'
     model.display = False
     trinity.WaitForResourceLoads()
     blue.pyos.synchro.SleepWallclock(delay)
     self.RemoveAndClearModel(model)
    def LoadPlanet(self, planetTypeID, planetID):
        planet = Planet()
        objType = cfg.invtypes.Get(planetTypeID)
        graphicFile = objType.GraphicFile()
        planet.typeData['graphicFile'] = graphicFile
        planet.typeID = planetTypeID
        planet.LoadPlanet(planetID,
                          forPhotoService=True,
                          rotate=False,
                          hiTextures=True)
        if planet.model is None or planet.model.highDetail is None:
            return
        planetTransform = trinity.EveTransform()
        planetTransform.name = 'planet'
        planetTransform.children.append(planet.model.highDetail)
        renderTarget, size = self.CreateRenderTarget()
        planet.DoPreProcessEffect(size, None, renderTarget)
        trinity.WaitForResourceLoads()
        for t in planet.model.highDetail.children:
            if t.mesh is not None:
                if len(t.mesh.transparentAreas) > 0:
                    t.sortValueMultiplier = 2.0

        self.systemMapTransform.children.append(planetTransform)
        return planetTransform
Example #16
0
 def RenderNormalType(self, bloodlineID, camera, category, character, genderID, itemType, scene):
     typeID = itemType[2]
     if typeID is not None:
         if not self.renderTypesCb.GetValue():
             return False
         typeIDs = self.GetTypeIDsFromField()
         if typeIDs and typeID not in typeIDs:
             return False
     doll = character.doll
     modifer = self.characterSvc.ApplyTypeToDoll(self.charID, itemType)
     if not modifer:
         return False
     typeInfo = itemType[1]
     if typeInfo[0].startswith('scars'):
         self.SetCameraForScar(typeInfo, character, camera, scene)
     if typeInfo[0].startswith(PIERCINGCATEGORIES):
         self.SetCameraAndLightPiercings(category, typeInfo, character, camera, scene)
     self.ApplyTuckingIfNeeded(category)
     self.TrySetColor(bloodlineID, category, genderID, typeInfo)
     if (category, genderID) in EXAGGERATE:
         if getattr(modifer, 'weight', None) is not None:
             modifer.weight = 1.5 * modifer.weight
     self.characterSvc.UpdateDoll(self.charID, fromWhere='RenderLoop')
     self.SetShadow(character.avatar, scene)
     blue.pyos.synchro.SleepWallclock(500)
     self.WaitForDoll(doll)
     blue.resMan.Wait()
     trinity.WaitForResourceLoads()
     path = '_'.join(list(itemType[1]))
     outputPath = self.GetOutputPath(assetPath=path, genderID=genderID, category=category, bloodlineID=bloodlineID, typeID=typeID)
     renderRGB = self.rgbCB.GetValue()
     self.SaveScreenShot(outputPath, rgb=renderRGB)
     doll.RemoveResource(modifer.GetResPath(), self.factory)
     return True
Example #17
0
    def GetPlanetPhoto(self, itemID, typeID, size=512):
        graphicID = evetypes.GetGraphicID(typeID)
        outPath = GetCachePath(typeID, graphicID, size, itemID)
        planet = Planet()
        planet.GetPlanetByID(itemID, typeID)
        if planet.model is None or planet.model.highDetail is None:
            return NOT_AVAILABLE_PATH
        planetTransform = trinity.EveTransform()
        planetTransform.scaling = (100.0, 100.0, 100.0)
        planetTransform.children.append(planet.model.highDetail)
        scene = self.GetPlanetScene()
        try:
            planet.DoPreProcessEffectForPhotoSvc(size)
        except:
            del planetTransform.children[:]
            return NOT_AVAILABLE_PATH

        trinity.WaitForResourceLoads()
        scene.sunDirection = (-1.0, 0.0, 0.0)
        scene.sunDiffuseColor = (1.0, 1.0, 1.0, 1.0)
        scene.objects.append(planetTransform)
        view, projection = camera_util.GetViewAndProjectionUsingBoundingSphere(
            boundingSphereRadius=130)
        bitmap = photo.RenderToSurface(view,
                                       projection,
                                       size,
                                       scene,
                                       transparent=False)
        bitmap.Save(outPath)
        del planetTransform.children[:]
        self._RemovePathFromNotAvailList(outPath)
        return outPath
Example #18
0
def _RebuildSofHull(sofhull):
    expandedPath = respathutils.ExpandResPath(sofhull.geometryResFilePath)
    hullresource = blue.resMan.GetResource(expandedPath)
    trinity.WaitForResourceLoads()
    hullresource.RecalculateBoundingSphere()
    bSphereCenter, bSphereRad = hullresource.GetBoundingSphere(0)
    sofhull.boundingSphere = (bSphereCenter[0], bSphereCenter[1],
                              bSphereCenter[2], bSphereRad)
Example #19
0
def _RebuildMissile(missile):
    missile.FreezeHighDetailMesh()
    trinity.WaitForResourceLoads()
    missile.boundingSphereRadius = -1
    missile.RebuildMissileBoundingSphere()
    if missile.boundingSphereRadius <= 0:
        res = missile.warheads[0].mesh.geometryResPath
        raise BoundingSphereRadiusZeroError(res)
Example #20
0
def _RebuildShip(ship):
    ship.FreezeHighDetailMesh()
    trinity.WaitForResourceLoads()
    ship.boundingSphereRadius = -1
    ship.RebuildBoundingSphereInformation()
    if ship.boundingSphereRadius <= 0:
        respath = '<No mesh>'
        if ship.meshLod:
            respath = ship.meshLod.geometryRes.highDetailResPath
        raise BoundingSphereRadiusZeroError(respath)
Example #21
0
 def PrepareBloodlineDoll(self, bloodlineID, paperdollGender, scene):
     self.characterSvc.RemoveCharacter(self.charID)
     uicore.layer.charactercreation.ResetDna()
     self.SetupCharacter(bloodlineID, scene, paperdollGender)
     character = self.characterSvc.GetSingleCharacter(self.charID)
     character.avatar.translation = (0.0, 0.0, 0.0)
     self.WaitForDollAndScene(character.doll, scene)
     self.FreezeCharacter(character.avatar)
     trinity.WaitForResourceLoads()
     return character
Example #22
0
 def PlaceShip(self, model, typeID):
     self.model = model
     trinity.WaitForResourceLoads()
     self.InitModelPosition()
     boundingBoxYBottom = self.GetBoundingBoxYBottom(model)
     translation = geo2.Vec3Subtract(self.shipAnchorPoint,
                                     (0.0, boundingBoxYBottom, 0.0))
     offset = geo2.Vec3Scale(self.model.GetBoundingSphereCenter(), 0.5)
     self.model.translationCurve.value = geo2.Vec3Add(translation, offset)
     self.endPos = self.model.translationCurve.value
     uicore.animations.StopAnimation(self.model.translationCurve, 'value')
 def __init__(self, trinobj, pumpBlue=False, passes=2, time=3.0):
     trinity.WaitForResourceLoads()
     self._passes = passes
     self._time = time
     self.redNodeMutated = trinobj.CopyTo()
     self.redNodeCopy = trinobj.CopyTo()
     self.systems = self.redNodeMutated.Find('trinity.Tr2ParticleSystem')
     self.curveSets = self.redNodeMutated.Find('trinity.TriCurveSet')
     self.activeIndex = [0]
     self._ets = []
     self.started = [False]
     self._pumpBlue = pumpBlue
     self._CollectMeshes()
Example #24
0
 def PlaceShip(self, model, typeID):
     model.translationCurve = trinity.TriVectorCurve()
     trinity.WaitForResourceLoads()
     localBB = model.GetLocalBoundingBox()
     width = abs(localBB[0][0])
     if evetypes.GetGroupID(typeID) == const.groupTitan:
         width += 2000
     self.endPos = geo2.Vec3Add(self.shipAnchorPoint, (width, 0.0, 0.0))
     model.translationCurve.value = self.endPos
     self.ApplyShipBobbing(model,
                           (0.0, model.translationCurve.value[1], 0.0),
                           (0.0, 250.0, 0.0),
                           model.GetBoundingSphereRadius())
Example #25
0
def UpdateStationLogo(width, height, desktop, entityID):
    desktop.Flush()
    desktop.renderObject.backgroundColor = (0, 0, 0, 0)
    corpID = eve.stationItem.ownerID
    logo = uiutil.GetLogoIcon(itemID=corpID,
                              parent=desktop,
                              acceptNone=False,
                              state=uiconst.UI_DISABLED,
                              width=128,
                              height=128,
                              align=uiconst.CENTER)
    trinity.WaitForResourceLoads()
    desktop.UpdateAlignmentAsRoot()
Example #26
0
 def ChangeModel(self, fileName, delay = 0):
     if self.currentModel == fileName:
         return
     oldModel = self.model
     self.buildAnim = None
     self.onlineAnim = None
     spaceObject.SpaceObject.LoadModel(self, fileName)
     self.currentModel = fileName
     trinity.WaitForResourceLoads()
     self.PrepareAnimationSetupFor(fileName)
     self.model.display = True
     if oldModel != None and oldModel != self.model:
         oldModel.display = False
         if delay == 0:
             self.DelayedRemove(oldModel, 0)
         else:
             uthread.pool('SovereigntyClaimMarker::DelayedRemove', self.DelayedRemove, oldModel, int(delay))
Example #27
0
 def GetPortraitTexture(self, portraitID):
     size = 512
     sceneManager = sm.GetService('sceneManager')
     scene = sceneManager.GetActiveScene()
     backdropPath = self.backdropPath
     if backdropPath:
         backdropScene = trinity.Tr2Sprite2dScene()
         backdropScene.displayWidth = size
         backdropScene.displayHeight = size
         sprite = trinity.Tr2Sprite2d()
         sprite.texturePrimary = trinity.Tr2Sprite2dTexture()
         sprite.texturePrimary.resPath = backdropPath
         sprite.displayWidth = size
         sprite.displayHeight = size
         backdropScene.children.append(sprite)
     target = trinity.Tr2RenderTarget(size, size, 1,
                                      trinity.PIXEL_FORMAT.B8G8R8X8_UNORM)
     depth = trinity.Tr2DepthStencil(size, size,
                                     trinity.DEPTH_STENCIL_FORMAT.AUTO)
     renderJob = trinity.CreateRenderJob('TakeSnapShot')
     renderJob.PushRenderTarget(target)
     renderJob.PushDepthStencil(depth)
     projection = trinity.TriProjection()
     projection.PerspectiveFov(self.camera.fieldOfView, 1, 0.1, 5.0)
     view = self.camera.viewMatrix
     renderJob.Clear((0.0, 0.0, 0.0, 1.0), 1.0)
     renderJob.SetProjection(projection)
     renderJob.SetView(view)
     if backdropPath:
         renderJob.Update(backdropScene)
         renderJob.RenderScene(backdropScene)
     renderJob.RenderScene(scene)
     trinity.WaitForResourceLoads()
     renderJob.PopDepthStencil()
     renderJob.PopRenderTarget()
     renderJob.ScheduleOnce()
     renderJob.WaitForFinish()
     filename = self.GetPortraitSnapshotPath(portraitID)
     trinity.Tr2HostBitmap(target).Save(filename)
     path = 'cache:/Pictures/Portraits/PortraitSnapshot_%s_%s.jpg' % (
         portraitID, session.userid)
     blue.motherLode.Delete(path)
     tex = blue.resMan.GetResource(path, 'atlas')
     return tex
Example #28
0
    def PosesAndLightThumbnails(self, bloodlineID, altCategory, camera, genderID, scene):
        self.characterSvc.RemoveCharacter(self.charID)
        uicore.layer.charactercreation.ResetDna()
        paperdollGender = ccUtil.GenderIDToPaperDollGender(genderID)
        self.SetupCharacter(bloodlineID, scene, paperdollGender)
        for dcCategory in DRESSCODE[ccConst.hair]:
            dcTypeData = self.characterSvc.GetAvailableTypesByCategory(dcCategory, genderID, bloodlineID)
            if dcTypeData:
                dcItemType = dcTypeData[0]
                dcModifier = self.characterSvc.ApplyTypeToDoll(self.charID, dcItemType)

        character = self.characterSvc.GetSingleCharacter(self.charID)
        self.WaitForDollAndScene(character.doll, scene)
        trinity.WaitForResourceLoads()
        camera.SetFieldOfView(0.3)
        if altCategory == 'poses':
            self.RenderPoseThumbnails(bloodlineID, camera, character, genderID)
        elif altCategory == 'lights':
            self.RenderLightThumbnails(bloodlineID, camera, genderID)
Example #29
0
 def ReloadShipModel(self, throttle = False, animate = True):
     if self.destroyed:
         return
     with self._reloadLock:
         if throttle:
             newModel = self.CreateActiveShipModelThrottled()
         else:
             newModel = self.CreateActiveShipModel()
         if not newModel:
             return
         newModel.FreezeHighDetailMesh()
         trinity.WaitForResourceLoads()
         self.AddToScene(newModel)
         if animate:
             self.AnimEntry()
         if isinstance(self.controller.dogmaLocation.GetCurrentShipID(), basestring):
             _ApplyIsisEffect(newModel, isSkinned=False)
             grid = trinity.Load('res:/dx9/model/UI/ScanGrid.red')
             grid.scaling = (4, 4, 4)
             self.scene.objects.append(grid)
         camera = self.camera
         rad = newModel.GetBoundingSphereRadius()
         minZoom = rad + camera.nearClip
         alpha = camera.fov / 2.0
         maxZoom = min(self.backClip - rad, rad * (1 / math.tan(alpha)) * 2)
         oldZoomDistance = self.minZoom + (self.maxZoom - self.minZoom) * self.zoom
         defaultZoom = minZoom / (maxZoom - minZoom)
         self.SetMinMaxZoom(minZoom, maxZoom)
         if animate or oldZoomDistance < minZoom or oldZoomDistance > maxZoom:
             self.SetZoom(defaultZoom)
         shipTypeID = self.controller.GetTypeID()
         stanceBtnControllerClass = self.controller.GetStanceBtnControllerClass()
         stanceID = stanceBtnControllerClass().get_ship_stance(self.controller.GetItemID(), shipTypeID)
         animationStates = []
         if evetypes.Exists(shipTypeID):
             animationStates = inventorycommon.typeHelpers.GetAnimationStates(shipTypeID)
         spaceobjanimation.LoadAnimationStates(animationStates, cfg.graphicStates, newModel, trinity)
         if newModel.animationSequencer is not None:
             newModel.animationSequencer.GoToState('normal')
             spaceobjanimation.SetShipAnimationStance(newModel, stanceID)
         if not self.controller.IsSimulated():
             self.UpdateHardpoints(newModel)
Example #30
0
    def _LoadSpherePinResources(self):
        while True:
            trinity.WaitForResourceLoads()
            while self.spherePinsPendingLoad:
                spherePin, textureName = self.spherePinsPendingLoad.pop()
                spherePin.pinEffect.PopulateParameters()
                for res in spherePin.pinEffect.resources:
                    if res.name == 'Layer1Map':
                        res.resourcePath = textureName
                    elif res.name == 'Layer2Map':
                        res.resourcePath = 'res:/dx9/texture/UI/pinCircularRamp.dds'

                spherePin.pickEffect.PopulateParameters()
                for res in spherePin.pickEffect.resources:
                    if res.name == 'Layer1Map':
                        res.resourcePath = textureName

                spherePin.pinColor = spherePin.pinColor
                spherePin.geometryResPath = 'res:/dx9/model/worldobject/planet/PlanetSphere.gr2'

            blue.pyos.synchro.Yield()