update with WiP

This commit is contained in:
Hartmut Seichter 2022-12-13 23:18:18 +01:00
parent 13349c9920
commit c73726ddc0
3 changed files with 10 additions and 9 deletions

View file

@ -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::<OffAxisProjection>::default())
.add_system(simulate_viewer)

View file

@ -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,

View file

@ -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<Time>) {
for mut v in query.iter_mut() {