public static void updateRenderer(Renderer rend, string shader, string diffuse, string normal, string specular, string emissive, string occlusion, ShaderProperty[] props)
        {
            Material m = rend.material;

            if (!String.IsNullOrEmpty(shader) && shader != m.shader.name)
            {
                m.shader = SSTUDatabase.getShader(shader);
            }
            if (!String.IsNullOrEmpty(diffuse))
            {
                m.mainTexture = GameDatabase.Instance.GetTexture(diffuse, false);
            }
            if (!String.IsNullOrEmpty(normal))
            {
                m.SetTexture("_BumpMap", GameDatabase.Instance.GetTexture(normal, true));
            }
            if (!String.IsNullOrEmpty(specular))
            {
                m.SetTexture("_SpecMap", GameDatabase.Instance.GetTexture(specular, false));
            }
            if (!String.IsNullOrEmpty(emissive))
            {
                m.SetTexture("_Emissive", GameDatabase.Instance.GetTexture(emissive, false));
            }
            if (!String.IsNullOrEmpty(occlusion))
            {
                m.SetTexture("_AOMap", GameDatabase.Instance.GetTexture(occlusion, false));
            }
            updateMaterialProperties(m, props);
        }
示例#2
0
 //called from the ModuleManagerPostLoad() callback for KSPShaderTools
 public void KSPShaderToolsPostLoad()
 {
     MonoBehaviour.print("Reloading config databases (fuel types, model data, etc...)");
     FuelTypes.INSTANCE.loadConfigData();
     VolumeContainerLoader.loadConfigData(); //needs to be loaded after fuel types
     SSTUDatabase.loadConfigData();          //loads heat-shield types
     SSTUModelData.loadConfigData();
 }
示例#3
0
 public void ModuleManagerPostLoad()
 {
     MonoBehaviour.print("Reloading config databases (fuel types, model data, etc...)");
     FuelTypes.INSTANCE.loadConfigData();
     VolumeContainerLoader.loadConfigData();//needs to be loaded after fuel types
     SSTUModelData.loadConfigData();
     SSTUDatabase.loadConfigData();
 }
        public HeatShieldTypeData(ConfigNode node)
        {
            string typeName = node.GetValue("name");

            baseType       = SSTUDatabase.getHeatShieldType(typeName);
            resourceMult   = node.GetFloatValue("resourceMult", baseType.resourceMult);
            ablationStart  = node.GetFloatValue("ablationStart", baseType.ablationStart);
            ablationEnd    = node.GetFloatValue("ablationEnd", baseType.ablationEnd);
            ablationMult   = node.GetFloatValue("ablationMult", baseType.ablationMult);
            massMult       = node.GetFloatValue("massMult", baseType.massMult);
            heatCurve      = node.GetFloatCurve("heatCurve", baseType.heatCurve);
            efficiencyMult = node.GetFloatValue("efficiencyMult", 1.0f);
        }
示例#5
0
 private void setShieldTypeFromEditor(String newType, bool updateSymmetry)
 {
     currentShieldType     = newType;
     currentShieldTypeData = SSTUDatabase.getHeatShieldType(newType);
     updateModuleStats();
     updatePartResources();
     updatePartCost();
     updateEditorFields();
     if (updateSymmetry)
     {
         SSTUModularHeatShield mhs;
         foreach (Part p in part.symmetryCounterparts)
         {
             mhs = p.GetComponent <SSTUModularHeatShield>();
             mhs.setShieldTypeFromEditor(newType, false);
         }
         SSTUStockInterop.fireEditorUpdate();
     }
 }
示例#6
0
        public void ModuleManagerPostLoad()
        {
            MonoBehaviour.print("Creating Part Config cache.");
            partConfigNodes.Clear();
            ConfigNode[] partNodes = GameDatabase.Instance.GetConfigNodes("PART");
            String       name;

            foreach (ConfigNode node in partNodes)
            {
                name = node.GetStringValue("name");
                name = name.Replace('_', '.');
                if (partConfigNodes.ContainsKey(name))
                {
                    continue;
                }
                partConfigNodes.Add(name, node);
            }
            MonoBehaviour.print("Reloading config databases (fuel types, model data, etc...)");
            FuelTypes.INSTANCE.loadConfigData();
            VolumeContainerLoader.loadConfigData();//needs to be loaded after fuel types
            SSTUModelData.loadConfigData();
            SSTUDatabase.loadConfigData();
        }
示例#7
0
        private void initialize()
        {
            if (heatCurve == null)
            {
                heatCurve = new FloatCurve();
                heatCurve.Add(0, 0.00002f);  //very minimal initial ablation factor
                heatCurve.Add(50, 0.00005f); //ramp it up fairly quickly though
                heatCurve.Add(150, 0.00015f);
                heatCurve.Add(500, 0.00050f);
                heatCurve.Add(750, 0.00075f);
                heatCurve.Add(1000, 0.00100f);
                heatCurve.Add(2000, 0.00400f);
                heatCurve.Add(3000, 0.00800f);  //generally, things will explode before this point
                heatCurve.Add(10000, 0.05000f); //but just in case, continue the curve up to insane levels
            }
            double hsp  = 1;
            double dens = 1;

            if (heatSoak)
            {
                PartResourceDefinition resource = PartResourceLibrary.Instance.GetDefinition(resourceName);
                hsp  = resource.specificHeatCapacity;
                dens = resource.density;
            }
            else
            {
                resource = part.Resources[resourceName];
                if (resource != null)
                {
                    hsp  = resource.info.specificHeatCapacity;
                    dens = resource.info.density;
                }
                else
                {
                    hsp  = PhysicsGlobals.StandardSpecificHeatCapacity;
                    dens = 0.005f;
                }
            }
            useToFluxMultiplier = hsp * ablationEfficiency * dens * ablationMult;
            baseSkinIntMult     = part.skinInternalConductionMult;

            //stand-alone modular heat-shield setup
            if (standAlonePart)
            {
                if (string.IsNullOrEmpty(modelName))
                {
                    MonoBehaviour.print("SEVERE ERROR: SSTUModularHeatShield could has no model specified for part: " + part.name);
                }

                if (!String.IsNullOrEmpty(transformsToRemove))
                {
                    SSTUUtils.removeTransforms(part, SSTUUtils.parseCSV(transformsToRemove));
                }

                shieldTypeNames = SSTUDatabase.getHeatShieldNames();

                ConfigNode modelNode = new ConfigNode("MODEL");
                modelNode.AddValue("name", modelName);
                mainModelData = new SingleModelData(modelNode);
                mainModelData.setupModel(part.transform.FindRecursive("model"), ModelOrientation.CENTRAL, true);
                setModelDiameter(currentDiameter);
                updateAttachNodes(false);
                updateDragCube();
                updateEditorFields();
            }

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] typeNodes = node.GetNodes("SHIELDTYPE");
            int          len       = typeNodes.Length;

            shieldTypeNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                shieldTypeNames[i] = typeNodes[i].GetStringValue("name");
            }
            if (shieldTypeNames.Length == 0)
            {
                shieldTypeNames = new string[] { "Medium" };
            }
            currentShieldTypeData = SSTUDatabase.getHeatShieldType(currentShieldType);
            heatCurve             = currentShieldTypeData.heatCurve;

            updatePartCost();
            if (!initializedResources && (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight))
            {
                updatePartResources();
                initializedResources = true;
            }
        }
 private static void replaceShader(Material m, string name)
 {
     m.shader = SSTUDatabase.getShader(name);
 }