Jump to content

Search the Community

Showing results for tags 'fog'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements
    • Welcome Aboard
  • Kerbal Space Program 2
    • KSP2 Dev Updates
    • KSP2 Discussion
    • KSP2 Suggestions and Development Discussion
    • Challenges & Mission Ideas
    • The KSP2 Spacecraft Exchange
    • Mission Reports
    • KSP2 Prelaunch Archive
  • Kerbal Space Program 2 Gameplay & Technical Support
    • KSP2 Gameplay Questions and Tutorials
    • KSP2 Technical Support (PC, unmodded installs)
    • KSP2 Technical Support (PC, modded installs)
  • Kerbal Space Program 2 Mods
    • KSP2 Mod Discussions
    • KSP2 Mod Releases
    • KSP2 Mod Development
  • Kerbal Space Program 1
    • KSP1 The Daily Kerbal
    • KSP1 Discussion
    • KSP1 Suggestions & Development Discussion
    • KSP1 Challenges & Mission ideas
    • KSP1 The Spacecraft Exchange
    • KSP1 Mission Reports
    • KSP1 Gameplay and Technical Support
    • KSP1 Mods
    • KSP1 Expansions
  • Community
    • Science & Spaceflight
    • Kerbal Network
    • The Lounge
    • KSP Fan Works
  • International
    • International
  • KerbalEDU
    • KerbalEDU
    • KerbalEDU Website

Categories

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Skype


Twitter


About me


Location


Interests

Found 2 results

  1. Hello, I'm rather new to modding KSP and Unity in general. I am attempting to add fog and clouds to KSP and I have really no clue where to begin. I've searched Google high and low as well as the forums and all I could find is incomplete code snippets so small that they really don't help much. If someone has the time and knowledge, would you lend me a hand. Below is my code so far. I think I am on the right track with making a gameobject, assigning it's .maintexture to be my texture I choose, adding a mesh, creating vertices, triangles, etc. but I really have no idea if this is correct and if it is, where do I go now. using System; using System.IO; using System.Collections; using UnityEngine; using KSP; namespace Clouds { public class Clouds_Main : MonoBehaviour { bool debug_output = false; Texture2D white_clouds = null, storm_clouds = null; private float lastFixedUpdate = 0.0f, logInterval = 2.5f; Mesh light_cloud_mesh = new Mesh(); Mesh dark_cloud_mesh = new Mesh(); public Material light_cloud_material; public Material dark_cloud_material; GameObject dark_cloud_gameObject; GameObject light_cloud_gameObject; /* Caution: as it says here: http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.Awake.html, use the Awake() method instead of the constructor for initializing data because Unity uses Serialization a lot. */ /* Called after the scene is loaded. */ void Awake() { if (white_clouds == null) white_clouds = LoadPNG(@"C:\Program Files (x86)\Steam\SteamApps\common\Kerbal Space Program\GameData\Wind Mod\S_Cloud4.png"); // Load the S_Cloud4.png Icon image into memory if (storm_clouds == null) storm_clouds = LoadPNG(@"C:\Program Files (x86)\Steam\SteamApps\common\Kerbal Space Program\GameData\Wind Mod\D_Cloud1.png"); // Load the D_Cloud1.png Icon image into memory light_cloud_material.SetTexture(0, white_clouds); dark_cloud_material.SetTexture(1, storm_clouds); } /* Called next. */ void Start() { dark_cloud_gameObject.AddComponent<MeshRenderer>().material.mainTexture = dark_cloud_material.GetTexture(1); dark_cloud_mesh = dark_cloud_gameObject.AddComponent<MeshFilter>().mesh; dark_cloud_mesh.Clear(); dark_cloud_mesh.vertices = new Vector3[] { new Vector3(-0.5f, 0, -0.5f), new Vector3(0.5f, 0, -0.5f), new Vector3(0.5f, 0, 0.5f), new Vector3(-0.5f, 0, 0.5f) }; dark_cloud_mesh.uv = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0) }; dark_cloud_mesh.triangles = new int[] { 0, 1, 2, 2, 3, 0 }; light_cloud_gameObject.AddComponent<MeshRenderer>().material.mainTexture = light_cloud_material.GetTexture(0); light_cloud_mesh = light_cloud_gameObject.AddComponent<MeshFilter>().mesh; light_cloud_mesh.Clear(); light_cloud_mesh.vertices = new Vector3[] { new Vector3(-0.5f, 0, -0.5f), new Vector3(0.5f, 0, -0.5f), new Vector3(0.5f, 0, 0.5f), new Vector3(-0.5f, 0, 0.5f) }; light_cloud_mesh.uv = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0) }; light_cloud_mesh.triangles = new int[] { 0, 1, 2, 2, 3, 0 }; } /* Called every frame */ void Update() { } /* Called at a fixed time interval determined by the physics time step. */ void FixedUpdate() { if ((Time.time - lastFixedUpdate) > logInterval) { } } /* Called when the game is leaving the scene (or exiting). Perform any clean up work here. */ void OnDestroy() { } Texture2D LoadPNG(string filePath) // Converts a .png image into a BYTE array that Unity needs in order to display as a GUI image { Texture2D temp_texture = null; // Ensure the texture is always reset byte[] fileData; if (File.Exists(filePath)) { fileData = File.ReadAllBytes(filePath); temp_texture = new Texture2D(2, 2); temp_texture.LoadImage(fileData); //..this will auto-resize the texture dimensions. } else { if (debug_output) Debug.Log("[WIND MOD : Gui Draw] Icon file does not exist in location: " + filePath); } return temp_texture; } } } I would greatly appreciate any help you can give. Thanks in advance.
  2. Hello, I'm rather new to modding KSP and Unity in general. I am attempting to add fog and clouds to KSP and I have really no clue where to begin. I've searched Google high and low as well as the forums and all I could find is incomplete code snippets so small that they really don't help much. If someone has the time and knowledge, would you lend me a hand. Below is my code so far. I think I am on the right track with making a gameobject, assigning it's .maintexture to be my texture I choose, adding a mesh, creating vertices, triangles, etc. but I really have no idea if this is correct and if it is, where do I go now. using System; using System.IO; using System.Collections; using UnityEngine; using KSP; namespace Clouds { public class Clouds_Main : MonoBehaviour { bool debug_output = false; Texture2D white_clouds = null, storm_clouds = null; private float lastFixedUpdate = 0.0f, logInterval = 2.5f; Mesh light_cloud_mesh = new Mesh(); Mesh dark_cloud_mesh = new Mesh(); public Material light_cloud_material; public Material dark_cloud_material; GameObject dark_cloud_gameObject; GameObject light_cloud_gameObject; /* Caution: as it says here: http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.Awake.html, use the Awake() method instead of the constructor for initializing data because Unity uses Serialization a lot. */ /* Called after the scene is loaded. */ void Awake() { if (white_clouds == null) white_clouds = LoadPNG(@"C:\Program Files (x86)\Steam\SteamApps\common\Kerbal Space Program\GameData\Wind Mod\S_Cloud4.png"); // Load the S_Cloud4.png Icon image into memory if (storm_clouds == null) storm_clouds = LoadPNG(@"C:\Program Files (x86)\Steam\SteamApps\common\Kerbal Space Program\GameData\Wind Mod\D_Cloud1.png"); // Load the D_Cloud1.png Icon image into memory light_cloud_material.SetTexture(0, white_clouds); dark_cloud_material.SetTexture(1, storm_clouds); } /* Called next. */ void Start() { dark_cloud_gameObject.AddComponent<MeshRenderer>().material.mainTexture = dark_cloud_material.GetTexture(1); dark_cloud_mesh = dark_cloud_gameObject.AddComponent<MeshFilter>().mesh; dark_cloud_mesh.Clear(); dark_cloud_mesh.vertices = new Vector3[] { new Vector3(-0.5f, 0, -0.5f), new Vector3(0.5f, 0, -0.5f), new Vector3(0.5f, 0, 0.5f), new Vector3(-0.5f, 0, 0.5f) }; dark_cloud_mesh.uv = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0) }; dark_cloud_mesh.triangles = new int[] { 0, 1, 2, 2, 3, 0 }; light_cloud_gameObject.AddComponent<MeshRenderer>().material.mainTexture = light_cloud_material.GetTexture(0); light_cloud_mesh = light_cloud_gameObject.AddComponent<MeshFilter>().mesh; light_cloud_mesh.Clear(); light_cloud_mesh.vertices = new Vector3[] { new Vector3(-0.5f, 0, -0.5f), new Vector3(0.5f, 0, -0.5f), new Vector3(0.5f, 0, 0.5f), new Vector3(-0.5f, 0, 0.5f) }; light_cloud_mesh.uv = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0) }; light_cloud_mesh.triangles = new int[] { 0, 1, 2, 2, 3, 0 }; } /* Called every frame */ void Update() { } /* Called at a fixed time interval determined by the physics time step. */ void FixedUpdate() { if ((Time.time - lastFixedUpdate) > logInterval) { } } /* Called when the game is leaving the scene (or exiting). Perform any clean up work here. */ void OnDestroy() { } Texture2D LoadPNG(string filePath) // Converts a .png image into a BYTE array that Unity needs in order to display as a GUI image { Texture2D temp_texture = null; // Ensure the texture is always reset byte[] fileData; if (File.Exists(filePath)) { fileData = File.ReadAllBytes(filePath); temp_texture = new Texture2D(2, 2); temp_texture.LoadImage(fileData); //..this will auto-resize the texture dimensions. } else { if (debug_output) Debug.Log("[WIND MOD : Gui Draw] Icon file does not exist in location: " + filePath); } return temp_texture; } } } I would greatly appreciate any help you can give. Thanks in advance.
×
×
  • Create New...