コード例 #1
0
ファイル: planet.py プロジェクト: connoryang/1v1dec
    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
コード例 #2
0
ファイル: planet.py プロジェクト: connoryang/1v1dec
 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