From 8004132c918a52af3b2e7b32b4fc72c65fde9e3c Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:22 +0100 Subject: feat(draw): attach camera position/settings to entity --- examples/render-bsp/src/main.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'examples/render-bsp/src/main.rs') diff --git a/examples/render-bsp/src/main.rs b/examples/render-bsp/src/main.rs index 96d5e42..cea34cd 100644 --- a/examples/render-bsp/src/main.rs +++ b/examples/render-bsp/src/main.rs @@ -17,6 +17,7 @@ //! Renders ./example.bsp +use std::f32::consts::PI; use stockton_input::{Axis, InputManager}; #[macro_use] extern crate stockton_input_codegen; @@ -25,9 +26,11 @@ use winit::{event::Event, event_loop::EventLoop, window::WindowBuilder}; use stockton_levels::{prelude::*, q3::Q3BSPFile}; use stockton_render::{ - do_render_system, window::process_window_events_system, Renderer, WindowEvent, + do_render_system, draw::calc_vp_matrix_system, window::process_window_events_system, Renderer, + WindowEvent, }; -use stockton_types::Session; +use stockton_types::components::{CameraSettings, Transform}; +use stockton_types::{Session, Vector3}; #[derive(InputManager, Default, Clone, Debug)] struct MovementInputs { @@ -88,10 +91,24 @@ fn main() { move |schedule| { schedule .add_system(process_window_events_system::()) + .add_system(calc_vp_matrix_system()) .add_thread_local(do_render_system::>()); }, ); + // Add our player entity + let _player = session.world.push(( + Transform { + position: Vector3::new(0.0, 0.0, 0.0), + rotation: Vector3::new(0.0, PI / 2.0, 0.0), + }, + CameraSettings { + far: 1024.0, + fov: 90.0, + near: 0.1, + }, + )); + // Done loading - This is our main loop. // It just communicates events to the session and continuously ticks event_loop.run(move |event, _, flow| { -- cgit v1.2.3