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("// 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("// 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("// 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("[")
|
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
|
# Takes ra/deg in degrees
|
||||||
ra = float(ra)
|
ra = float(ra)
|
||||||
dec = float(dec)
|
dec = float(dec)
|
||||||
mag = float(mag)
|
mag = float(mag)
|
||||||
|
x, y, z = float(x), float(y), float(z)
|
||||||
name = re.sub(r'\s+', ' ', name)
|
name = re.sub(r'\s+', ' ', name)
|
||||||
if name == 'Sol':
|
if name == 'Sol':
|
||||||
return
|
return
|
||||||
|
|
||||||
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]
|
||||||
dec_radians = math.radians(dec)
|
# dec_radians = math.radians(dec)
|
||||||
#print(f"ra_radians={ra_radians}, dec_radians={dec_radians}, dec={dec}, ra={ra}", file=sys.stderr)
|
# #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)
|
# x = distance * math.cos(dec_radians) * math.cos(-ra_radians)
|
||||||
y = distance * math.cos(dec_radians) * math.sin(-ra_radians)
|
# y = distance * math.cos(dec_radians) * math.sin(-ra_radians)
|
||||||
z = distance * math.sin(dec_radians)
|
# z = distance * math.sin(dec_radians)
|
||||||
|
#
|
||||||
# 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
|
||||||
|
|
||||||
#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},{absmag:.04},{ci},"{name}"),')
|
||||||
|
|
||||||
|
|
||||||
def clean_name(string):
|
def clean_name(string):
|
||||||
|
@ -81,7 +82,11 @@ for entry in entries:
|
||||||
total += 1
|
total += 1
|
||||||
ra = entry['ra']
|
ra = entry['ra']
|
||||||
dec = entry['dec']
|
dec = entry['dec']
|
||||||
|
x = entry['x']
|
||||||
|
y = entry['y']
|
||||||
|
z = entry['z']
|
||||||
mag = entry['mag']
|
mag = entry['mag']
|
||||||
|
absmag = entry['absmag']
|
||||||
ci = entry['ci']
|
ci = entry['ci']
|
||||||
dist = entry['dist']
|
dist = entry['dist']
|
||||||
name = clean_name(entry['proper'])
|
name = clean_name(entry['proper'])
|
||||||
|
@ -94,7 +99,7 @@ for entry in entries:
|
||||||
continue
|
continue
|
||||||
if float(mag) > MAX_APPARENT_MAGNITUDE:
|
if float(mag) > MAX_APPARENT_MAGNITUDE:
|
||||||
continue
|
continue
|
||||||
render(ra, dec, mag, ci, dist, name)
|
render(x, y, z, ra, dec, mag, absmag, 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])
|
||||||
|
|
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)));
|
commands.insert_resource(AsteroidModel2(asset_server.load(ASSET_ASTEROID2)));
|
||||||
|
|
||||||
// Generate starmap
|
// 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;
|
let mut starcount = 0;
|
||||||
for star in nature::STARS {
|
for star in nature::STARS {
|
||||||
let mag = star.3;
|
let (x, y, z, mag, absmag, color_index, name) = *star;
|
||||||
if mag > STARS_MAX_MAGNITUDE {
|
if mag > STARS_MAX_MAGNITUDE {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let is_sun = mag < -20.0;
|
|
||||||
let mag = mag.min(6.0);
|
let mag = mag.min(6.0);
|
||||||
let scale_color = {|color: f32|
|
let scale_color = {|color: f32|
|
||||||
if is_sun {
|
|
||||||
color * 13.0f32
|
|
||||||
} else {
|
|
||||||
color * (0.0659663 * mag * mag - 1.09862 * mag + 4.3)
|
color * (0.0659663 * mag * mag - 1.09862 * mag + 4.3)
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let scale_size = {|mag: f32|
|
let (r, g, b) = nature::star_color_index_to_rgb(color_index);
|
||||||
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 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 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() {
|
let name = if star.6.is_empty() {
|
||||||
"Uncharted Star".to_string()
|
"Uncharted Star".to_string()
|
||||||
} else {
|
} else {
|
||||||
star.6.to_string()
|
star.6.to_string()
|
||||||
};
|
};
|
||||||
let translation = Vec3::new(
|
let translation = Vec3::new(
|
||||||
mesh_distance * star.0,
|
nature::PARSEC2METER as f32 * x,
|
||||||
mesh_distance * star.1,
|
nature::PARSEC2METER as f32 * z,
|
||||||
mesh_distance * star.2,
|
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((
|
commands.spawn((
|
||||||
Star,
|
Star,
|
||||||
hud::IsClickable {
|
hud::IsClickable {
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
distance: starchart_distance,
|
distance: None,
|
||||||
},
|
},
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: sphere_handle.clone(),
|
mesh: sphere_handle.clone(),
|
||||||
material: star_color_handle,
|
material: star_color_handle,
|
||||||
transform: Transform {
|
transform: Transform {
|
||||||
translation,
|
translation,
|
||||||
rotation,
|
scale: Vec3::splat(scale),
|
||||||
scale: Vec3::splat(scale_size(mag)),
|
..default()
|
||||||
},
|
},
|
||||||
..default()
|
..default()
|
||||||
}
|
},
|
||||||
|
Position::new(translation.as_dvec3()),
|
||||||
));
|
));
|
||||||
starcount += 1;
|
starcount += 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue