restore jupiter's ring
This commit is contained in:
parent
513e3d89ef
commit
ed6187d996
|
@ -3,7 +3,7 @@ extern crate regex;
|
|||
use bevy::prelude::*;
|
||||
use bevy_xpbd_3d::prelude::*;
|
||||
use bevy::math::DVec3;
|
||||
use crate::{actor, chat, hud, nature, world};
|
||||
use crate::{actor, chat, hud, nature, shading, world};
|
||||
use regex::Regex;
|
||||
use std::f32::consts::PI;
|
||||
use std::f64::consts::PI as PI64;
|
||||
|
@ -55,6 +55,7 @@ struct ParserState {
|
|||
is_targeted_on_startup: bool,
|
||||
is_sun: bool,
|
||||
has_physics: bool,
|
||||
has_ring: bool,
|
||||
wants_maxrotation: Option<f64>,
|
||||
wants_maxvelocity: Option<f64>,
|
||||
collider_is_mesh: bool,
|
||||
|
@ -101,6 +102,7 @@ impl Default for ParserState {
|
|||
is_targeted_on_startup: false,
|
||||
is_sun: false,
|
||||
has_physics: true,
|
||||
has_ring: false,
|
||||
wants_maxrotation: None,
|
||||
wants_maxvelocity: None,
|
||||
collider_is_mesh: false,
|
||||
|
@ -257,6 +259,9 @@ pub fn load_defs(
|
|||
state.is_sun = true;
|
||||
state.model_scale *= 5.0;
|
||||
}
|
||||
["ring", "yes"] => {
|
||||
state.has_ring = true;
|
||||
}
|
||||
["oxygen", amount] => {
|
||||
if let Ok(amount) = amount.parse::<f32>() {
|
||||
state.is_lifeform = true;
|
||||
|
@ -462,6 +467,7 @@ fn spawn_entities(
|
|||
asset_server: Res<AssetServer>,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
mut materials_jupiter: ResMut<Assets<shading::JupitersRing>>,
|
||||
) {
|
||||
for state_wrapper in er_spawn.read() {
|
||||
let state = &state_wrapper.0;
|
||||
|
@ -644,6 +650,25 @@ fn spawn_entities(
|
|||
},
|
||||
));
|
||||
}
|
||||
|
||||
if state.has_ring {
|
||||
commands.spawn((
|
||||
world::DespawnOnPlayerDeath,
|
||||
MaterialMeshBundle {
|
||||
mesh: meshes.add(Mesh::from(Cylinder::new(nature::JUPITER_RING_RADIUS as f32, 1.0))),
|
||||
material: materials_jupiter.add(shading::JupitersRing {
|
||||
alpha_mode: AlphaMode::Blend,
|
||||
ring_radius: nature::JUPITER_RING_RADIUS as f32,
|
||||
jupiter_radius: nature::JUPITER_RADIUS as f32,
|
||||
}),
|
||||
transform: Transform::from_translation(state.pos.as_vec3()),
|
||||
..default()
|
||||
},
|
||||
Position::new(state.pos),
|
||||
Rotation::from(Quat::IDENTITY),
|
||||
//Rotation::from(Quat::from_rotation_x(-0.3f32.to_radians())),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ actor 0 0 0 jupiter
|
|||
name Jupiter
|
||||
scale 71492e3
|
||||
sphere yes
|
||||
ring yes
|
||||
physics off
|
||||
rotationx -0.50
|
||||
rotationz -0.28
|
||||
|
|
|
@ -11,7 +11,10 @@ pub const LIGHTYEAR2METER: f64 = 9_460_730_472_580_800.0;
|
|||
pub const PARSEC2METER: f64 = 3.0857e16;
|
||||
pub const DIST_JUPTER_SUN: f64 = 778479.0e6;
|
||||
pub const EARTH_GRAVITY: f32 = 9.81;
|
||||
pub const SOL_RADIUS: f64 = 696.3e6;
|
||||
|
||||
pub const SOL_RADIUS: f64 = 696_300_000.0;
|
||||
pub const JUPITER_RADIUS: f64 = 71_492_000.0;
|
||||
pub const JUPITER_RING_RADIUS: f64 = 229_000_000.0;
|
||||
|
||||
// Each star's values: (x, y, z, magnitude, color index, distance, name)
|
||||
pub const STARS: &[(f32, f32, f32, f32, f32, f32, &str)] = &include!("data/stars.in");
|
||||
|
|
19
src/world.rs
19
src/world.rs
|
@ -104,7 +104,6 @@ pub fn setup(
|
|||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
mut materials_jupiter: ResMut<Assets<shading::JupitersRing>>,
|
||||
mut materials_skybox: ResMut<Assets<shading::SkyBox>>,
|
||||
asset_server: Res<AssetServer>,
|
||||
) {
|
||||
|
@ -196,24 +195,6 @@ pub fn setup(
|
|||
..default()
|
||||
});
|
||||
}
|
||||
|
||||
// Add shaded ring
|
||||
let ring_radius = 229_000_000.0;
|
||||
let jupiter_radius = 71_492_000.0;
|
||||
commands.spawn((
|
||||
MaterialMeshBundle {
|
||||
mesh: meshes.add(Mesh::from(Cylinder::new(ring_radius, 1.0))),
|
||||
material: materials_jupiter.add(shading::JupitersRing {
|
||||
alpha_mode: AlphaMode::Blend,
|
||||
ring_radius: ring_radius,
|
||||
jupiter_radius: jupiter_radius,
|
||||
}),
|
||||
..default()
|
||||
},
|
||||
Position::from_xyz(0.0, 0.0, 0.0),
|
||||
Rotation::from(Quat::IDENTITY),
|
||||
//Rotation::from(Quat::from_rotation_x(-0.3f32.to_radians())),
|
||||
));
|
||||
}
|
||||
|
||||
fn spawn_despawn_asteroids(
|
||||
|
|
Loading…
Reference in a new issue