Exemple #1
0
    def __CreateBakeEffect(self):
        self.effectHeight = trinity.Tr2Effect()
        if self.effectHeight is None:
            self.logger.error('Could not create effect for planet with id %s', self.itemID)
            return
        mainMesh = self.model.highDetail.children[0].meshLod
        if mainMesh is None:
            mainMesh = self.model.highDetail.children[0].mesh
            errorMsg = 'No LODs found on planet.\n'
            errorMsg += 'modelPath=%s\n'
            errorMsg += 'presetPath=%s\n'
            errorMsg += 'shaderPreset=%s\n'
            self.logger.error(errorMsg, self.modelPath, self.presetPath, str(self.attributes.shaderPreset))
        if len(mainMesh.transparentAreas) > 0:
            resPath = mainMesh.transparentAreas[0].effect.effectFilePath
        elif len(mainMesh.opaqueAreas) > 0:
            resPath = mainMesh.opaqueAreas[0].effect.effectFilePath
        else:
            self.logger.error('Unexpected program flow! Loading fallback shader.')
            resPath = 'res:/Graphics/Effect/Managed/Space/Planet/EarthlikePlanet.fx'
        resPath = resPath.replace('.fx', 'BlitHeight.fx')
        self.effectHeight.effectFilePath = resPath
        if self.__GetHeightMap1() is not None and self.__GetHeightMap2() is not None:
            param1 = trinity.TriTextureParameter()
            param1.name = 'NormalHeight1'
            self.heightMapResPath1 = GetGraphicFile(self.__GetHeightMap1())
            self.effectHeight.resources.append(param1)
            param2 = trinity.TriTextureParameter()
            param2.name = 'NormalHeight2'
            self.heightMapResPath2 = GetGraphicFile(self.__GetHeightMap2())
            self.effectHeight.resources.append(param2)
            param3 = trinity.Tr2FloatParameter()
            param3.name = 'Random'
            param3.value = float(self.itemID % 100)
            self.effectHeight.parameters.append(param3)
            param4 = trinity.Tr2FloatParameter()
            param4.name = 'TargetTextureHeight'
            param4.value = 2048
            self.effectHeight.parameters.append(param4)
        paramList = self.__GetPlanetShaderParameters('', 'trinity.Tr2Vector4Parameter')
        for param in paramList:
            self.effectHeight.parameters.append(param)

        paramList = self.__GetPlanetShaderParameters('', 'trinity.Tr2FloatParameter')
        for param in paramList:
            self.effectHeight.parameters.append(param)

        resList = self.__GetPlanetShaderParameters('', 'trinity.TriTextureParameter')
        for res in resList:
            self.effectHeight.resources.append(res)
Exemple #2
0
 def LoadScene(self, shipTypeID):
     self.currentGraphicID = GetHangarGraphicID(self.GetStationType(), shipTypeID)
     stationGraphicFile = GetGraphicFile(self.currentGraphicID)
     if stationGraphicFile is None:
         self.LogError("Could not find a graphic file for graphicID '%s', returning and showing nothing" % self.currentGraphicID)
     scene, _ = self.sceneManager.LoadScene(stationGraphicFile, registerKey=ViewState.Hangar)
     return scene
Exemple #3
0
    def Prepare(self, wormholeItem, destNebulaPath, srcNebulaPath):
        if self.resPath is not None:
            self.model = trinity.Load(self.resPath)
        transition = sm.GetService('viewState').GetTransitionByName(
            'inflight', 'inflight')
        transition.InitializeWormholeTransition(
            GetGraphicFile(wormholeItem.nebulaType))
        self.transition = transition
        cubeParams = self.model.Find('trinity.TriTextureParameter')
        for cube in cubeParams:
            if cube.name == 'SourceNebulaMap':
                cube.resourcePath = srcNebulaPath
            elif cube.name == 'ReflectionMap':
                cube.resourcePath = destNebulaPath

        for each in self.model.curveSets:
            if each.name == 'start':
                self.startCS = each
            elif each.name == 'stop':
                self.stopCS = each
            elif each.name == 'middle':
                self.midCS = each

        transition.SetTransitionEffect(self)
        self.itemID = wormholeItem.itemID
        sceneMan = sm.GetService('sceneManager')
        self.camera = sceneMan.SetPrimaryCamera(evecamera.CAM_JUMP)
Exemple #4
0
 def __init__(self, trigger, effect=None, graphicFile=None):
     self.ballIDs = [trigger.shipID, trigger.targetID]
     self.gfx = None
     self.gfxModel = None
     self.graphicFile = graphicFile
     self.transformFlags = [0] if effect is None else effect.transformFlags
     self.mergeFlags = [0] if effect is None else effect.mergeFlags
     if trigger.duration is not None and trigger.duration > 0:
         self.duration = trigger.duration
     else:
         self.duration = getattr(effect, 'duration', 10000)
     if hasattr(effect, 'secondaryGraphicID'):
         self.secondaryGraphicFile = GetGraphicFile(
             getattr(effect, 'secondaryGraphicID'))
     else:
         self.secondaryGraphicFile = None
     self.scaleTime = getattr(effect, 'timeScale', False)
     self.sourceOffset = 0 if effect is None else effect.sourceOffset
     self.destinationOffset = 0 if effect is None else effect.destinationOffset
     self.animationName = None if effect is None else getattr(
         effect, 'animationName', None)
     self.graphicInfo = trigger.graphicInfo
     self.startTime = trigger.startTime
     self.timeFromStart = trigger.timeFromStart
     self.moduleID = trigger.moduleID
     self.fxSequencer = sm.GetService('FxSequencer')
     self.observer = None
Exemple #5
0
 def _LoadModel(self):
     path = GetGraphicFile(20984)
     model = blue.resMan.LoadObject(path)
     self.model = trinity.EveTransform()
     self.model.scaling = (10000.0, 10000.0, 10000.0)
     self.model.modifier = 2
     self.model.name = 'Supernova'
     self.model.children.append(model)
Exemple #6
0
def GetClassification(guid):
    effect = cfg.graphicEffects.get(guid, None)
    if effect is None:
        return
    classType = typeToClass.get(effect.type, None)
    graphicID = getattr(effect, 'graphicID', None)
    resPath = GetGraphicFile(graphicID)
    return (classType, effect, resPath)
Exemple #7
0
 def GetMenu(self, *args):
     if isinstance(self.sr.node.invtype, tuple):
         typeID = self.sr.node.invtype[0]
     else:
         typeID = self.sr.node.invtype
     groupID = evetypes.GetGroupID(typeID)
     catID = evetypes.GetCategoryIDByGroup(groupID)
     graphicID = evetypes.GetGraphicID(typeID)
     graphicFileMenu = []
     if evetypes.Exists(typeID) and evetypes.GetGraphicID(
             typeID) is not None:
         graphic = GetGraphic(evetypes.GetGraphicID(typeID))
         if graphic is not None:
             graphicFile = GetGraphicFile(graphic)
             graphicFileMenu = [
                 [
                     'Copy graphicID (%s)' % graphicID,
                     lambda *x: blue.pyos.SetClipboardData(str(graphicID)),
                     ()
                 ],
                 [
                     'Copy graphicFile (%s)' % graphicFile,
                     lambda *x: blue.pyos.SetClipboardData(graphicFile), ()
                 ]
             ]
     averagePrice = inventorycommon.typeHelpers.GetAveragePrice(typeID)
     if averagePrice is None:
         averagePrice = 'n/a'
     else:
         averagePrice = util.FmtISK(averagePrice)
     menu = [[
         'Preview', lambda *x: uthread.new(
             sm.StartService('preview').PreviewType, typeID), ()
     ]]
     menu += graphicFileMenu
     menu += [[
         'Copy typeID (%s)' % typeID,
         lambda *x: blue.pyos.SetClipboardData(str(typeID)), ()
     ],
              [
                  'Copy groupID (%s)' % groupID,
                  lambda *x: blue.pyos.SetClipboardData(str(groupID)), ()
              ],
              [
                  'Copy categoryID (%s)' % catID,
                  lambda *x: blue.pyos.SetClipboardData(str(catID)), ()
              ],
              [
                  'Average price: %s' % averagePrice,
                  lambda *x: blue.pyos.SetClipboardData(averagePrice), ()
              ],
              [
                  'View market details', lambda *x: uthread.new(
                      sm.StartService('marketutils').ShowMarketDetails,
                      typeID, None), ()
              ], None]
     menu += sm.GetService('menu').GetGMTypeMenu(typeID)
     return menu
    def LoadSolarSystemMap(self):
        self.maxRadius = 0.0
        solarsystemID = self.solarsystemID
        parent = self.systemMapTransform
        solarSystemData = self.systemMapSvc.GetSolarsystemData(solarsystemID)
        planets = []
        childrenToParentByID = {}
        sunID = None
        maxRadius = 0.0
        for celestialObject in solarSystemData:
            if celestialObject.groupID == const.groupPlanet:
                planets.append((celestialObject.itemID, geo2.Vector(celestialObject.x, celestialObject.y, celestialObject.z)))
                maxRadius = max(maxRadius, geo2.Vec3Length((celestialObject.x, celestialObject.y, celestialObject.z)))
            elif celestialObject.groupID == const.groupSun:
                sunID = celestialObject.itemID
                sunGraphicFilePath = GetGraphicFile(evetypes.GetGraphicID(celestialObject.typeID))
                sunGraphicFile = trinity.Load(sunGraphicFilePath)
                self.CreateSun(sunGraphicFile)

        self.sunID = sunID
        objectPositions = {}
        for each in solarSystemData:
            objectPositions[each.itemID] = (each.x, each.y, each.z)
            if each.groupID in (const.groupPlanet, const.groupStargate):
                childrenToParentByID[each.itemID] = sunID
                continue
            closest = []
            eachPosition = geo2.Vector(each.x, each.y, each.z)
            maxRadius = max(maxRadius, geo2.Vec3Length(eachPosition))
            for planetID, planetPos in planets:
                diffPos = planetPos - eachPosition
                diffVector = geo2.Vec3Length(diffPos)
                closest.append((diffVector, planetID))

            closest.sort()
            childrenToParentByID[each.itemID] = closest[0][1]

        self.maxRadius = maxRadius
        for each in solarSystemData:
            if each.itemID == each.locationID:
                continue
            if each.groupID == const.groupSecondarySun:
                continue
            if each.groupID == const.groupPlanet:
                self.CreatePlanet((each.x, each.y, each.z))
                OrbitCircle(each.itemID, (each.x, each.y, each.z), objectPositions[sunID], self.systemMapTransform)
            elif each.groupID == const.groupMoon:
                parentID = childrenToParentByID.get(each.itemID, None)
                if parentID:
                    self.CreatePlanet((each.x, each.y, each.z))
                    OrbitCircle(each.itemID, (each.x, each.y, each.z), objectPositions[parentID], self.systemMapTransform)

        self.solarSystemRadius = maxRadius
        cfg.evelocations.Prime(objectPositions.keys(), 0)
Exemple #9
0
 def LoadRedFiles(self):
     if self.modelPath is None:
         self.modelPath = self._GetModelPath()
         if self.largeTextures:
             self.modelPath = self.modelPath.replace('.red', '_HI.red')
     if self.rotatePlanet and not self.rotationApplied:
         self._ApplyPlanetRotation()
     if self.typeID == const.typeMoon and self.model.zOnlyModel is None:
         self._ApplyZOnlyModel()
     if self.attributes is None:
         self.attributes = self._GetPlanetAttributes(self.itemID)
     presetPath = self.modelPath
     if self.__GetShaderPreset() is not None:
         presetPath = GetGraphicFile(self.__GetShaderPreset())
     self.presetPath = presetPath
     if self.largeTextures:
         presetPath = presetPath.replace('/Template/', '/Template_HI/')
     gfx = inventorycommon.typeHelpers.GetGraphic(self.typeID)
     if hasattr(gfx, 'albedoColor') and gfx.albedoColor:
         self.model.albedoColor = tuple(gfx.albedoColor)
     if hasattr(gfx, 'emissiveColor') and gfx.emissiveColor:
         self.model.emissiveColor = tuple(gfx.emissiveColor)
     planet = trinity.Load(presetPath)
     if planet is None:
         self.logger.error('No planet was loaded! %s', presetPath)
         return False
     planet.name = 'Planet'
     self.model.highDetail.children.append(planet)
     self.model.highDetail.children.append(self.districtContainer)
     self.model.highDetail.children.append(self.districtExplosions)
     self.__ModifyPlanetShader()
     self.__CreateBakeEffect()
     self.__CollectLargeResources()
     self.__ApplyPlanetAttributesToDistricts()
     if self.isInflightPlanet and not self.audioStarted:
         self.audioStarted = True
         self.SetupAmbientAudio()
     return True
Exemple #10
0
 def DoModelChange(self):
     oldModel = self.model
     if self.level is None or self.level not in self.modelLists:
         LargeCollidableStructure.LoadModel(self)
     else:
         modelName = GetGraphicFile(self.modelLists[self.level])
         LargeCollidableStructure.LoadModel(self, modelName)
         if self.model is None:
             LargeCollidableStructure.LoadModel(self)
     self.SetStaticRotation()
     if oldModel is not None:
         uthread.pool('CustomsOffice::DelayedRemove', self.DelayedRemove,
                      oldModel, int(1000))
     if self.model is not None:
         self.model.display = True
Exemple #11
0
 def LoadModel(self, fileName = None, loadedModel = None):
     groupID = self.typeData.get('groupID')
     typeID = self.typeData.get('typeID')
     groupGraphics = cfg.groupGraphics.get(groupID, None)
     graphicID = None
     if hasattr(groupGraphics, 'graphicIDs'):
         variationID = self.id % len(groupGraphics.graphicIDs)
         graphicID = groupGraphics.graphicIDs[variationID]
     elif hasattr(groupGraphics, 'typeIDs'):
         graphicIDs = groupGraphics.typeIDs.get(typeID, None).graphicIDs
         variationID = self.id % len(graphicIDs)
         graphicID = graphicIDs[variationID]
     graphicFile = GetGraphicFile(graphicID)
     if graphicFile:
         SpaceObject.LoadModel(self, fileName=graphicFile)
         Asteroid._asteroidEnvironment.Add(self)
     else:
         self.logger.error('Could not load model for asteroid. groupID: %s, typeID: %s, graphicID: %s', groupID, typeID, graphicID)
Exemple #12
0
    def __ModifyPlanetShader(self):
        if self.typeID == const.typePlanetEarthlike or self.typeID == const.typePlanetSandstorm:
            now = datetime.datetime.now()
            r = random.Random()
            r.seed(now.year + now.month * 30 + now.day + self.itemID)
            val = r.randint(1, 5)
            useDense = val % 5 == 0
            if self.typeID == const.typePlanetEarthlike:
                if useDense:
                    cloudMapIDs = (3857, 3858, 3859, 3860)
                    cloudCapMapIDs = (3861, 3862, 3863, 3864)
                else:
                    cloudMapIDs = (3848, 3849, 3851, 3852)
                    cloudCapMapIDs = (3853, 3854, 3855, 3856)
            else:
                cloudMapIDs = (3956, 3957, 3958, 3959)
                cloudCapMapIDs = (3960, 3961, 3962, 3963)
            cloudMapIdx = r.randint(0, 3)
            cloudCapMapIdx = r.randint(0, 3)
            cloudCapTexResPath = GetGraphicFile(cloudCapMapIDs[cloudCapMapIdx])
            cloudTexResPath = GetGraphicFile(cloudMapIDs[cloudMapIdx])
            if self.largeTextures:
                cloudCapTexResPath = cloudCapTexResPath.replace('.dds', '_HI.dds')
                cloudTexResPath = cloudTexResPath.replace('.dds', '_HI.dds')
            cloudCapParamList = self.__GetPlanetShaderParameters('CloudCapTexture', 'trinity.TriTextureParameter')
            for cloudCapParam in cloudCapParamList:
                cloudCapParam.resourcePath = cloudCapTexResPath

            cloudParamList = self.__GetPlanetShaderParameters('CloudsTexture', 'trinity.TriTextureParameter')
            for cloudParam in cloudParamList:
                cloudParam.resourcePath = cloudTexResPath

            cloudsBrightness = r.random() * 0.4 + 0.6
            cloudsTransparency = r.random() * 2.0 + 1.0
            cloudsFactorsParamList = self.__GetPlanetShaderParameters('CloudsFactors', 'trinity.Tr2Vector4Parameter')
            for cloudsFactorsParam in cloudsFactorsParamList:
                cloudsFactorsParam.v3 = cloudsTransparency
                cloudsFactorsParam.v2 = cloudsBrightness

        if self.typeID is const.typePlanetOcean or self.typeID is const.typePlanetEarthlike:
            if self.__GetPopulation() == 0:
                for textureParamName in ['CityLight', 'CityDistributionTexture', 'CityDistributionMask']:
                    textureParamList = self.__GetPlanetShaderParameters(textureParamName, 'trinity.TriTextureParameter')
                    for textureParam in textureParamList:
                        textureParam.resourcePath = ''

                coverageFactorsParamList = self.__GetPlanetShaderParameters('CoverageFactors', 'trinity.Tr2Vector4Parameter')
                for coverageFactorsParam in coverageFactorsParamList:
                    coverageFactorsParam.v4 = 0.0
Exemple #13
0
 def __init__(self, dna, dirt=None, scenePath=None):
     if scenePath is None:
         scenePath = GetGraphicFile(20413)
     self.dna = dna
     self.dirt = dirt
     self.scenePath = scenePath
 def LoadNanoContainerModel(self):
     self.logger.debug('BuildableStructure: Loading nano container model')
     self.nanoContainerModel = self.LoadAdditionalModel(GetGraphicFile(NANO_CONTAINER_GRAPHIC_ID))
     self.nanoContainerModel.name += '_nanocontainer'
     self.nanoContainerModelLoadedEvent.set()
Exemple #15
0
    def LoadHangarBackground(self):
        stationRace = evetypes.GetRaceID(eve.stationItem.stationTypeID)
        stationGraphicsID = hangarUtil.racialHangarScenes[8]
        if stationRace in hangarUtil.racialHangarScenes:
            stationGraphicsID = hangarUtil.racialHangarScenes[stationRace]
        scenePath = GetGraphicFile(stationGraphicsID)
        if stationRace == const.raceAmarr:
            shipPositionData = ReadYamlFile(
                'res:/dx9/scene/hangar/shipPlacementAmarr.yaml')
            positioning = ReadYamlFile(
                'res:/dx9/scene/hangar/amarrbalconyplacement.yaml')
            self.sceneTranslation = positioning['position']
            self.sceneRotation = geo2.QuaternionRotationSetYawPitchRoll(
                positioning['orientation'], 0.0, 0.0)
        elif stationRace == const.raceCaldari:
            shipPositionData = ReadYamlFile(
                'res:/dx9/scene/hangar/shipPlacementCaldari.yaml')
            positioning = ReadYamlFile(
                'res:/dx9/scene/hangar/caldaribalconyplacement.yaml')
            self.sceneTranslation = positioning['position']
            self.sceneRotation = geo2.QuaternionRotationSetYawPitchRoll(
                positioning['orientation'], 0.0, 0.0)
        elif stationRace == const.raceGallente:
            shipPositionData = ReadYamlFile(
                'res:/dx9/scene/hangar/shipPlacementGallente.yaml')
            positioning = ReadYamlFile(
                'res:/dx9/scene/hangar/gallentebalconyplacement.yaml')
            self.sceneTranslation = positioning['position']
            self.sceneRotation = geo2.QuaternionRotationSetYawPitchRoll(
                positioning['orientation'], 0.0, 0.0)
        elif stationRace == const.raceMinmatar:
            shipPositionData = ReadYamlFile(
                'res:/dx9/scene/hangar/shipPlacementMinmatar.yaml')
            positioning = ReadYamlFile(
                'res:/dx9/scene/hangar/minmatarbalconyplacement.yaml')
            self.sceneTranslation = positioning['position']
            self.sceneRotation = geo2.QuaternionRotationSetYawPitchRoll(
                positioning['orientation'], 0.0, 0.0)
        else:
            shipPositionData = ReadYamlFile(
                'res:/dx9/scene/hangar/shipPlacementGallente.yaml')
            positioning = ReadYamlFile(
                'res:/dx9/scene/hangar/gallentebalconyplacement.yaml')
            self.sceneTranslation = positioning['position']
            self.sceneRotation = geo2.QuaternionRotationSetYawPitchRoll(
                positioning['orientation'], 0.0, 0.0)
        self.hangarScene = blue.resMan.LoadObject(scenePath)
        hangarMeshes = self.hangarScene.Find('trinity.EveStation2')
        for hangarMesh in hangarMeshes:
            if hangarMesh.planeSets is not None:
                hangarMesh.planeSets.removeAt(-1)

        self.hangarTraffic.SetupScene(self.hangarScene)
        self.hangarTraffic.RemoveAudio(self.hangarScene)
        self.sceneManager.SetupIncarnaBackground(self.hangarScene,
                                                 self.sceneTranslation,
                                                 self.sceneRotation)
        self.shipPositionMinDistance = shipPositionData['minDistance']
        self.shipPositionMaxDistance = shipPositionData['maxDistance']
        self.shipPositionMaxSize = shipPositionData['shipMaxSize']
        self.shipPositionMinSize = shipPositionData['shipMinSize']
        self.shipPositionTargetHeightMin = shipPositionData[
            'shipTargetHeightMin']
        self.shipPositionTargetHeightMax = shipPositionData[
            'shipTargetHeightMax']
        self.shipPositionCurveRoot = shipPositionData['curveRoot']
        self.shipPositionRotation = shipPositionData['rotation']
        if self.hangarScene is not None:
            stationModel = self.hangarScene.objects[0]
            stationModel.enableShadow = False
Exemple #16
0
 def _AddGraphicAttribute(self, pla, attr, filesToPrefetch):
     graphic = GetGraphicFile(getattr(pla, attr))
     filesToPrefetch.add(graphic.lower())
Exemple #17
0
 def _getResourceFromGraphicID(self, graphicID):
     resPath = GetGraphicFile(graphicID)
     if resPath is None:
         self._showMessage('Could not get resPath from graphicID ' + str(graphicID))
         return
     return self._getResourceFromResPath(resPath)