From ace3755cc7a5f6ab3801f1077af92f649810b19b Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 11 Mar 2022 22:10:16 -0500 Subject: [PATCH] Add tidal lock and comet tail orientation parameters --- NewHorizons/Builder/Body/CometTailBuilder.cs | 6 ++-- NewHorizons/Builder/Updater/OrbitUpdater.cs | 2 +- NewHorizons/External/BaseModule.cs | 1 + NewHorizons/schema.json | 32 ++++++++++++-------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index 93a43605..60b4d5fe 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -19,10 +19,10 @@ namespace NewHorizons.Builder.Body cometTail.name = "CometTail"; cometTail.transform.localScale = Vector3.one * config.Base.SurfaceSize / 110; - Vector3 alignmentAxis = new Vector3(0, -1, 0); - if (config.Orbit.AlignmentAxis != null) alignmentAxis = config.Orbit.AlignmentAxis; + Vector3 alignment = new Vector3(0, 270, 90); + if (config.Base.CometTailRotation != null) alignment = config.Base.CometTailRotation; - cometTail.transform.localRotation = Quaternion.Euler(0, 270, 90) * Quaternion.FromToRotation(new Vector3(0, -1, 0), alignmentAxis); + cometTail.transform.rotation = Quaternion.Euler(alignment); } } } diff --git a/NewHorizons/Builder/Updater/OrbitUpdater.cs b/NewHorizons/Builder/Updater/OrbitUpdater.cs index a188126c..ac4f014d 100644 --- a/NewHorizons/Builder/Updater/OrbitUpdater.cs +++ b/NewHorizons/Builder/Updater/OrbitUpdater.cs @@ -49,7 +49,7 @@ namespace NewHorizons.Builder.Updater var planetoid = new Planet.Plantoid( original.size, original.gravity, - go.transform.rotation, + mapping[heavenlyBody].state.orbit.orientation.rotation, InitialMotionBuilder.SiderealPeriodToAngularSpeed(body.Config.Orbit.SiderealPeriod), parent, coords diff --git a/NewHorizons/External/BaseModule.cs b/NewHorizons/External/BaseModule.cs index 1b9f9f78..1dd32d55 100644 --- a/NewHorizons/External/BaseModule.cs +++ b/NewHorizons/External/BaseModule.cs @@ -17,6 +17,7 @@ namespace NewHorizons.External public float SphereOfInfluence { get; set; } public float GroundSize { get; set; } public bool HasCometTail { get; set; } + public MVector3 CometTailRotation { get; set; } public bool HasReferenceFrame { get; set; } = true; public bool CenterOfSolarSystem { get; set; } = false; public bool IsSatellite { get; set; } diff --git a/NewHorizons/schema.json b/NewHorizons/schema.json index ff92347c..94d8b609 100644 --- a/NewHorizons/schema.json +++ b/NewHorizons/schema.json @@ -131,12 +131,12 @@ "hasMapMarker": { "type": "boolean", "default": false, - "description" : "If the body should have a marker on the map screen." + "description": "If the body should have a marker on the map screen." }, "hasAmbientLight": { "type": "boolean", "default": false, - "description" : "If the dark side of the body should have some slight ammount of light" + "description": "If the dark side of the body should have some slight ammount of light" }, "surfaceGravity": { "type": "number", @@ -150,7 +150,7 @@ "inverseSquared" ], "default": "linear", - "description" : "How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared." + "description": "How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared." }, "surfaceSize": { "type": "number", @@ -170,7 +170,11 @@ "hasCometTail": { "type": "boolean", "default": false, - "description" : "If you want the body to have a tail like the Interloper." + "description": "If you want the body to have a tail like the Interloper." + }, + "cometTailRotation": { + "type": "#/$defs/vector3", + "description": "If it has a comet tail, it'll be oriented according to these Euler angles." }, "hasReferenceFrame": { "type": "boolean", @@ -286,41 +290,45 @@ }, "longitudeOfAscendingNode": { "$ref": "#/$defs/angle", - "description" : "An angle (in degrees) defining the point where the orbit of the body rises above the orbital plane if it has nonzero inclination." + "description": "An angle (in degrees) defining the point where the orbit of the body rises above the orbital plane if it has nonzero inclination." }, "eccentricity": { "type": "number", "default": 0, "minimum": 0, "maximum": 0.99999, - "description" : "At 0 the orbit is a circle. The closer to 1 it is, the more oval-shaped the orbit is." + "description": "At 0 the orbit is a circle. The closer to 1 it is, the more oval-shaped the orbit is." }, "argumentOfPeriapsis": { "$ref": "#/$defs/angle", - "description" : "An angle (in degrees) defining the location of the periapsis (closest distance to it's primary body) if it has nonzero eccentricity." + "description": "An angle (in degrees) defining the location of the periapsis (closest distance to it's primary body) if it has nonzero eccentricity." }, "trueAnomaly": { "$ref": "#/$defs/angle", - "description" : "Where the planet should start off in its orbit in terms of the central angle." + "description": "Where the planet should start off in its orbit in terms of the central angle." }, "axialTilt": { "$ref": "#/$defs/angle", - "description" : "The angle between the normal to the orbital plane and its axis of rotation." + "description": "The angle between the normal to the orbital plane and its axis of rotation." }, "siderealPeriod": { "type": "number", "default": 0, - "description" : "Rotation period in minutes." + "description": "Rotation period in minutes." }, "isTidallyLocked": { "type": "boolean", "default": false, - "description" : "Should the body always have one side facing its primary?" + "description": "Should the body always have one side facing its primary?" + }, + "alignmentAxis": { + "type": "#/$defs/vector3", + "description": "If it is tidally locked, this direction will face towards the primary. Ex) Interloper uses 0, -1, 0. Most planets will want something like -1, 0, 0." }, "showOrbitLine": { "type": "boolean", "default": false, - "description" : "Referring to the orbit line in the map screen." + "description": "Referring to the orbit line in the map screen." }, "isStatic": { "type": "boolean",