show actual names of stars when targeting them
This commit is contained in:
parent
81187b4fe6
commit
9f15e78e07
|
@ -1,10 +1,13 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# This script requires the following file in the assets/tmp/ directory:
|
# This script requires the following file in the extra/ directory:
|
||||||
# https://github.com/astronexus/HYG-Database/blob/cbd21013d2bb89732b893be357a6f41836dbe614/hyg/CURRENT/hygdata_v41.csv
|
# https://github.com/astronexus/HYG-Database/blob/cbd21013d2bb89732b893be357a6f41836dbe614/hyg/CURRENT/hygdata_v41.csv
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
import sys
|
import sys
|
||||||
import math
|
import math
|
||||||
|
import re
|
||||||
|
|
||||||
|
PATH = "extra/hygdata_v41.csv"
|
||||||
|
|
||||||
#def entry(ra_hour, ra_min, ra_sec, dec_deg, dec_min, dec_sec, mag, name, color_index):
|
#def entry(ra_hour, ra_min, ra_sec, dec_deg, dec_min, dec_sec, mag, name, color_index):
|
||||||
# return [
|
# return [
|
||||||
|
@ -28,19 +31,20 @@ import math
|
||||||
# Meissa (orion's head, 8th brightest star in orion) = 3.33
|
# Meissa (orion's head, 8th brightest star in orion) = 3.33
|
||||||
MAX_APPARENT_MAGNITUDE = 7.0
|
MAX_APPARENT_MAGNITUDE = 7.0
|
||||||
|
|
||||||
print("// The \"STARS\" constant was autogenerated by \"genrate_starchart.py\" using data")
|
print("// This file was autogenerated by \"genrate_starchart.py\" using data from the")
|
||||||
print("// from the HYG database: https://github.com/astronexus/HYG-Database/tree/main/hyg")
|
print("// HYG database: https://github.com/astronexus/HYG-Database/tree/main/hyg")
|
||||||
print("// License: CC BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/")
|
print("// License: CC BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/")
|
||||||
print("")
|
print("")
|
||||||
print("// Each star's values: [x, y, z, magnitude, color index]")
|
print("// Each star's values: [x, y, z, magnitude, color index, distance, name]")
|
||||||
print("pub const STARS: &[[f32; 5]] = &[")
|
print("pub const STARS: &[(f32; f32, f32, f32, f32, f32, str)] = &[")
|
||||||
|
|
||||||
|
|
||||||
def render(ra, dec, mag, ci, proper):
|
def render(ra, dec, mag, ci, dist, name):
|
||||||
# Takes ra/deg in degrees
|
# Takes ra/deg in degrees
|
||||||
ra = float(ra)
|
ra = float(ra)
|
||||||
dec = float(dec)
|
dec = float(dec)
|
||||||
mag = float(mag)
|
mag = float(mag)
|
||||||
|
name = re.sub(r'\s+', ' ', name)
|
||||||
|
|
||||||
distance = 1.0
|
distance = 1.0
|
||||||
ra_radians = math.radians(ra * 15) # ra is in [0, 24], multiplying by 15 gives degrees in [0, 360]
|
ra_radians = math.radians(ra * 15) # ra is in [0, 24], multiplying by 15 gives degrees in [0, 360]
|
||||||
|
@ -53,18 +57,20 @@ def render(ra, dec, mag, ci, proper):
|
||||||
# Correct for differences in coordinate system axes
|
# Correct for differences in coordinate system axes
|
||||||
x, y, z = x, z, y
|
x, y, z = x, z, y
|
||||||
|
|
||||||
comment = f" // {proper}" if proper else ""
|
#brightness = 2.512 ** (0 - mag)
|
||||||
|
|
||||||
brightness = 2.512 ** (0 - mag)
|
print(f' ({x:.04}, {y:.04}, {z:.04}, {mag:.04}, {ci}, {dist}, "{name}"),')
|
||||||
|
|
||||||
print(f" [{x:.04}, {y:.04}, {z:.04}, {mag:.04}, {ci}],{comment}")
|
|
||||||
|
def clean_name(string):
|
||||||
|
return "".join([c for c in string if c.isalnum() or c in ' -_'])
|
||||||
|
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
count = 0
|
count = 0
|
||||||
count_extra = 0
|
count_extra = 0
|
||||||
entries = []
|
entries = []
|
||||||
with open("assets/tmp/hygdata_v41.csv", "r", encoding="utf-8") as f:
|
with open(PATH, "r", encoding="utf-8") as f:
|
||||||
for entry in csv.DictReader(f):
|
for entry in csv.DictReader(f):
|
||||||
entries.append(entry)
|
entries.append(entry)
|
||||||
|
|
||||||
|
@ -76,13 +82,18 @@ for entry in entries:
|
||||||
dec = entry['dec']
|
dec = entry['dec']
|
||||||
mag = entry['mag']
|
mag = entry['mag']
|
||||||
ci = entry['ci']
|
ci = entry['ci']
|
||||||
proper = entry['proper']
|
dist = entry['dist']
|
||||||
proper = "".join([c for c in proper if c.isalnum() or c in ' -_'])
|
name = clean_name(entry['proper'])
|
||||||
|
if not name:
|
||||||
|
name = clean_name(entry['bf'])
|
||||||
|
if not name:
|
||||||
|
name = clean_name(entry['gl'])
|
||||||
|
|
||||||
if not all([ra, dec, mag, ci]):
|
if not all([ra, dec, mag, ci]):
|
||||||
continue
|
continue
|
||||||
if float(mag) > MAX_APPARENT_MAGNITUDE:
|
if float(mag) > MAX_APPARENT_MAGNITUDE:
|
||||||
continue
|
continue
|
||||||
render(ra, dec, mag, ci, proper)
|
render(ra, dec, mag, ci, dist, name)
|
||||||
count += 1
|
count += 1
|
||||||
#for entry in CUSTOM_ENTRIES:
|
#for entry in CUSTOM_ENTRIES:
|
||||||
# render(entry[0], entry[1], entry[2], entry[3], entry[4])
|
# render(entry[0], entry[1], entry[2], entry[3], entry[4])
|
||||||
|
|
|
@ -6,6 +6,7 @@ mod commands;
|
||||||
mod effects;
|
mod effects;
|
||||||
mod hud;
|
mod hud;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
mod stars;
|
||||||
mod world;
|
mod world;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
15553
src/nature.rs
15553
src/nature.rs
File diff suppressed because it is too large
Load diff
15551
src/stars.rs
Normal file
15551
src/stars.rs
Normal file
File diff suppressed because it is too large
Load diff
23
src/world.rs
23
src/world.rs
|
@ -1,4 +1,4 @@
|
||||||
use crate::{actor, hud, nature, settings};
|
use crate::{actor, hud, nature, settings, stars};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
|
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
|
||||||
use bevy::math::{DVec3, I64Vec3};
|
use bevy::math::{DVec3, I64Vec3};
|
||||||
|
@ -123,8 +123,8 @@ pub fn setup(
|
||||||
// Generate starmap
|
// Generate starmap
|
||||||
let sphere_handle = meshes.add(Sphere::new(1.0));
|
let sphere_handle = meshes.add(Sphere::new(1.0));
|
||||||
let mut starcount = 0;
|
let mut starcount = 0;
|
||||||
for star in nature::STARS {
|
for star in stars::STARS {
|
||||||
let mag = star[3];
|
let mag = star.3;
|
||||||
if mag > STARS_MAX_MAGNITUDE {
|
if mag > STARS_MAX_MAGNITUDE {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -142,26 +142,31 @@ pub fn setup(
|
||||||
1000.0 * (0.230299 * mag * mag - 3.09013 * mag + 15.1782)
|
1000.0 * (0.230299 * mag * mag - 3.09013 * mag + 15.1782)
|
||||||
} * 100.0
|
} * 100.0
|
||||||
};
|
};
|
||||||
let (r, g, b) = nature::star_color_index_to_rgb(star[4]);
|
let (r, g, b) = nature::star_color_index_to_rgb(star.4);
|
||||||
let star_color_handle = materials.add(StandardMaterial {
|
let star_color_handle = materials.add(StandardMaterial {
|
||||||
base_color: Color::rgb(scale_color(r), scale_color(g), scale_color(b)),
|
base_color: Color::rgb(scale_color(r), scale_color(g), scale_color(b)),
|
||||||
unlit: true,
|
unlit: true,
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
let dist = 1e9;
|
let dist = 1e9;
|
||||||
|
let name = if star.6.is_empty() {
|
||||||
|
"Uncharted Star".to_string()
|
||||||
|
} else {
|
||||||
|
star.6.to_string()
|
||||||
|
};
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Star,
|
Star,
|
||||||
hud::IsClickable {
|
hud::IsClickable {
|
||||||
name: Some("Star".to_string()),
|
name: Some(name),
|
||||||
distance: Some(10000000000.0),
|
distance: Some(nature::PARSEC2METER * star.5 as f64),
|
||||||
},
|
},
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: sphere_handle.clone(),
|
mesh: sphere_handle.clone(),
|
||||||
material: star_color_handle,
|
material: star_color_handle,
|
||||||
transform: Transform::from_xyz(
|
transform: Transform::from_xyz(
|
||||||
dist * star[0],
|
dist * star.0,
|
||||||
dist * star[1],
|
dist * star.1,
|
||||||
dist * star[2],
|
dist * star.2,
|
||||||
)
|
)
|
||||||
.with_scale(Vec3::splat(scale_size(mag))),
|
.with_scale(Vec3::splat(scale_size(mag))),
|
||||||
..default()
|
..default()
|
||||||
|
|
Loading…
Reference in a new issue