initial implementation for the off-axis view frustum based on previous code
This commit is contained in:
parent
670e1b1756
commit
10a41fcfce
4 changed files with 118 additions and 76 deletions
|
@ -1,10 +1,9 @@
|
|||
use bevy::{prelude::*, window::PresentMode, render::camera::CameraProjectionPlugin};
|
||||
use bevy::{prelude::*, render::camera::CameraProjectionPlugin, window::PresentMode};
|
||||
|
||||
use crate::screeninfo::ScreenInfo;
|
||||
// use offaxis::{offaxis_camera_setup, OffAxisProjection};
|
||||
|
||||
|
||||
#[derive(Component,Default)]
|
||||
#[derive(Component, Default)]
|
||||
pub struct Viewer {
|
||||
pub position: Vec3,
|
||||
pub orientation: Quat,
|
||||
|
@ -13,13 +12,11 @@ pub struct Viewer {
|
|||
}
|
||||
|
||||
impl Viewer {
|
||||
|
||||
pub fn new(position: Vec3) ->Self {
|
||||
pub fn new(position: Vec3) -> Self {
|
||||
Self {
|
||||
position,
|
||||
orientation: Quat::IDENTITY,
|
||||
alpha: 0.0,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,34 +24,32 @@ impl Viewer {
|
|||
Self {
|
||||
position: Vec3::ZERO,
|
||||
orientation: Quat::IDENTITY,
|
||||
alpha: 0.0
|
||||
alpha: 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simulate_viewer(mut query: Query<&mut Viewer>)
|
||||
{
|
||||
for mut v in query.iter_mut() {
|
||||
pub fn simulate_viewer(mut query: Query<&mut Viewer>, screen_info: Query<&ScreenInfo>) {
|
||||
for mut v in query.iter_mut() {
|
||||
//v.position += Vec3::Y * 0.005;
|
||||
v.alpha += 0.01;
|
||||
let radius = 1.5;
|
||||
|
||||
let z_distance = 8.0_f32;
|
||||
|
||||
v.position = Vec3::new(v.alpha.sin()*radius,v.alpha.cos()*radius + 1.0_f32,z_distance);
|
||||
v.position = Vec3::new(
|
||||
v.alpha.sin() * radius,
|
||||
v.alpha.cos() * radius + 1.0_f32,
|
||||
z_distance,
|
||||
);
|
||||
|
||||
let vm = Mat4::look_at_rh(v.position, Vec3::ZERO, Vec3::Y);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{:?}",vm);
|
||||
println!("{:?}", vm);
|
||||
|
||||
// view matrices should be orientation only
|
||||
let dir = Quat::from_mat4(&vm);
|
||||
|
||||
v.orientation = dir;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue