debug visuals and add mig jet
This commit is contained in:
BIN
assets/models/mig.glb
Normal file
BIN
assets/models/mig.glb
Normal file
Binary file not shown.
51
src/main.rs
51
src/main.rs
@@ -17,9 +17,22 @@ pub struct MyBaseClass {
|
||||
pub my_value: u32,
|
||||
}
|
||||
|
||||
#[derive(Resource, Reflect, Debug)]
|
||||
#[reflect(Resource)]
|
||||
struct DebugVisuals {
|
||||
pub unlit: bool,
|
||||
pub tonemapping: Tonemapping,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut app = App::new();
|
||||
|
||||
app.register_type::<DebugVisuals>();
|
||||
app.insert_resource(DebugVisuals {
|
||||
unlit: true,
|
||||
tonemapping: Tonemapping::None,
|
||||
});
|
||||
|
||||
app.add_plugins(DefaultPlugins.set(ImagePlugin {
|
||||
default_sampler: repeating_image_sampler(false),
|
||||
}));
|
||||
@@ -30,38 +43,62 @@ fn main() {
|
||||
app.insert_resource(MovementSettings {
|
||||
sensitivity: 0.00005,
|
||||
speed: 12.,
|
||||
})
|
||||
.add_plugins(bevy_inspector_egui::quick::WorldInspectorPlugin::default());
|
||||
});
|
||||
app.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 500.,
|
||||
});
|
||||
app.add_plugins(bevy_inspector_egui::quick::WorldInspectorPlugin::default());
|
||||
|
||||
app.add_plugins(TrenchBroomPlugin(TrenchBroomConfig::new("hedz")));
|
||||
|
||||
app.add_systems(Startup, write_trenchbroom_config);
|
||||
app.add_systems(PostStartup, setup_scene);
|
||||
app.add_systems(Update, (set_materials_unlit, disable_tone_mapping));
|
||||
app.add_systems(Update, (set_materials_unlit, set_tonemapping));
|
||||
|
||||
app.run();
|
||||
}
|
||||
|
||||
fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
commands.spawn(SceneRoot(asset_server.load("maps/map1.map#Scene")));
|
||||
|
||||
commands.spawn((
|
||||
DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
Transform {
|
||||
translation: Vec3::new(0.0, 2.0, 0.0),
|
||||
rotation: Quat::from_rotation_x(-1.7),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
|
||||
commands.spawn((SceneRoot(
|
||||
asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/mig.glb")),
|
||||
),));
|
||||
}
|
||||
|
||||
fn write_trenchbroom_config(server: Res<TrenchBroomServer>) {
|
||||
server.config.write_folder("trenchbroom/hedz").unwrap()
|
||||
}
|
||||
|
||||
fn disable_tone_mapping(mut cams: Query<&mut Tonemapping, With<Camera>>) {
|
||||
fn set_tonemapping(mut cams: Query<&mut Tonemapping, With<Camera>>, visuals: Res<DebugVisuals>) {
|
||||
for mut tm in cams.iter_mut() {
|
||||
*tm = Tonemapping::None;
|
||||
*tm = visuals.tonemapping;
|
||||
}
|
||||
}
|
||||
|
||||
fn set_materials_unlit(mut materials: ResMut<Assets<StandardMaterial>>) {
|
||||
fn set_materials_unlit(
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
visuals: Res<DebugVisuals>,
|
||||
) {
|
||||
if !materials.is_changed() {
|
||||
return;
|
||||
}
|
||||
|
||||
for (_, material) in materials.iter_mut() {
|
||||
material.unlit = true;
|
||||
material.unlit = visuals.unlit;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user