Bloom and static reticle
This commit is contained in:
parent
afe34105e4
commit
340b516cab
Binary file not shown.
@ -1,4 +1,4 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::{prelude::*, core_pipeline::{tonemapping::Tonemapping, bloom::{BloomSettings, BloomCompositeMode}}};
|
||||||
use bevy_rapier3d::prelude::*;
|
use bevy_rapier3d::prelude::*;
|
||||||
|
|
||||||
use crate::{comps::core::markers::{proxy::physics::rapier::LinkToPlayer, camera::MainCamera}, logic::core::player::player_values_state::PlayerValuesState};
|
use crate::{comps::core::markers::{proxy::physics::rapier::LinkToPlayer, camera::MainCamera}, logic::core::player::player_values_state::PlayerValuesState};
|
||||||
@ -24,6 +24,14 @@ pub fn insert_components_into_spawned_player(
|
|||||||
.spawn(MainCamera)
|
.spawn(MainCamera)
|
||||||
.insert(Camera3dBundle {
|
.insert(Camera3dBundle {
|
||||||
transform: Transform::from_xyz(0.0, 0.0, 0.0),
|
transform: Transform::from_xyz(0.0, 0.0, 0.0),
|
||||||
|
camera: Camera {
|
||||||
|
hdr: true,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
tonemapping: Tonemapping::TonyMcMapface,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.insert(BloomSettings {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
//s.insert(Skybox(skybox_handle.clone()))
|
//s.insert(Skybox(skybox_handle.clone()))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use bevy::{reflect::{Reflect, std_traits::ReflectDefault}, ecs::{component::Component, reflect::ReflectComponent}, math::Vec3, pbr::StandardMaterial, render::color::Color};
|
use bevy::{reflect::{Reflect, std_traits::ReflectDefault}, ecs::{component::Component, reflect::ReflectComponent}, math::Vec3, pbr::StandardMaterial, render::color::Color};
|
||||||
use bevy_inspector_egui::egui::Rgba;
|
use bevy_inspector_egui::egui::Rgba;
|
||||||
|
|
||||||
use crate::comps::core::weapons::optic_data::OpticData;
|
use crate::comps::core::weapons::{optic_data::OpticData, reticle::SightReticle};
|
||||||
|
|
||||||
use super::attachment::Attachment;
|
use super::attachment::Attachment;
|
||||||
|
|
||||||
@ -24,6 +24,12 @@ impl Optic {
|
|||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reticle(&self) -> SightReticle {
|
||||||
|
match self {
|
||||||
|
Optic::AimpointT1 => SightReticle::Dot(0.1, Color::rgb_linear(100.0, 0.0, 0.0)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn optic_data(&self) -> OpticData {
|
pub fn optic_data(&self) -> OpticData {
|
||||||
OpticData { optic_pos_y: None, reticle_brightness: self.default_reticle_brightness() }
|
OpticData { optic_pos_y: None, reticle_brightness: self.default_reticle_brightness() }
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,5 @@ pub mod slot;
|
|||||||
pub mod parts;
|
pub mod parts;
|
||||||
pub mod firearm_state;
|
pub mod firearm_state;
|
||||||
pub mod attachment_slot;
|
pub mod attachment_slot;
|
||||||
pub mod optic_data;
|
pub mod optic_data;
|
||||||
|
pub mod reticle;
|
37
src/comps/core/weapons/reticle.rs
Normal file
37
src/comps/core/weapons/reticle.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
|
||||||
|
|
||||||
|
#[derive(Reflect, PartialEq, Clone, Debug)]
|
||||||
|
pub enum SightReticle {
|
||||||
|
/// Reticle Radius & Reticle Color
|
||||||
|
Dot(f32, Color),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for SightReticle {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Dot(0.05, Color::rgb_linear(100.0, 0.0, 0.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SightReticle {
|
||||||
|
pub fn spawn(self, commands: &mut Commands, parent: Entity, meshes: &mut ResMut<Assets<Mesh>>, materials: &mut ResMut<Assets<StandardMaterial>>) {
|
||||||
|
match self {
|
||||||
|
SightReticle::Dot(radius, color) => {
|
||||||
|
commands.spawn(
|
||||||
|
MaterialMeshBundle {
|
||||||
|
mesh: meshes.add(shape::Circle::new(radius).into()).into(),
|
||||||
|
material: materials.add(StandardMaterial {
|
||||||
|
emissive: color,
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
transform: {
|
||||||
|
let mut t = Transform::from_translation(Vec3::ZERO);
|
||||||
|
t.rotate_x(90.0f32.to_radians());
|
||||||
|
t
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
}
|
||||||
|
).set_parent(parent);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,4 +3,5 @@ pub mod player_firing;
|
|||||||
pub mod shoot;
|
pub mod shoot;
|
||||||
pub mod inspect;
|
pub mod inspect;
|
||||||
pub mod equipped_gun_collisions;
|
pub mod equipped_gun_collisions;
|
||||||
pub mod update_bullet;
|
pub mod update_bullet;
|
||||||
|
pub mod reticle;
|
20
src/logic/core/guns/reticle.rs
Normal file
20
src/logic/core/guns/reticle.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
use crate::comps::core::markers::proxy::weapons::optic_sight_glass::OpticSightGlass;
|
||||||
|
|
||||||
|
/// How?
|
||||||
|
/// Achieve parallax on all reticles by drawing a line straight out of the barrel and a straight line from the sight that intersected at the specified zeroed range for the optic.
|
||||||
|
/// Make sure that the reticle is where the bullets will land at the specified zeroed range.
|
||||||
|
pub fn update_reticle(
|
||||||
|
mut commands: Commands,
|
||||||
|
// TODO: make this identify which optic is on the gun, but meanwhile just start doing it to all the optics in
|
||||||
|
sight_query: Query<(Entity, &OpticSightGlass), Added<OpticSightGlass>>,
|
||||||
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
|
) {
|
||||||
|
for (entity, sight) in sight_query.iter() {
|
||||||
|
let reticle = sight.0.reticle();
|
||||||
|
reticle.spawn(&mut commands, entity, &mut meshes, &mut materials);
|
||||||
|
println!("Added reticle");
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
spawners::{player::player_spawner, spawn::SpawnerPlugin}, events::{bullet_collision::BulletCollisionEvent, equipped_gun_collision::EquippedGunCollisionEvent},
|
spawners::{player::player_spawner, spawn::SpawnerPlugin}, events::{bullet_collision::BulletCollisionEvent, equipped_gun_collision::EquippedGunCollisionEvent},
|
||||||
},
|
},
|
||||||
logic::core::{
|
logic::core::{
|
||||||
guns::{despawn_shots::{despawn_muzzle_flashes, despawn_stray_bullets}, inspect::inspect_firearm, equipped_gun_collisions::update_gun_position_on_collision, update_bullet::update_bullet},
|
guns::{despawn_shots::{despawn_muzzle_flashes, despawn_stray_bullets}, inspect::inspect_firearm, equipped_gun_collisions::update_gun_position_on_collision, update_bullet::update_bullet, reticle::update_reticle},
|
||||||
player::{
|
player::{
|
||||||
camera_player_sync::{
|
camera_player_sync::{
|
||||||
follow_cursor_with_camera, update_camera_vertical_position, MouseMovementSettings,
|
follow_cursor_with_camera, update_camera_vertical_position, MouseMovementSettings,
|
||||||
@ -63,6 +63,7 @@ pub fn load_scene(application: &mut App) {
|
|||||||
application.add_systems(Update, collision_handler);
|
application.add_systems(Update, collision_handler);
|
||||||
application.add_systems(Update, update_gun_position_on_collision);
|
application.add_systems(Update, update_gun_position_on_collision);
|
||||||
application.add_systems(Update, update_bullet);
|
application.add_systems(Update, update_bullet);
|
||||||
|
application.add_systems(Update, update_reticle);
|
||||||
|
|
||||||
//application.add_systems(Update, animate_player);
|
//application.add_systems(Update, animate_player);
|
||||||
//application.add_systems(Update, register_bullet_hits);
|
//application.add_systems(Update, register_bullet_hits);
|
||||||
|
@ -6,7 +6,7 @@ use crate::{
|
|||||||
comps::core::{markers::{
|
comps::core::{markers::{
|
||||||
holdable::{HoldableObjectData, InPlayerHands},
|
holdable::{HoldableObjectData, InPlayerHands},
|
||||||
player::{Player, PlayerData, PlayerHand}, inspect_screen::InspectScreenSlotUiMarker, bullet::BulletMarker,
|
player::{Player, PlayerData, PlayerHand}, inspect_screen::InspectScreenSlotUiMarker, bullet::BulletMarker,
|
||||||
}, weapons::{firearm_data::FirearmData, magazine_data::MagazineData, caliber::Caliber, firearm::Firearm, spray_pattern::FirearmSprayPattern, firearm_state::FirearmState}},
|
}, weapons::{firearm_data::FirearmData, magazine_data::MagazineData, caliber::Caliber, firearm::Firearm, spray_pattern::FirearmSprayPattern, firearm_state::FirearmState, reticle::SightReticle}},
|
||||||
logic::core::{
|
logic::core::{
|
||||||
guns::player_firing::PlayerFiringInfo,
|
guns::player_firing::PlayerFiringInfo,
|
||||||
player::{
|
player::{
|
||||||
@ -57,6 +57,7 @@ impl Plugin for MainEditorUiPlugin {
|
|||||||
.register_type::<PlayerSettings>()
|
.register_type::<PlayerSettings>()
|
||||||
.register_type::<InspectScreenSlotUiMarker>()
|
.register_type::<InspectScreenSlotUiMarker>()
|
||||||
.register_type::<PlayerControls>()
|
.register_type::<PlayerControls>()
|
||||||
|
.register_type::<SightReticle>()
|
||||||
//.register_type::<AllAnimations>()
|
//.register_type::<AllAnimations>()
|
||||||
//.register_type::<FirearmAnimations>()
|
//.register_type::<FirearmAnimations>()
|
||||||
.register_type::<GltfAssetType>()
|
.register_type::<GltfAssetType>()
|
||||||
|
Loading…
Reference in New Issue
Block a user