private void loadConfigData()
        {
            ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this);

            ConfigNode[] textureNodes = node.GetNodes("TEXTURESET");
            int          len          = textureNodes.Length;

            textureSetData = new TextureSet[len];
            for (int i = 0; i < len; i++)
            {
                textureSetData[i] = new TextureSet(textureNodes[i]);
            }
            currentTextureSetData = Array.Find(textureSetData, m => m.setName == currentTextureSet);
            if (currentTextureSetData == null)
            {
                currentTextureSetData = textureSetData[0];
                currentTextureSet     = currentTextureSetData.setName;
            }
            string[] textureSetNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                textureSetNames[i] = textureSetData[i].setName;
            }
            this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet);

            techLimitMaxDiameter = SSTUStockInterop.getTechLimit(techLimitSet);
            if (diameter > techLimitMaxDiameter)
            {
                diameter = techLimitMaxDiameter;
            }
        }
예제 #2
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);

            mpf = part.GetComponent <ModuleProceduralFairing>();
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            string[]   names  = node.GetStringValues("textureSet");
            string[]   titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title);
            TextureSet t      = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            if (t == null)
            {
                currentTextureSet = names[0];
                t = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(t.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
            Fields[nameof(currentTextureSet)].guiActiveEditor = names.Length > 1;
        }
예제 #3
0
        private void updateTextureSet(bool useDefaults)
        {
            if (mpf == null)
            {
                return;
            }
            TextureSet s = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors(string.Empty);
            Material         fm     = mpf.FairingMaterial;

            s.textureData[0].apply(fm);//TODO -- bit of an ugly hack; should at least pull a ref to whatever index that slot goes to
            s.textureData[0].apply(mpf.FairingMaterial);
            s.textureData[0].applyRecoloring(mpf.FairingMaterial, colors);
            s.textureData[0].apply(mpf.FairingConeMaterial);
            s.textureData[0].applyRecoloring(mpf.FairingConeMaterial, colors);
            List <Transform> trs = new List <Transform>();

            foreach (ProceduralFairings.FairingPanel fp in mpf.Panels)
            {
                s.enable(fp.go.transform, colors);
            }
            if (useDefaults)
            {
                recolorHandler.setColorData(colors);
            }
            SSTUModInterop.onPartTextureUpdated(part);
        }
예제 #4
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            mpf = part.GetComponent <ModuleProceduralFairing>();
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            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);

            updateModelScale();
            updateTexture(currentTextureSet);
            updateNodePositions(false);
            this.updateUIFloatEditControl("currentDiameter", minDiameter, maxDiameter, 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();
        }
예제 #5
0
        /// <summary>
        /// Enables the input texture set name, or default texture for the model if 'none' or 'default' is input for the set name
        /// </summary>
        /// <param name="setName"></param>
        public void enableTextureSet(String setName, RecoloringData[] userColors)
        {
            if (setName == "none" || setName == "default" || String.IsNullOrEmpty(setName))
            {
                return;
            }
            TextureSet mts = Array.Find(modelDefinition.textureSets, m => m.name == setName);

            if (mts == null)
            {
                MonoBehaviour.print("ERROR: No texture set data for set by name: " + setName + "  --  for model: " + name);
                if (String.IsNullOrEmpty(modelDefinition.defaultTextureSet))
                {
                    MonoBehaviour.print("ERROR: Default texture set was null or empty string, this is a configuration error. " +
                                        "Please correct the model definition for model: " +
                                        modelDefinition.name + " to add a proper default texture set definition.");
                }
                int len = modelDefinition.textureSets.Length;
                MonoBehaviour.print("Texture sets avaialble for model: " + len + ". Default set: " + modelDefinition.defaultTextureSet);
                for (int i = 0; i < len; i++)
                {
                    MonoBehaviour.print("\n" + modelDefinition.textureSets[i].name);
                }
            }
            else if (model != null)
            {
                mts.enable(model, userColors);
            }
        }
예제 #6
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");
        }
예제 #7
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized    = true;
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            string[]   names  = node.GetStringValues("textureSet");
            string[]   titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title);
            TextureSet currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            if (currentTextureSetData == null)
            {
                currentTextureSet     = names[0];
                currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors     = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(currentTextureSetData.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
            Fields[nameof(currentTextureSet)].guiActiveEditor = names.Length > 1;

            fuelType = VolumeContainerLoader.getPreset(fuelPreset);

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

            //Set up the engine models container
            ConfigNode[] modelNodes = node.GetNodes("MODEL");
            engineModelRoot = modelBase.FindOrCreate(engineModelRootName);
            ModelDefinitionLayoutOptions[] models = SSTUModelData.getModelDefinitions(modelNodes);
            engineModels = new ModelModule <SSTUInterstageDecoupler>(part, this, engineModelRoot, ModelOrientation.CENTRAL, nameof(currentEngineModel), nameof(currentEngineLayout), nameof(currentEngineTextureSet), nameof(customEngineColorData), null, null, null, null);
            engineModels.getSymmetryModule       = m => m.engineModels;
            engineModels.getValidOptions         = () => models;
            engineModels.getLayoutPositionScalar = () => currentBottomDiameter * 0.5f;
            //engineModels.getLayoutScaleScalar = () => currentEngineScale;
            engineModels.setupModelList(models);
            engineModels.setupModel();
            engineModels.updateSelections();
            updateEnginePositionAndScale();

            //set up the fairing container
            minHeight = engineModels.moduleHeight;
            Transform fairingContainerRoot = modelBase.FindOrCreate(baseTransformName);

            fairingBase = new FairingContainer(fairingContainerRoot.gameObject, cylinderSides, numberOfPanels, wallThickness);
            updateEditorFields();
            buildFairing();
            updateEnginePositionAndScale();
            updateFairingTextureSet(false);
            updateNodePositions(false);
            updatePartMass();
        }
예제 #8
0
        public void enableTextureSet(string name, RecoloringData[] userColors)
        {
            TextureSet s = KSPShaderLoader.getTextureSet(name);

            if (s != null)
            {
                s.enable(root, userColors);
            }
        }
예제 #9
0
        public void enableTextureSet(string name, RecoloringData[] userColors)
        {
            TextureSet s = TexturesUnlimitedLoader.getTextureSet(name);

            if (s != null)
            {
                s.enable(root.transform, userColors);
            }
        }
예제 #10
0
        //enables a specific texture set, by name
        public void enableTextureSet(String name)
        {
            TextureSet ts = Array.Find(textureSets, m => m.setName == name);

            if (ts != null)
            {
                ts.enableFromMeshes(part);
                currentTextureSet = name;
            }
        }
예제 #11
0
        private void updateFairingTextureSet(bool useDefaults)
        {
            TextureSet s = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors("Decoupler");
            fairingBase.enableTextureSet(currentTextureSet, colors);
            if (useDefaults)
            {
                recolorHandler.setColorData(colors);
            }
            SSTUModInterop.onPartTextureUpdated(part);
        }
예제 #12
0
        private void updateTextureSet(bool useDefaults)
        {
            TextureSet s = KSPShaderLoader.getTextureSet(currentTextureSet);

            RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors(string.Empty);
            model.enableTextureSet(currentTextureSet, colors);
            if (useDefaults)
            {
                recolorHandler.setColorData(colors);
            }
            SSTUModInterop.onPartTextureUpdated(part);
        }
예제 #13
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized    = true;
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] textureNodes          = node.GetNodes("TEXTURESET");
            string[]     names                 = TextureSet.getTextureSetNames(textureNodes);
            string[]     titles                = TextureSet.getTextureSetTitles(textureNodes);
            TextureSet   currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet);

            if (currentTextureSetData == null)
            {
                currentTextureSet     = names[0];
                currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet);
                initializedColors     = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(currentTextureSetData.maskColors);
            }
            this.updateUIChooseOptionControl("currentTextureSet", names, titles, true, currentTextureSet);
            Fields[nameof(currentTextureSet)].guiActiveEditor = textureNodes.Length > 1;

            fairingMaterial = currentTextureSetData.textureData[0].createMaterial("SSTUFairingMaterial");

            fuelType = VolumeContainerLoader.getPreset(fuelPreset);

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

            setupEngineModels(modelBase, node);
            minHeight = engineModels.model.modelDefinition.height * getEngineScale();
            Transform root     = modelBase.FindOrCreate(baseTransformName);
            Transform collider = modelBase.FindOrCreate("InterstageFairingBaseCollider");

            fairingBase = new InterstageDecouplerModel(root.gameObject, collider.gameObject, 0.25f, cylinderSides, numberOfPanels, wallThickness);
            updateEditorFields();
            buildFairing();
            updateTextureSet(false);
            updateNodePositions(false);
            if (!initializedResources && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor))
            {
                initializedResources = true;
                updateResources();
            }
            updatePartMass();
            updateEngineThrust();
        }
예제 #14
0
 private void loadTextureSets()
 {
     if(defsLoaded){return;}
     defsLoaded=true;
     ConfigNode[] configNodes = GameDatabase.Instance.GetConfigNodes("SSTU_TEXTURESET");
     if(configNodes==null){return;}
     TextureSet textureSet;
     foreach(ConfigNode node in configNodes)
     {
         textureSet = new TextureSet(node);
         textureSets.Add(textureSet.setName, textureSet);
     }
 }
예제 #15
0
        public void enableTextureSet(string name, RecoloringData[] userColors)
        {
            TextureSet set = KSPShaderLoader.getTextureSet(name);

            if (set != null)
            {
                set.enable(rootObject, userColors);
            }
            else
            {
                MonoBehaviour.print("ERROR: " + name + " is not a valid texture set for fairing.");
            }
        }
예제 #16
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();
        }
예제 #17
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] textureNodes = node.GetNodes("TEXTURESET");
            string[]     names        = TextureSet.getTextureSetNames(textureNodes);
            string[]     titles       = TextureSet.getTextureSetTitles(textureNodes);
            TextureSet   t            = KSPShaderLoader.getTextureSet(currentTextureSet);

            if (t == null)
            {
                currentTextureSet = names[0];
                t = KSPShaderLoader.getTextureSet(currentTextureSet);
                initializedColors = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(t.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
            fairingMaterial = t.textureData[0].createMaterial("SSTUFairingMaterial");

            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");

            validateStraightHeight();
            rebuildFairing(false);//will create fairing using default / previously saved fairing configuration
            setPanelRotations(currentRotation);
            if (panelsJettisoned)
            {
                fairingBase.destroyFairing();
            }
            updateGuiState();
        }
예제 #18
0
        private void updateTextureSet(bool useDefaults)
        {
            TextureSet s = KSPShaderLoader.getTextureSet(currentTextureSet);

            RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors(string.Empty);
            int len = fairingParts.Length;

            for (int i = 0; i < len; i++)
            {
                fairingParts[i].fairingBase.enableTextureSet(currentTextureSet, colors);
            }
            if (useDefaults)
            {
                recolorHandler.setColorData(colors);
            }
            updateOpacity();
            SSTUModInterop.onPartTextureUpdated(part);
        }
예제 #19
0
        public void nextTextureEvent()
        {
            if (textureSets != null && textureSets.Length > 0)
            {
                TextureSet s = SSTUUtils.findNext(textureSets, m => m.setName == currentTextureSet, false);
                currentTextureSet = s.setName;
                updateTextureSet();
            }
            SSTUNodeFairing f;
            int             index = part.Modules.IndexOf(this);

            foreach (Part p in part.symmetryCounterparts)
            {
                f = (SSTUNodeFairing)p.Modules[index];
                f.currentTextureSet = this.currentTextureSet;
                f.updateTextureSet();
            }
        }
예제 #20
0
        private void updateTexture(String name)
        {
            currentTextureSet = name;
            if (mpf != null)
            {
                TextureSet set = Array.Find(textureSets, m => m.setName == currentTextureSet);
                if (set != null)
                {
                    TextureData data = set.textureDatas[0];//TODO cleanup this hack
                    mpf.TextureURL = data.diffuseTextureName;
                    Texture t = SSTUUtils.findTexture(data.diffuseTextureName, false);

                    mpf.FairingMaterial.mainTexture = t;
                    foreach (var f in mpf.Panels)
                    {
                        f.mat.mainTexture = t;
                        SSTUUtils.setMainTextureRecursive(f.go.transform, t);
                    }
                }
            }
        }
예제 #21
0
        private void loadConfigData()
        {
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            string[]   names  = node.GetStringValues("textureSet");
            string[]   titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title);
            TextureSet currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            if (currentTextureSetData == null)
            {
                currentTextureSet     = names[0];
                currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors     = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(currentTextureSetData.maskColors);
            }
            Fields["currentTextureSet"].guiActiveEditor = names.Length > 1;
            this.updateUIChooseOptionControl("currentTextureSet", names, titles, true, currentTextureSet);
        }
예제 #22
0
        private void setTextureFromEditor(String newTexture, bool updateSymmetry)
        {
            currentTextureSet     = newTexture;
            currentTextureSetData = Array.Find(textureSetData, m => m.setName == newTexture);
            if (currentTextureSetData == null)
            {
                currentTextureSetData = textureSetData[0];
                currentTextureSet     = currentTextureSetData.setName;
                newTexture            = currentTextureSet;
            }
            TextureData data = currentTextureSetData.textureDatas[0];

            data.enableForced(fairingBase.rootObject.transform, true);
            if (updateSymmetry)
            {
                SSTUInterstageFairing dc;
                foreach (Part p in part.symmetryCounterparts)
                {
                    dc = p.GetComponent <SSTUInterstageFairing>();
                    dc.setTextureFromEditor(newTexture, false);
                }
            }
        }
예제 #23
0
        private void setTextureFromEditor(String newTexture, bool updateSymmetry)
        {
            currentTextureSet     = newTexture;
            currentTextureSetData = Array.Find(textureSetData, m => m.setName == newTexture);
            if (currentTextureSetData == null)
            {
                currentTextureSetData = textureSetData[0];
                currentTextureSet     = currentTextureSetData.setName;
                newTexture            = currentTextureSet;
            }
            TextureData data = currentTextureSetData.textureDatas[0];

            model.setMainTexture(data.diffuseTextureName);
            model.setNormalTexture(data.normalTextureName);
            if (updateSymmetry)
            {
                SSTUProceduralDecoupler dc;
                foreach (Part p in part.symmetryCounterparts)
                {
                    dc = p.GetComponent <SSTUProceduralDecoupler>();
                    dc.setTextureFromEditor(newTexture, false);
                }
            }
        }
예제 #24
0
 public static TextureSet[] loadTextureSets(ConfigNode[] textureSetNodes)
 {
     int len = textureSetNodes.Length;
     TextureSet[] sets = new TextureSet[len];
     for (int i = 0; i < len; i++)
     {
         String name = textureSetNodes[i].GetStringValue("name");
         sets[i] = TextureSets.INSTANCE.getTextureSet(textureSetNodes[i].GetStringValue("name"));
         if (sets[i] == null) { MonoBehaviour.print("ERROR: Could not locate texture set for name: " + name); }
     }
     return sets;
 }
예제 #25
0
 private void updateModuleTexture(SingleModelData module, TextureSet set)
 {
     if (module.model == null) { return; }//model may be null if the module has no model (e.g. 'None' mount type)
     set.enable(module.model.transform);
 }
예제 #26
0
        private void setMountTextureFromEditor(TextureSet set, bool updateSymmetry)
        {
            currentMountTexture = set.setName;
            updateModuleTexture(currentMountModule, set);

            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    SSTUModularFuelTank mft = p.GetComponent<SSTUModularFuelTank>();
                    TextureSet st = Array.Find(mft.textureSets, t => t.setName == set.setName);
                    mft.setMountTextureFromEditor(st, false);
                }
            }
        }
예제 #27
0
        public ModelDefinition(ConfigNode node)
        {
            configNode        = node;
            name              = node.GetStringValue("name", String.Empty);
            title             = node.GetStringValue("title", name);
            description       = node.GetStringValue("description", title);
            icon              = node.GetStringValue("icon");
            modelName         = node.GetStringValue("modelName", String.Empty);
            upgradeUnlockName = node.GetStringValue("upgradeUnlock", upgradeUnlockName);
            height            = node.GetFloatValue("height", height);
            volume            = node.GetFloatValue("volume", volume);
            mass              = node.GetFloatValue("mass", mass);
            cost              = node.GetFloatValue("cost", cost);
            diameter          = node.GetFloatValue("diameter", diameter);
            verticalOffset    = node.GetFloatValue("verticalOffset", verticalOffset);
            if (node.GetBoolValue("invertForTop", false))
            {
                orientation = ModelOrientation.BOTTOM;
            }
            else if (node.GetBoolValue("invertForBottom", false))
            {
                orientation = ModelOrientation.TOP;
            }
            invertAxis            = node.GetVector3("invertAxis", invertAxis);
            fairingDisabled       = node.GetBoolValue("fairingDisabled", fairingDisabled);
            fairingTopOffset      = node.GetFloatValue("fairingTopOffset", fairingTopOffset);
            rcsVerticalPosition   = node.GetFloatValue("rcsVerticalPosition", rcsVerticalPosition);
            rcsHorizontalPosition = node.GetFloatValue("rcsHorizontalPosition", rcsHorizontalPosition);
            rcsVerticalRotation   = node.GetFloatValue("rcsVerticalRotation", rcsVerticalRotation);
            rcsHorizontalRotation = node.GetFloatValue("rcsHorizontalRotation", rcsHorizontalRotation);

            ConfigNode[] subModelNodes = node.GetNodes("SUBMODEL");
            int          len           = subModelNodes.Length;

            subModelData = new SubModelData[len];
            for (int i = 0; i < len; i++)
            {
                subModelData[i] = new SubModelData(subModelNodes[i]);
            }

            defaultTextureSet = node.GetStringValue("defaultTextureSet");

            String[] attachNodeStrings = node.GetValues("node");
            len            = attachNodeStrings.Length;
            attachNodeData = new AttachNodeBaseData[len];
            for (int i = 0; i < len; i++)
            {
                attachNodeData[i] = new AttachNodeBaseData(attachNodeStrings[i]);
            }

            ConfigNode[] textureSetNodes = node.GetNodes("TEXTURESET");
            len         = textureSetNodes.Length;
            textureSets = new TextureSet[len];
            for (int i = 0; i < len; i++)
            {
                textureSets[i] = new TextureSet(textureSetNodes[i]);
            }
            if (node.HasValue("surface"))
            {
                surfaceNode = new AttachNodeBaseData(node.GetStringValue("surface"));
            }
            else
            {
                String val = (diameter * 0.5f) + ",0,0,1,0,0,2";
                surfaceNode = new AttachNodeBaseData(val);
            }

            if (node.HasNode("COMPOUNDMODEL"))
            {
                compoundModelData = new CompoundModelData(node.GetNode("COMPOUNDMODEL"));
            }

            if (node.HasNode("ANIMATION"))
            {
                animationData = ModelAnimationData.parseAnimationData(node.GetNodes("ANIMATION"));
            }
            else
            {
                animationData = new ModelAnimationData[0];
            }

            if (node.HasNode("CONSTRAINT"))
            {
                constraintData = node.GetNode("CONSTRAINT");
            }
        }
        private void loadConfigData()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] textureNodes = node.GetNodes("TEXTURESET");
            int len = textureNodes.Length;
            textureSetData = new TextureSet[len];
            for (int i = 0; i < len; i++)
            {
                textureSetData[i] = new TextureSet(textureNodes[i]);
            }
            currentTextureSetData = Array.Find(textureSetData, m => m.setName == currentTextureSet);
            if (currentTextureSetData == null)
            {
                currentTextureSetData = textureSetData[0];
                currentTextureSet = currentTextureSetData.setName;
            }
            string[] textureSetNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                textureSetNames[i] = textureSetData[i].setName;
            }
            this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet);
        }
 private void setTextureFromEditor(String newTexture, bool updateSymmetry)
 {
     currentTextureSet = newTexture;
     currentTextureSetData = Array.Find(textureSetData, m => m.setName == newTexture);
     if (currentTextureSetData == null)
     {
         currentTextureSetData = textureSetData[0];
         currentTextureSet = currentTextureSetData.setName;
         newTexture = currentTextureSet;
     }
     TextureData data = currentTextureSetData.textureDatas[0];
     model.setMainTexture(data.diffuseTextureName);
     model.setNormalTexture(data.normalTextureName);
     if (updateSymmetry)
     {
         SSTUProceduralDecoupler dc;
         foreach (Part p in part.symmetryCounterparts)
         {
             dc = p.GetComponent<SSTUProceduralDecoupler>();
             dc.setTextureFromEditor(newTexture, false);
         }
     }
 }
예제 #30
0
        private void loadConfigData()
        {
            ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this);

            textureSets = TextureSet.loadTextureSets(node.GetNodes("TEXTURESET"));
        }
예제 #31
0
        //creates/recreates FairingData instances from data from config node and any persistent node (if applicable)
        private void loadFairingData(ConfigNode node)
        {
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);

            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 (guiTopDiameter < 0)
                    {
                        guiTopDiameter = fairingParts[i].topRadius * 2f;
                    }
                    else
                    {
                        fairingParts[i].topRadius = guiTopDiameter * 0.5f;
                    }
                }
                if (fairingParts[i].canAdjustBottom)
                {
                    enableBottomDiameterControls = true;
                    if (guiBottomDiameter < 0)
                    {
                        guiBottomDiameter = fairingParts[i].bottomRadius * 2f;
                    }
                    else
                    {
                        fairingParts[i].bottomRadius = guiBottomDiameter * 0.5f;
                    }
                }
            }
            //reload fairing data from persistence;
            //it -should- already match the guiTopDiameter/guiBottomDiameter (or else was already corrupted/invalid when saved out).
            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]);
                }
            }
            ConfigNode[] textureNodes = node.GetNodes("TEXTURESET");
            string[]     names        = TextureSet.getTextureSetNames(textureNodes);
            string[]     titles       = TextureSet.getTextureSetTitles(textureNodes);
            TextureSet   t            = KSPShaderLoader.getTextureSet(currentTextureSet);

            if (t == null)
            {
                currentTextureSet = names[0];
                t = KSPShaderLoader.getTextureSet(currentTextureSet);
                initializedColors = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(t.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
            fairingMaterial = t.textureData[0].createMaterial("SSTUFairingMaterial");
        }
예제 #32
0
        private void loadConfigData()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

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