-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
769 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**v0.1.0** | ||
|
||
First Beta Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"NAME": "<b><color=#9B59B6>Sigma Cartographer</color></b>", | ||
"URL": "https://raw.githubusercontent.com/Sigma88/Sigma-Cartographer/master/GameData/Sigma/Cartographer/Sigma-Cartographer.version", | ||
"DOWNLOAD": "https://github.com/Sigma88/Sigma-Cartographer/releases/latest", | ||
"CHANGE_LOG_URL": "https://raw.githubusercontent.com/Sigma88/Sigma-Cartographer/master/Changelog.txt", | ||
"GITHUB": | ||
{ | ||
"USERNAME": "Sigma88", | ||
"REPOSITORY": "Sigma-Cartographer", | ||
"ALLOW_PRE_RELEASE": false | ||
}, | ||
"VERSION": | ||
{ | ||
"MAJOR": 0, | ||
"MINOR": 1, | ||
"PATCH": 0, | ||
"BUILD": 0 | ||
}, | ||
"KSP_VERSION": | ||
{ | ||
"MAJOR": 1, | ||
"MINOR": 3, | ||
"PATCH": 1 | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Sigma-Cartographer | ||
Map exporting tool for KSP | ||
# Sigma Cartographer | ||
|
||
**Map exporting tool for KSP** |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
using System.Linq; | ||
using System.IO; | ||
using UnityEngine; | ||
|
||
|
||
namespace SigmaRandomPlugin | ||
{ | ||
[KSPAddon(KSPAddon.Startup.MainMenu, false)] | ||
class BodyInfo : MonoBehaviour | ||
{ | ||
static string[] info = new string[9]; | ||
|
||
void Start() | ||
{ | ||
UrlDir.UrlConfig[] nodes = GameDatabase.Instance?.GetConfigs("SigmaCartographer"); | ||
|
||
foreach (var node in nodes) | ||
{ | ||
foreach (var bodyInfo in node.config.GetNodes("Info")) | ||
{ | ||
foreach (var bodyName in bodyInfo.GetValues("body")) | ||
{ | ||
CelestialBody body = FlightGlobals.Bodies.FirstOrDefault(p => p.transform.name == bodyName); | ||
if (body?.pqsController != null) | ||
{ | ||
FirstPass(body); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
void FirstPass(CelestialBody body) | ||
{ | ||
double lowest = double.MaxValue; | ||
double highest = double.MinValue; | ||
|
||
Vector2d LatLonLo = new Vector2d(); | ||
Vector2d LatLonHi = new Vector2d(); | ||
|
||
for (double LON = -180; LON < 180; LON += 0.1) | ||
{ | ||
for (double LAT = -90; LAT <= 90; LAT += 0.1) | ||
{ | ||
double ALT = body.TerrainAltitude(LAT, LON, true); | ||
|
||
if (ALT < lowest) | ||
{ | ||
lowest = ALT; | ||
LatLonLo = new Vector2d(LAT, LON); | ||
} | ||
if (ALT > highest) | ||
{ | ||
highest = ALT; | ||
LatLonHi = new Vector2d(LAT, LON); | ||
} | ||
} | ||
} | ||
Lowest(body, LatLonLo); | ||
Highest(body, LatLonHi); | ||
} | ||
|
||
void Lowest(CelestialBody body, Vector2d LatLon) | ||
{ | ||
double altitude = double.MaxValue; | ||
double latitude = LatLon.x; | ||
double longitude = LatLon.y; | ||
|
||
for (double LON = LatLon.y - 0.1; LON <= LatLon.y + 0.1; LON += 0.001) | ||
{ | ||
for (double LAT = LatLon.x - 0.1; LAT <= LatLon.x + 0.1; LAT += 0.001) | ||
{ | ||
double ALT = body.TerrainAltitude(LAT, LON, true); | ||
if (ALT < altitude) | ||
{ | ||
latitude = LAT; | ||
longitude = LON; | ||
altitude = ALT; | ||
} | ||
} | ||
} | ||
|
||
info[0] = "Lowest Point"; | ||
info[1] = "LAT = " + latitude; | ||
info[2] = "LON = " + longitude; | ||
info[3] = "ALT = " + altitude; | ||
info[4] = ""; | ||
} | ||
|
||
void Highest(CelestialBody body, Vector2d LatLon) | ||
{ | ||
double altitude = double.MinValue; | ||
double latitude = LatLon.x; | ||
double longitude = LatLon.y; | ||
|
||
for (double LON = LatLon.y - 0.1; LON <= LatLon.y + 0.1; LON += 0.001) | ||
{ | ||
for (double LAT = LatLon.x - 0.1; LAT <= LatLon.x + 0.1; LAT += 0.001) | ||
{ | ||
double ALT = body.TerrainAltitude(LAT, LON, true); | ||
if (ALT > altitude) | ||
{ | ||
latitude = LAT; | ||
longitude = LON; | ||
altitude = ALT; | ||
} | ||
} | ||
} | ||
|
||
info[5] = "Highest Point"; | ||
info[6] = "LAT = " + latitude; | ||
info[7] = "LON = " + longitude; | ||
info[8] = "ALT = " + altitude; | ||
|
||
string path = "GameData/Sigma/Cartographer/PluginData/" + body.transform.name + "/"; | ||
|
||
Directory.CreateDirectory(path); | ||
File.WriteAllLines(path + "Info.txt", info); | ||
} | ||
} | ||
} |
Oops, something went wrong.