From c73726ddc0de9747480775c21392c395b331ea19 Mon Sep 17 00:00:00 2001 From: Hartmut Seichter Date: Tue, 13 Dec 2022 23:18:18 +0100 Subject: [PATCH] update with WiP --- src/main.rs | 4 ++-- src/projection.rs | 14 +++++++------- src/viewer.rs | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index dcb0af0..a26ae1e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,8 +47,8 @@ fn main() { // .add_system(modify_projection) .add_startup_system(offaxis_camera_setup) - .add_startup_system(setup_tracker) - .add_system(update_tracker) + // .add_startup_system(setup_tracker) + // .add_system(update_tracker) .add_plugin(CameraProjectionPlugin::::default()) .add_system(simulate_viewer) diff --git a/src/projection.rs b/src/projection.rs index 2b8ccd3..7cdd334 100644 --- a/src/projection.rs +++ b/src/projection.rs @@ -28,15 +28,15 @@ pub fn make_projection_rh_from_frustum_reversed(left: f32, right: f32, bottom: f // reversed z 0..1 projection based on https://thxforthefish.com/posts/reverse_z/ // let a = (right + left) / (right - left); - let b: f32 = (top + bottom) / (top - bottom); + let b = (top + bottom) / (top - bottom); let c = z_near / (z_far - z_near); let d = z_far * z_near / (z_far - z_near); Mat4::from_cols( - Vec4::new(2.0 * z_near / (right-left),0.0,0.0,0.0), - Vec4::new(0.0, 2.0 * z_near / (top-bottom), 0.0,0.0), + Vec4::new(2.0 * z_near / (right-left), 0.0,0.0,0.0), + Vec4::new(0.0, 2.0 * z_near / (top-bottom), 0.0,0.0), Vec4::new(a, b, c, -1.0), Vec4::new(0.0, 0.0, d, 0.0)) } @@ -101,7 +101,7 @@ pub fn create_offaxis_matrices( let bottom = vec_up_normalized.dot(frustum_left) * z_near / dist; // bottom screen edge let top = vec_up_normalized.dot(frustum_up) * z_near / dist; // distance eye from screen - info!("l r b t {} {} {} {}",left,right,bottom,top); + // info!("l r b t {} {} {} {}",left,right,bottom,top); // create a view frustum let projection_matrix = make_projection_rh_from_frustum_reversed(left,right,bottom,top,z_near,z_far); @@ -113,10 +113,10 @@ pub fn create_offaxis_matrices( Vec4::W ); - let rotation_quat = Quat::from_mat4(&view_matrix_rotation); /// Quat::from_mat4(view_matrix_rotation); + let rotation_quat = Quat::from_mat4(&view_matrix_rotation); // Quat::from_mat4(view_matrix_rotation); - info!("Rotation Mat {:?}",view_matrix_rotation); - info!("Viewer Rotation {:?}",rotation_quat); + // info!("Rotation Mat {:?}",view_matrix_rotation); + // info!("Viewer Rotation {:?}",rotation_quat); let view_matrix_eye = Mat4::from_cols( Vec4::X, diff --git a/src/viewer.rs b/src/viewer.rs index 2f78a8b..352fd21 100644 --- a/src/viewer.rs +++ b/src/viewer.rs @@ -56,6 +56,7 @@ pub fn apply_viewer_to_projections(mut query: Query<(&Viewer,&ScreenInfo,&mut Of } + pub fn simulate_viewer(mut query: Query<&mut Viewer>,time: Res