place stars at their actual xyz coordinate. (try zooming out in map 🤯)
This commit is contained in:
parent
fca8251f27
commit
ea26711806
|
@ -34,33 +34,34 @@ MAX_APPARENT_MAGNITUDE = 7.0
|
|||
print("// This file was autogenerated by \"genrate_starchart.py\" using data from the")
|
||||
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("// Each star's values: (x, y, z, magnitude, color index, distance, name)")
|
||||
print("// Each star's values: (x, y, z, magnitude, absolute magnitude, color index, name)")
|
||||
print("[")
|
||||
|
||||
|
||||
def render(ra, dec, mag, ci, dist, name):
|
||||
def render(x, y, z, ra, dec, mag, absmag, ci, dist, name):
|
||||
# Takes ra/deg in degrees
|
||||
ra = float(ra)
|
||||
dec = float(dec)
|
||||
mag = float(mag)
|
||||
x, y, z = float(x), float(y), float(z)
|
||||
name = re.sub(r'\s+', ' ', name)
|
||||
if name == 'Sol':
|
||||
return
|
||||
|
||||
distance = 1.0
|
||||
ra_radians = math.radians(ra * 15) # ra is in [0, 24], multiplying by 15 gives degrees in [0, 360]
|
||||
dec_radians = math.radians(dec)
|
||||
#print(f"ra_radians={ra_radians}, dec_radians={dec_radians}, dec={dec}, ra={ra}", file=sys.stderr)
|
||||
x = distance * math.cos(dec_radians) * math.cos(-ra_radians)
|
||||
y = distance * math.cos(dec_radians) * math.sin(-ra_radians)
|
||||
z = distance * math.sin(dec_radians)
|
||||
|
||||
# Correct for differences in coordinate system axes
|
||||
x, y, z = x, z, y
|
||||
# distance = 1.0
|
||||
# ra_radians = math.radians(ra * 15) # ra is in [0, 24], multiplying by 15 gives degrees in [0, 360]
|
||||
# dec_radians = math.radians(dec)
|
||||
# #print(f"ra_radians={ra_radians}, dec_radians={dec_radians}, dec={dec}, ra={ra}", file=sys.stderr)
|
||||
# x = distance * math.cos(dec_radians) * math.cos(-ra_radians)
|
||||
# y = distance * math.cos(dec_radians) * math.sin(-ra_radians)
|
||||
# z = distance * math.sin(dec_radians)
|
||||
#
|
||||
# # Correct for differences in coordinate system axes
|
||||
# x, y, z = x, z, y
|
||||
|
||||
#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},{absmag:.04},{ci},"{name}"),')
|
||||
|
||||
|
||||
def clean_name(string):
|
||||
|
@ -81,7 +82,11 @@ for entry in entries:
|
|||
total += 1
|
||||
ra = entry['ra']
|
||||
dec = entry['dec']
|
||||
x = entry['x']
|
||||
y = entry['y']
|
||||
z = entry['z']
|
||||
mag = entry['mag']
|
||||
absmag = entry['absmag']
|
||||
ci = entry['ci']
|
||||
dist = entry['dist']
|
||||
name = clean_name(entry['proper'])
|
||||
|
@ -94,7 +99,7 @@ for entry in entries:
|
|||
continue
|
||||
if float(mag) > MAX_APPARENT_MAGNITUDE:
|
||||
continue
|
||||
render(ra, dec, mag, ci, dist, name)
|
||||
render(x, y, z, ra, dec, mag, absmag, ci, dist, name)
|
||||
count += 1
|
||||
#for entry in CUSTOM_ENTRIES:
|
||||
# render(entry[0], entry[1], entry[2], entry[3], entry[4])
|
||||
|
|
31088
src/data/stars.in
31088
src/data/stars.in
File diff suppressed because it is too large
Load diff
46
src/world.rs
46
src/world.rs
|
@ -113,70 +113,54 @@ pub fn setup(
|
|||
commands.insert_resource(AsteroidModel2(asset_server.load(ASSET_ASTEROID2)));
|
||||
|
||||
// Generate starmap
|
||||
let sphere_handle = meshes.add(Circle::new(1.0));
|
||||
let sphere_handle = meshes.add(Sphere::new(1.0).mesh().uv(16, 16));
|
||||
let mut starcount = 0;
|
||||
for star in nature::STARS {
|
||||
let mag = star.3;
|
||||
let (x, y, z, mag, absmag, color_index, name) = *star;
|
||||
if mag > STARS_MAX_MAGNITUDE {
|
||||
continue;
|
||||
}
|
||||
let is_sun = mag < -20.0;
|
||||
let mag = mag.min(6.0);
|
||||
let scale_color = {|color: f32|
|
||||
if is_sun {
|
||||
color * 13.0f32
|
||||
} else {
|
||||
color * (0.0659663 * mag * mag - 1.09862 * mag + 4.3)
|
||||
}
|
||||
};
|
||||
let scale_size = {|mag: f32|
|
||||
if is_sun {
|
||||
40000.0f32
|
||||
} else {
|
||||
1000.0 * (0.230299 * mag * mag - 3.09013 * mag + 15.1782)
|
||||
} * 1e11
|
||||
};
|
||||
let (r, g, b) = nature::star_color_index_to_rgb(star.4);
|
||||
let (r, g, b) = nature::star_color_index_to_rgb(color_index);
|
||||
let star_color_handle = materials.add(StandardMaterial {
|
||||
base_color: Color::rgb(scale_color(r), scale_color(g), scale_color(b)),
|
||||
unlit: true,
|
||||
..default()
|
||||
});
|
||||
let mesh_distance = 1e18;
|
||||
let starchart_distance = if is_sun {
|
||||
Some(nature::DIST_JUPTER_SUN)
|
||||
} else if star.5 >= 100000.0 {
|
||||
None
|
||||
} else {
|
||||
Some(nature::PARSEC2METER * star.5 as f64)
|
||||
};
|
||||
let name = if star.6.is_empty() {
|
||||
"Uncharted Star".to_string()
|
||||
} else {
|
||||
star.6.to_string()
|
||||
};
|
||||
let translation = Vec3::new(
|
||||
mesh_distance * star.0,
|
||||
mesh_distance * star.1,
|
||||
mesh_distance * star.2,
|
||||
nature::PARSEC2METER as f32 * x,
|
||||
nature::PARSEC2METER as f32 * z,
|
||||
nature::PARSEC2METER as f32 * -y,
|
||||
);
|
||||
let rotation = Quat::from_rotation_arc(Vec3::Z, (-translation).normalize());
|
||||
//let rotation = Quat::from_rotation_arc(Vec3::Z, (-translation).normalize());
|
||||
|
||||
let scale = translation.length().powf(0.85);
|
||||
|
||||
commands.spawn((
|
||||
Star,
|
||||
hud::IsClickable {
|
||||
name: Some(name),
|
||||
distance: starchart_distance,
|
||||
distance: None,
|
||||
},
|
||||
PbrBundle {
|
||||
mesh: sphere_handle.clone(),
|
||||
material: star_color_handle,
|
||||
transform: Transform {
|
||||
translation,
|
||||
rotation,
|
||||
scale: Vec3::splat(scale_size(mag)),
|
||||
scale: Vec3::splat(scale),
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
}
|
||||
},
|
||||
Position::new(translation.as_dvec3()),
|
||||
));
|
||||
starcount += 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue