update to utilize a proper off-axis projection including a demo scene to prototype all systems

This commit is contained in:
Hartmut Seichter 2022-12-11 21:12:08 +01:00
parent 040bc8d88a
commit 9c778afa2b
7 changed files with 130 additions and 81 deletions

View file

@ -12,31 +12,21 @@ use crate::projection::*;
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default)]
pub struct OffAxisProjection {
near: f32,
pub far: f32,
aspect: f32,
pub projection_matrix: Mat4
}
impl CameraProjection for OffAxisProjection {
fn get_projection_matrix(&self) -> Mat4 {
make_projection_rh_custom(45.0_f32.to_radians(), self.aspect, self.near, self.far)
// Mat4::perspective_rh(45.0_f32.to_radians(),
// self.aspect,
// self.near,
// self.far)
self.projection_matrix
}
// what to do on window resize
fn update(&mut self, width: f32, height: f32) {
self.aspect = width / height;
// self.aspect = width / height;
}
fn far(&self) -> f32 {
println!("Z-Value");
self.far
}
}
@ -44,9 +34,8 @@ impl CameraProjection for OffAxisProjection {
impl Default for OffAxisProjection {
fn default() -> Self {
Self {
near: 0.1,
far: 1000.0,
aspect: 1.5,
projection_matrix: make_projection_rh_custom(45.0f32.to_radians(),1.3f32, 1.0, 1000.0)
}
}
}