mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Merge branch 'dev' into no-more-CR
This commit is contained in:
commit
6b07ee8bf3
@ -32,16 +32,14 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
Color cloudTint = atmo.CloudTint == null ? Color.white : (Color)atmo.CloudTint.ToColor32();
|
||||
|
||||
GameObject cloudsMainGO = new GameObject();
|
||||
GameObject cloudsMainGO = new GameObject("Clouds");
|
||||
cloudsMainGO.SetActive(false);
|
||||
cloudsMainGO.transform.parent = body.transform;
|
||||
cloudsMainGO.name = "Clouds";
|
||||
|
||||
GameObject cloudsTopGO = new GameObject();
|
||||
GameObject cloudsTopGO = new GameObject("TopClouds");
|
||||
cloudsTopGO.SetActive(false);
|
||||
cloudsTopGO.transform.parent = cloudsMainGO.transform;
|
||||
cloudsTopGO.transform.localScale = Vector3.one * atmo.Size;
|
||||
cloudsTopGO.name = "TopClouds";
|
||||
|
||||
MeshFilter topMF = cloudsTopGO.AddComponent<MeshFilter>();
|
||||
topMF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
||||
@ -54,6 +52,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
var mat = new Material(GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials[i]);
|
||||
if (!atmo.ShadowsOnClouds) mat.renderQueue = 2550;
|
||||
mat.name = atmo.ShadowsOnClouds ? "AdvancedShadowCloud" : "AdvancedCloud";
|
||||
tempArray[i] = mat;
|
||||
}
|
||||
topMR.sharedMaterials = tempArray;
|
||||
@ -63,6 +62,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
if (_sphereShader == null) _sphereShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
|
||||
topMR.material = new Material(_sphereShader);
|
||||
if (!atmo.ShadowsOnClouds) topMR.material.renderQueue = 2550;
|
||||
topMR.material.name = atmo.ShadowsOnClouds ? "BasicShadowCloud" : "BasicCloud";
|
||||
}
|
||||
|
||||
foreach (var material in topMR.sharedMaterials)
|
||||
@ -86,11 +86,10 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
topRT._degreesPerSecond = 10;
|
||||
topRT._randomizeRotationRate = false;
|
||||
|
||||
GameObject cloudsBottomGO = new GameObject();
|
||||
GameObject cloudsBottomGO = new GameObject("BottomClouds");
|
||||
cloudsBottomGO.SetActive(false);
|
||||
cloudsBottomGO.transform.parent = cloudsMainGO.transform;
|
||||
cloudsBottomGO.transform.localScale = Vector3.one * (atmo.Size * 0.9f);
|
||||
cloudsBottomGO.name = "BottomClouds";
|
||||
|
||||
TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent<TessellatedSphereRenderer>();
|
||||
bottomTSR.tessellationMeshGroup = GameObject.Find("CloudsBottomLayer_GD").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
|
||||
@ -114,11 +113,10 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
TessSphereSectorToggle bottomTSST = cloudsBottomGO.AddComponent<TessSphereSectorToggle>();
|
||||
bottomTSST._sector = sector;
|
||||
|
||||
GameObject cloudsFluidGO = new GameObject();
|
||||
GameObject cloudsFluidGO = new GameObject("CloudsFluid");
|
||||
cloudsFluidGO.SetActive(false);
|
||||
cloudsFluidGO.layer = 17;
|
||||
cloudsFluidGO.transform.parent = cloudsMainGO.transform;
|
||||
cloudsFluidGO.name = "CloudsFluid";
|
||||
|
||||
SphereCollider fluidSC = cloudsFluidGO.AddComponent<SphereCollider>();
|
||||
fluidSC.isTrigger = true;
|
||||
|
||||
@ -14,7 +14,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
volumesGO.SetActive(false);
|
||||
volumesGO.transform.parent = body.transform;
|
||||
|
||||
GameObject rulesetGO = new GameObject();
|
||||
GameObject rulesetGO = new GameObject("Ruleset");
|
||||
rulesetGO.SetActive(false);
|
||||
rulesetGO.transform.parent = volumesGO.transform;
|
||||
|
||||
|
||||
@ -20,9 +20,10 @@ namespace NewHorizons.Builder.Body
|
||||
{
|
||||
var belt = parentConfig.AsteroidBelt;
|
||||
|
||||
var minSize = 20;
|
||||
var maxSize = 50;
|
||||
float minSize = belt.MinSize;
|
||||
float maxSize = belt.MaxSize;
|
||||
int count = (int)(2f * Mathf.PI * belt.InnerRadius / (10f * maxSize));
|
||||
if (belt.Amount >= 0) count = belt.Amount;
|
||||
if (count > 200) count = 200;
|
||||
|
||||
Random.InitState(belt.RandomSeed);
|
||||
|
||||
@ -11,7 +11,7 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
{
|
||||
static class CubeSphere
|
||||
{
|
||||
public static Mesh Build(int resolution, Texture2D heightMap, float minHeight, float maxHeight)
|
||||
public static Mesh Build(int resolution, Texture2D heightMap, float minHeight, float maxHeight, Vector3 stretch)
|
||||
{
|
||||
// It breaks if resolution is greater than 100 I don't know why
|
||||
if(resolution > 100)
|
||||
@ -23,15 +23,51 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
Mesh mesh = new Mesh();
|
||||
mesh.name = "CubeSphere";
|
||||
|
||||
float max = 1;
|
||||
if (stretch.x > stretch.y && stretch.x > stretch.z)
|
||||
max = stretch.x;
|
||||
else if (stretch.y > stretch.x && stretch.y > stretch.z)
|
||||
max = stretch.y;
|
||||
else if (stretch.z > stretch.x && stretch.z > stretch.y)
|
||||
max = stretch.z;
|
||||
else if (stretch.y == stretch.z && stretch.x > stretch.y)
|
||||
max = stretch.x;
|
||||
else if (stretch.x == stretch.z && stretch.y > stretch.x)
|
||||
max = stretch.y;
|
||||
else if (stretch.x == stretch.y && stretch.z > stretch.x)
|
||||
max = stretch.z;
|
||||
minHeight /= max;
|
||||
maxHeight /= max;
|
||||
|
||||
CreateVertices(mesh, resolution, heightMap, minHeight, maxHeight);
|
||||
StretchVertices(mesh, stretch);
|
||||
CreateTriangles(mesh, resolution);
|
||||
|
||||
mesh.RecalculateNormals();
|
||||
mesh.RecalculateBounds();
|
||||
mesh.RecalculateTangents();
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
private static void StretchVertices(Mesh mesh, Vector3 scale)
|
||||
{
|
||||
var baseVertices = mesh.vertices;
|
||||
|
||||
var vertices = new Vector3[baseVertices.Length];
|
||||
|
||||
for (var i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
var vertex = baseVertices[i];
|
||||
vertex.x = vertex.x * scale.x;
|
||||
vertex.y = vertex.y * scale.y;
|
||||
vertex.z = vertex.z * scale.z;
|
||||
vertices[i] = vertex;
|
||||
}
|
||||
|
||||
mesh.vertices = vertices;
|
||||
}
|
||||
|
||||
// Thank you Catlikecoding
|
||||
private static void CreateVertices(Mesh mesh, int resolution, Texture2D heightMap, float minHeight, float maxHeight)
|
||||
{
|
||||
|
||||
@ -38,7 +38,7 @@ namespace NewHorizons.Builder.Body
|
||||
cubeSphere.transform.parent = go.transform;
|
||||
cubeSphere.transform.rotation = Quaternion.Euler(90, 0, 0);
|
||||
|
||||
Mesh mesh = CubeSphere.Build(51, heightMap, module.MinHeight, module.MaxHeight);
|
||||
Mesh mesh = CubeSphere.Build(51, heightMap, module.MinHeight, module.MaxHeight, module.Stretch);
|
||||
|
||||
cubeSphere.AddComponent<MeshFilter>();
|
||||
cubeSphere.GetComponent<MeshFilter>().mesh = mesh;
|
||||
@ -49,6 +49,7 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
var cubeSphereMR = cubeSphere.AddComponent<MeshRenderer>();
|
||||
cubeSphereMR.material = new Material(PlanetShader);
|
||||
cubeSphereMR.material.name = textureMap.name;
|
||||
cubeSphereMR.material.mainTexture = textureMap;
|
||||
|
||||
var cubeSphereMC = cubeSphere.AddComponent<MeshCollider>();
|
||||
|
||||
3
NewHorizons/External/AsteroidBeltModule.cs
vendored
3
NewHorizons/External/AsteroidBeltModule.cs
vendored
@ -10,6 +10,9 @@ namespace NewHorizons.External
|
||||
{
|
||||
public float InnerRadius { get; set; }
|
||||
public float OuterRadius { get; set; }
|
||||
public float MinSize { get; set; } = 20;
|
||||
public float MaxSize { get; set; } = 50;
|
||||
public int Amount { get; set; } = -1;
|
||||
public float Inclination { get; set; }
|
||||
public float LongitudeOfAscendingNode { get; set; }
|
||||
public int RandomSeed { get; set; }
|
||||
|
||||
8
NewHorizons/External/HeightMapModule.cs
vendored
8
NewHorizons/External/HeightMapModule.cs
vendored
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NewHorizons.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.External
|
||||
{
|
||||
@ -12,5 +9,6 @@ namespace NewHorizons.External
|
||||
public string TextureMap { get; set; }
|
||||
public float MinHeight { get; set; }
|
||||
public float MaxHeight { get; set; }
|
||||
public MVector3 Stretch { get; set; } = (MVector3)Vector3.one;
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,6 +132,7 @@ namespace NewHorizons
|
||||
Logger.Log($"Scene Loaded: {scene.name} {mode}");
|
||||
|
||||
SearchUtilities.ClearCache();
|
||||
ImageUtilities.ClearCache();
|
||||
|
||||
_isChangingStarSystem = false;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using OWML.Common;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
@ -10,6 +11,7 @@ namespace NewHorizons.Utility
|
||||
public static Texture2D MakeOutline(Texture2D texture, Color color, int thickness)
|
||||
{
|
||||
var outline = new Texture2D(texture.width, texture.height, TextureFormat.ARGB32, false);
|
||||
outline.name = texture.name + "Outline";
|
||||
var outlinePixels = new Color[texture.width * texture.height];
|
||||
var pixels = texture.GetPixels();
|
||||
|
||||
@ -62,6 +64,7 @@ namespace NewHorizons.Utility
|
||||
}
|
||||
|
||||
var newImage = new Texture2D(image.width, image.height);
|
||||
newImage.name = image.name + "Tinted";
|
||||
newImage.SetPixels(pixels);
|
||||
newImage.Apply();
|
||||
return newImage;
|
||||
@ -78,6 +81,7 @@ namespace NewHorizons.Utility
|
||||
}
|
||||
|
||||
var newImage = new Texture2D(image.width, image.height);
|
||||
newImage.name = image.name + "LerpedGrayscale";
|
||||
newImage.SetPixels(pixels);
|
||||
newImage.Apply();
|
||||
return newImage;
|
||||
@ -86,6 +90,7 @@ namespace NewHorizons.Utility
|
||||
public static Texture2D LoadImage(string filepath)
|
||||
{
|
||||
Texture2D tex = new Texture2D(2, 2);
|
||||
tex.name = Path.GetFileNameWithoutExtension(filepath);
|
||||
tex.LoadRawTextureData(File.ReadAllBytes(filepath));
|
||||
return tex;
|
||||
}
|
||||
@ -93,6 +98,7 @@ namespace NewHorizons.Utility
|
||||
public static Texture2D ClearTexture(int width, int height)
|
||||
{
|
||||
var tex = (new Texture2D(1, 1, TextureFormat.ARGB32, false));
|
||||
tex.name = "Clear";
|
||||
Color fillColor = Color.clear;
|
||||
Color[] fillPixels = new Color[tex.width * tex.height];
|
||||
for(int i = 0; i < fillPixels.Length; i++)
|
||||
@ -107,6 +113,7 @@ namespace NewHorizons.Utility
|
||||
public static Texture2D CanvasScaled(Texture2D src, int width, int height)
|
||||
{
|
||||
var tex = (new Texture2D(width, height, TextureFormat.ARGB32, false));
|
||||
tex.name = src.name + "CanvasScaled";
|
||||
Color[] fillPixels = new Color[tex.width * tex.height];
|
||||
for (int i = 0; i < tex.width; i++)
|
||||
{
|
||||
@ -120,16 +127,36 @@ namespace NewHorizons.Utility
|
||||
return tex;
|
||||
}
|
||||
|
||||
private static Dictionary<string, Texture2D> _loadedTextures = new Dictionary<string, Texture2D>();
|
||||
|
||||
public static Texture2D GetTexture(IModBehaviour mod, string filename)
|
||||
{
|
||||
// Copied from OWML but without the print statement lol
|
||||
var path = mod.ModHelper.Manifest.ModFolderPath + filename;
|
||||
if (_loadedTextures.ContainsKey(path))
|
||||
{
|
||||
Logger.Log($"Already loaded image at path: {path}");
|
||||
return _loadedTextures[path];
|
||||
}
|
||||
Logger.Log($"Loading image at path: {path}");
|
||||
var data = File.ReadAllBytes(path);
|
||||
var texture = new Texture2D(2, 2);
|
||||
texture.name = Path.GetFileNameWithoutExtension(path);
|
||||
texture.LoadImage(data);
|
||||
_loadedTextures.Add(path, texture);
|
||||
return texture;
|
||||
}
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
foreach(var texture in _loadedTextures.Values)
|
||||
{
|
||||
if (texture == null) continue;
|
||||
UnityEngine.Object.Destroy(texture);
|
||||
}
|
||||
_loadedTextures.Clear();
|
||||
}
|
||||
|
||||
public static Color GetAverageColor(Texture2D src)
|
||||
{
|
||||
var pixels = src.GetPixels32();
|
||||
|
||||
@ -439,6 +439,10 @@
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"description": "The highest points on your planet will be at this height."
|
||||
},
|
||||
"stretch": {
|
||||
"$ref": "#/$defs/vector3",
|
||||
"description": "The scale of the terrain."
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -459,6 +463,24 @@
|
||||
"default": 0,
|
||||
"minimum": 0
|
||||
},
|
||||
"minSize": {
|
||||
"type": "number",
|
||||
"default": 20,
|
||||
"minimum": 0,
|
||||
"description": "Minimum size of the asteroids."
|
||||
},
|
||||
"maxSize": {
|
||||
"type": "number",
|
||||
"default": 50,
|
||||
"minimum": 0,
|
||||
"description": "Maximum size of the asteroids."
|
||||
},
|
||||
"amount": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 200,
|
||||
"description": "Amount of asteroids to create."
|
||||
},
|
||||
"inclination": {
|
||||
"$ref": "#/$defs/angle",
|
||||
"description": "Angle between the rings and the equatorial plane of the planet."
|
||||
@ -581,6 +603,14 @@
|
||||
"type": "string",
|
||||
"description": "Relative filepath to an asset-bundle"
|
||||
},
|
||||
"objFilePath": {
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the obj file"
|
||||
},
|
||||
"mtlFilePath": {
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the mtl file of the obj file"
|
||||
},
|
||||
"position": {
|
||||
"$ref": "#/$defs/vector3"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user