loadTextureSets() public static method

public static loadTextureSets ( ConfigNode textureSetNodes ) : SSTUTools.TextureSet[]
textureSetNodes System.ConfigNode
return SSTUTools.TextureSet[]
Ejemplo n.º 1
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            mpf = part.GetComponent <ModuleProceduralFairing>();
            ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this);

            textureSets = TextureSet.loadTextureSets(node.GetNodes("TEXTURESET"));
            int len = textureSets.Length;

            string[] textureSetNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                textureSetNames[i] = textureSets[i].setName;
            }
            this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet);
            techLimitMaxDiameter = SSTUStockInterop.getTechLimit(techLimitSet);
            if (currentDiameter > techLimitMaxDiameter)
            {
                currentDiameter = techLimitMaxDiameter;
            }
            updateModelScale();
            updateTexture(currentTextureSet);
            updateNodePositions(false);
            float max = techLimitMaxDiameter < maxDiameter ? techLimitMaxDiameter : maxDiameter;

            this.updateUIFloatEditControl("currentDiameter", minDiameter, max, diameterIncrement * 2f, diameterIncrement, diameterIncrement * 0.05f, true, currentDiameter);
            Fields["currentDiameter"].uiControlEditor.onFieldChanged   = onDiameterUpdated;
            Fields["currentTextureSet"].uiControlEditor.onFieldChanged = onTextureUpdated;
            Fields["currentTextureSet"].guiActiveEditor = textureSets.Length > 1;
            updateEditorFields();
        }
Ejemplo n.º 2
0
        //creates/recreates FairingData instances from data from config node and any persistent node (if applicable)
        private void loadFairingData(ConfigNode node)
        {
            ConfigNode[] fairingNodes = node.GetNodes("FAIRING");
            fairingParts = new SSTUNodeFairingData[fairingNodes.Length];

            Transform modelBase = part.transform.FindRecursive("model");
            Transform parent;

            SSTUNodeFairing[] cs = part.GetComponents <SSTUNodeFairing>();
            int l           = Array.IndexOf(cs, this);
            int moduleIndex = l;

            for (int i = 0; i < fairingNodes.Length; i++)
            {
                parent          = modelBase.FindOrCreate(fairingName + "-" + moduleIndex + "-" + i);
                fairingParts[i] = new SSTUNodeFairingData();
                fairingParts[i].load(fairingNodes[i], parent.gameObject);
                if (fairingParts[i].canAdjustTop)
                {
                    enableTopDiameterControls = true;
                }
                if (fairingParts[i].canAdjustBottom)
                {
                    enableBottomDiameterControls = true;
                }
            }
            if (!String.IsNullOrEmpty(persistentDataString))
            {
                String[] datas  = SSTUUtils.parseCSV(persistentDataString, ":");
                int      length = datas.Length;
                for (int i = 0; i < length; i++)
                {
                    fairingParts[i].loadPersistence(datas[i]);
                }
            }

            textureSets = TextureSet.loadTextureSets(node.GetNodes("TEXTURESET"));

            if (fairingMaterial != null)
            {
                Material.Destroy(fairingMaterial);
                fairingMaterial = null;
            }

            if (textureSets != null && !String.IsNullOrEmpty(currentTextureSet))
            {
                TextureSet t = Array.Find(textureSets, m => m.setName == currentTextureSet);
                if (t != null)
                {
                    TextureData d = t.textureDatas[0];
                    if (d != null)
                    {
                        diffuseTextureName = d.diffuseTextureName;
                        normalTextureName  = d.normalTextureName;
                    }
                }
            }
            fairingMaterial = SSTUUtils.loadMaterial(diffuseTextureName, normalTextureName, "KSP/Bumped Specular");
        }
Ejemplo n.º 3
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] textureNodes = node.GetNodes("TEXTURESET");
            textureSetData        = TextureSet.loadTextureSets(textureNodes);
            currentTextureSetData = Array.Find(textureSetData, m => m.setName == currentTextureSet);
            if (currentTextureSetData == null)
            {
                currentTextureSetData = textureSetData[0];
                currentTextureSet     = currentTextureSetData.setName;
            }

            int len = textureSetData.Length;

            string[] textureSetNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                textureSetNames[i] = textureSetData[i].setName;
            }
            this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet);

            TextureData data = currentTextureSetData.textureDatas[0];

            fairingMaterial = SSTUUtils.loadMaterial(data.diffuseTextureName, null, "KSP/Specular");

            loadMaterial();

            Transform tr = part.transform.FindRecursive("model").FindOrCreate("PetalAdapterRoot");

            fairingBase = new InterstageFairingContainer(tr.gameObject, cylinderSides, numberOfPanels, wallThickness);
            UVMap uvs = UVMap.GetUVMapGlobal(uvMap);

            fairingBase.outsideUV = uvs.getArea("outside");
            fairingBase.insideUV  = uvs.getArea("inside");
            fairingBase.edgesUV   = uvs.getArea("edges");

            rebuildFairing(false);//will create fairing using default / previously saved fairing configuration
            restoreEditorFields();
            setPanelRotations(currentRotation);
            if (panelsJettisoned)
            {
                fairingBase.destroyExistingPanels();
            }
            updateGuiState();
        }
Ejemplo n.º 4
0
        private void loadConfigData()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            textureSets = TextureSet.loadTextureSets(node.GetNodes("TEXTURESET"));
        }
Ejemplo n.º 5
0
        private void loadConfigData()
        {
            ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this);

            textureSets = TextureSet.loadTextureSets(node.GetNodes("TEXTURESET"));
        }