Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by SuperRedNova

  1. Not entirely sure if this is the forum where this should go, but it seemed like the best candidate. Please feel free to correct me if this isn't the place this should go. I recently have found myself facing a conundrum for developing the Model Rocketry Add-on. My original Idea, when I started creating the mod was to make to-scale model rocket parts, but these turned out to be WAY to small to really use in the editor. In light of this, i had decided to upscale the parts I had made to 1.25m parts and give them some customization for fun (like you can do with a real model rocket.) However, recently I thought about this problem again and realized that it might be possible to create a new editor just for the model rockets (and a new tiny launch-pad as well. This would be beyond my ability as a modder for KSP at the moment, but I am sure it could be done (it would just take some help or a really long time). Any feed back on what you guys think I should do would be appreciated. Also, feel free to offer help, criticism, and ideas, one mind can only think of so many things.
  2. -1 to 28 I give up. I heard there was cookies and I like the color red better anyways.
  3. 42. That would be like... the answer to life the universe and everything! or at least to my hopes and dreams of the positives winning.
  4. Working on making it so I people can add basic patterns onto the parts I made, but in Linux(even on the same computer), the filtering does not take effect and just blends the colors together because i'm using smaller textures to conserve memory usage. The only thing I can think of is that the graphic drivers are different. I would like to work around this without having to resort to bigger textures, any Ideas? Pics of the same craft in the different OSs: Edit: I was able to solve this problem by changing the texture format to RGB24 instead of being a floating point texture, because apparently point filtering with opengl doesn't work on some hardware if you are using them.
  5. Just posting that I will be using KSPAPIExtensions in my next release of Model Rocketry (will be version 0.1.4) as per requirements of use.
  6. I've since fixed this by setting the original texture to the desired color and getting rid of the onAwake method entirely, which isn't my prefered way but it gets the job done. My logic for having both methods was this: just having onStart would leave the texture for the model in the thumbnail, so I had added the awake method, but I still needed the onstart method to try and set the color for each instance of the part that was on the vessel when loading in to a new scene. This ended up causing more problems then it solved, unfortunately. Thanks for pointing out the delay code though, I had had it in there because I saw it in someone else's code that seemed like they were trying to do something similar, but now that I think about it isn't really needed.
  7. I am making a part module that will change the color of one of a part's rendered meshes, but am getting an annoying bug where model in the preview thumbnail changes to the color of the part instance in the editor that was most recently changed. It is the right color (whatever is defined in the part.cfg) when first loading into the editor or spawning a new instance of the part, but then will still change afterwards. Any help I can get to fix this would be appreciated. So far I have tried instantiating the part, both in onAwake() (makes it so that both the preview model and the part I'm trying to change the color of don't change, until the part is loaded in a new scene) and in onStart() (bad idea, calls itself recursively), along with messing around with the prefabs, because I read that they have something to do with the preview model here, although I've had no luck with this so far. using System;using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; namespace KSPModelRocketry { public class VariableTexture : PartModule { public static float scale = 21; [KSPField(guiActiveEditor = true, guiName = "Red", guiFormat = "F2", isPersistant = true)] [UI_FloatRange(minValue = 0, maxValue = 1, stepIncrement = .05f)] public float red = 1f; private float r; [KSPField(guiActiveEditor = true, guiName = "Green", guiFormat = "F2", isPersistant = true)] [UI_FloatRange(minValue = 0, maxValue = 1, stepIncrement = .05f)] public float green = 1f; private float g; [KSPField(guiActiveEditor = true, guiName = "Blue", guiFormat = "F2", isPersistant = true)] [UI_FloatRange(minValue = 0, maxValue = 1, stepIncrement = .05f)] public float blue = 1f; private float b; [KSPField] public string textureMeshName = "Variable"; public Mesh textureMesh; public Renderer texRend; public Material mat; [KSPField] public bool newUV = true; public float updateDelay = 0; public override void OnAwake() { changeColor(true); setUV(newUV); base.OnAwake(); } /// <summary> /// Raises the start event. /// </summary> /// <param name="state">State.</param> public override void OnStart(StartState state) { changeColor(true); setUV(newUV); base.OnStart(state); } /// <summary> /// Standardizes the uv coords of the mesh. /// </summary> private void setUV(bool newUV) { if (textureMesh == null) { textureMesh = part.FindModelComponent<MeshFilter>(textureMeshName).mesh; } if (newUV) { Vector2[] uvs = new Vector2[textureMesh.vertices.Length]; for (int i = 0; i < uvs.Length; i++) { int j = i % 4; switch (j) { case 0: uvs[i] = Vector2.zero; break; case 1: uvs[i] = Vector2.up; break; case 2: uvs[i] = Vector2.right; break; case 3: uvs[i] = Vector2.one; break; } } textureMesh.uv = uvs; } } /// <summary> /// Called every frame. /// </summary> public void Update() { if (HighLogic.LoadedSceneIsEditor) { updateDelay -= Time.deltaTime; if (updateDelay <= 0) { changeColor(); updateDelay = 0.02f; } } } /// <summary> /// Changes the color of a mesh of a part implementing this PartModlue based on it's red, green, and blue values. /// </summary> public void changeColor(Boolean forceChange = false) { if (texRend == null) { texRend = part.FindModelComponent<Renderer>(textureMeshName); mat = new Material(texRend.material.shader); } if (red != r | green != g | blue != b | forceChange) { r = red; g = green; b = blue; Color color = new Color(r, g, ; Texture2D tex = new Texture2D(10, 10); Color[] colors = new Color[tex.height * tex.width]; for (int i = 0; i < colors.Length; i++) { colors[i] = color; } tex.SetPixels(colors); tex.Apply(); mat.mainTexture = tex; texRend.material = mat; if (forceChange) { print("[VariableTexture]:Changing Color! " +color); } } } } } Edit: was testing a little more and noticed that when you load in a vessel with multiple of the same part that implements the partmodule, they are all the same color. this was working before I added onAwake() (which I added to try and make the parts the right color in the editor) as seen here:
  8. Check all the transforms in the tree for the game object to make sure they are centered the way you want, and not just the gameobject transform. Otherwise, I don't know what would be causing the problem.
  9. I'll throw in my two cents on how I was able to fix this issue for myself. I was trying to make it so that KSP didn't have to load a texture that I made for multiple models multiple times. First of all, the part I was having trouble with had two materials: Material: One with the texture I didn't want to need to reload (ModelTexture) Variable: One without an assigned texture because the texture is just replaced in game anyways with a custom PartModule. Here is the MODEL node I had for the part: MODEL{ model = ModelRocketry/Parts/Structural/ModelTubeSmall/NewModel position = 0.0, 0.0, 0.0 scale = 1.0, 1.0, 1.0 rotation = 0, 0, 0 texture = ModelTexture , ModelRocketry/Parts/Aero/ModelFin/ModelTexture } With just this I was getting that annoying null reference error. How I was able to fix this is giving the Variable material its own texture (just a small 1 x 1 white texture). I didn't actually need to put a "texture =" for both of the textures and it compiled without any problems in KSP.
  10. I am excited to present my first KSP Add-on: Model Rocketry (Some Kerbal Engineers thought it would be a good idea to upscale model rocket parts in order to save money.) Alpha build, needs balancing Downloads: KerbalStuff Releases on Github Source Code Features Scaled Up Model Rocket parts A PartModule that allows you to change the color of some of the parts Parts Model Kerbal A probe shaped like a kerbal that can be attached by the side or on top of a stack. Has no torque itself. (Inspired by HarvesteR and Moach.) Model Engine A solid fuel engine that is meant for use with the other model parts. Model Engine Mount* A structural piece that you can put the model engine into to make it look nice. Model Tube* A tube for the body of the rocket. Feel free to stuff things inside of it. Small Model Tube* A shorter variant of the model tube. Model Nosecone* What rocket would be complete without a pointy end? Model Fin* Keeps things going straight... ish. * - Denotes a part that you can change the color of. Installation Unpack the .zip file. Copy the "ModelRocketry" folder into your GameData directory. Boot up KSP and have fun! Uninstallation Delete the "ModelRocketry" folder from your GameData directory. Licensing can be found with the source code or in the download.
  • Create New...