atmosphere: add clouds right/left of the player inside jupiter (WIP)
This commit is contained in:
parent
c7fb4eef3f
commit
193f95992c
|
@ -56,6 +56,12 @@ pub struct IsEffect;
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct InnerAtmosphereBox;
|
pub struct InnerAtmosphereBox;
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
|
pub enum AtmosphereCloud {
|
||||||
|
Above,
|
||||||
|
Below,
|
||||||
|
Fog,
|
||||||
|
}
|
||||||
|
#[derive(Component)]
|
||||||
pub struct FadeInSprite;
|
pub struct FadeInSprite;
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct FadeOutSprite;
|
pub struct FadeOutSprite;
|
||||||
|
@ -117,6 +123,7 @@ pub fn setup(
|
||||||
let graph = graphs.add(graph);
|
let graph = graphs.add(graph);
|
||||||
commands.insert_resource(SuitAnimation { index, graph });
|
commands.insert_resource(SuitAnimation { index, graph });
|
||||||
|
|
||||||
|
// Add atmosphere box
|
||||||
let box_material_handle = materials.add(StandardMaterial {
|
let box_material_handle = materials.add(StandardMaterial {
|
||||||
base_color: Color::srgba(0.0, 0.0, 0.0, 1.0),
|
base_color: Color::srgba(0.0, 0.0, 0.0, 1.0),
|
||||||
alpha_mode: AlphaMode::Blend,
|
alpha_mode: AlphaMode::Blend,
|
||||||
|
@ -137,6 +144,36 @@ pub fn setup(
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Add atmosphere cloud
|
||||||
|
let texture = asset_server.load("models/textures/cloud.png");
|
||||||
|
let cloud_material_handle = materials.add(StandardMaterial {
|
||||||
|
base_color: Color::srgba(1.0, 1.0, 1.0, 1.0),
|
||||||
|
base_color_texture: Some(texture),
|
||||||
|
perceptual_roughness: 1.0,
|
||||||
|
alpha_mode: AlphaMode::Blend,
|
||||||
|
cull_mode: None,
|
||||||
|
unlit: true,
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
let mesh = Rectangle::new(100000.0, 25000.0);
|
||||||
|
let mesh_handle = meshes.add(mesh);
|
||||||
|
commands.spawn((
|
||||||
|
AtmosphereCloud::Above,
|
||||||
|
PbrBundle {
|
||||||
|
mesh: mesh_handle.clone(),
|
||||||
|
material: cloud_material_handle.clone(),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
));
|
||||||
|
commands.spawn((
|
||||||
|
AtmosphereCloud::Below,
|
||||||
|
PbrBundle {
|
||||||
|
mesh: mesh_handle,
|
||||||
|
material: cloud_material_handle,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
// Blackout disabled for now
|
// Blackout disabled for now
|
||||||
// commands.spawn((
|
// commands.spawn((
|
||||||
// BlackOutOverlay,
|
// BlackOutOverlay,
|
||||||
|
@ -360,11 +397,22 @@ fn play_animations(
|
||||||
|
|
||||||
fn update_atmosphere(
|
fn update_atmosphere(
|
||||||
settings: Res<Settings>,
|
settings: Res<Settings>,
|
||||||
mut q_atmo: Query<
|
mut q_atmobox: Query<
|
||||||
(&mut Transform, &Handle<StandardMaterial>, &mut Visibility),
|
(&mut Transform, &Handle<StandardMaterial>, &mut Visibility),
|
||||||
With<InnerAtmosphereBox>,
|
With<InnerAtmosphereBox>,
|
||||||
>,
|
>,
|
||||||
q_player: Query<&Transform, (With<actor::PlayerCamera>, Without<InnerAtmosphereBox>)>,
|
mut q_atmocloud: Query<
|
||||||
|
(&mut Transform, &mut Visibility, &AtmosphereCloud),
|
||||||
|
Without<InnerAtmosphereBox>,
|
||||||
|
>,
|
||||||
|
q_player: Query<
|
||||||
|
&Transform,
|
||||||
|
(
|
||||||
|
With<actor::PlayerCamera>,
|
||||||
|
Without<InnerAtmosphereBox>,
|
||||||
|
Without<AtmosphereCloud>,
|
||||||
|
),
|
||||||
|
>,
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
let player_trans = if let Ok(trans) = q_player.get_single() {
|
let player_trans = if let Ok(trans) = q_player.get_single() {
|
||||||
|
@ -372,7 +420,8 @@ fn update_atmosphere(
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
for (mut trans, material_handle, mut vis) in &mut q_atmo {
|
|
||||||
|
for (mut trans, material_handle, mut vis) in &mut q_atmobox {
|
||||||
if let Some(x) = settings.atmo_altitude {
|
if let Some(x) = settings.atmo_altitude {
|
||||||
*vis = Visibility::Inherited;
|
*vis = Visibility::Inherited;
|
||||||
trans.translation = player_trans.translation;
|
trans.translation = player_trans.translation;
|
||||||
|
@ -396,4 +445,23 @@ fn update_atmosphere(
|
||||||
*vis = Visibility::Hidden;
|
*vis = Visibility::Hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (mut trans, mut vis, cloud_type) in &mut q_atmocloud {
|
||||||
|
if let Some(_x) = settings.atmo_altitude {
|
||||||
|
*vis = Visibility::Inherited;
|
||||||
|
match cloud_type {
|
||||||
|
AtmosphereCloud::Above => {
|
||||||
|
trans.translation = player_trans.translation + Vec3::new(0.0, 10000.0, 0.0);
|
||||||
|
}
|
||||||
|
AtmosphereCloud::Below => {
|
||||||
|
trans.translation = player_trans.translation + Vec3::new(0.0, -10000.0, 0.0);
|
||||||
|
}
|
||||||
|
AtmosphereCloud::Fog => {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trans.look_at(player_trans.translation, Dir3::X);
|
||||||
|
} else {
|
||||||
|
*vis = Visibility::Hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue