first step done: we have a custom and updatable matrix
This commit is contained in:
parent
8234a61364
commit
4a8c9a298a
7 changed files with 360 additions and 180 deletions
73
src/scene.rs
73
src/scene.rs
|
@ -1,4 +1,7 @@
|
|||
use bevy::{prelude::*, math::bool};
|
||||
use bevy::{prelude::*, math::bool, render::primitives::Frustum};
|
||||
use rand::prelude::*;
|
||||
use bevy::render::primitives::Plane;
|
||||
|
||||
|
||||
pub struct BuildScenePlugin;
|
||||
|
||||
|
@ -33,7 +36,15 @@ pub struct ProjectionScreen {
|
|||
|
||||
}
|
||||
|
||||
fn compute_offaxis_frustum (
|
||||
|
||||
|
||||
fn generalized_projection_stereo(eyePos : Vec3)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
fn generalized_projection (
|
||||
projectionScreen: ProjectionScreen,
|
||||
eyePos: Vec3,
|
||||
mut camera: Camera3dBundle,
|
||||
|
@ -49,7 +60,9 @@ fn compute_offaxis_frustum (
|
|||
let vr = projectionScreen.dir_right;
|
||||
let vn = projectionScreen.dir_normal;
|
||||
|
||||
let m = projectionScreen.matrix;
|
||||
// let m = projectionScreen.matrix;
|
||||
|
||||
//let m = Mat4::from_cols(vu., y_axis, z_axis, w_axis)
|
||||
|
||||
let va = pa - eyePos;
|
||||
let vb = pb - eyePos;
|
||||
|
@ -60,7 +73,9 @@ fn compute_offaxis_frustum (
|
|||
|
||||
let d = -va.dot(vn);
|
||||
|
||||
if (clampNearPlane) {
|
||||
|
||||
if clampNearPlane {
|
||||
_ = 33;
|
||||
// camera.frustum.planes[4]. // should be near
|
||||
}
|
||||
}
|
||||
|
@ -99,12 +114,15 @@ pub fn build_scene(
|
|||
|
||||
let mut cam = Camera3dBundle {
|
||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
|
||||
..default()
|
||||
};
|
||||
|
||||
commands.spawn(cam);
|
||||
|
||||
commands.spawn((Person, Position { x: 10.0, y: 10.0 }));
|
||||
|
||||
// commands.spawn(cam);
|
||||
|
||||
// commands.spawn((Person, Position { x: 10.0, y: 10.0 }));
|
||||
// commands.spawn()
|
||||
// .insert(Person)
|
||||
// .insert(Position { x: 10.0, y: 10.0 } );
|
||||
|
@ -116,9 +134,52 @@ pub fn build_scene(
|
|||
// });
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub fn modify_frustum(mut query: Query<&Frustum>)
|
||||
{
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
for mut q in query.iter() {
|
||||
|
||||
for mut p in q.planes {
|
||||
|
||||
println!("{:?}",p);
|
||||
|
||||
let mut n = p.normal_d();
|
||||
|
||||
n.w += rng.gen::<f32>();
|
||||
|
||||
p = Plane::new(n);
|
||||
|
||||
println!("{:?}",p);
|
||||
|
||||
|
||||
|
||||
// p.normal_d() += rng.gen();
|
||||
}
|
||||
|
||||
// println!("{:?}",q.frustum.planes.len());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn modify_projection(mut query: Query<&Projection>)
|
||||
{
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
for mut q in query.iter() {
|
||||
|
||||
print!("{:?}",q);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_positions(query: Query<&Position>) {
|
||||
for _position in query.iter() {
|
||||
_ = 33;
|
||||
// println!("position {:?} {:?}", position.x, position.y)
|
||||
}
|
||||
}
|
||||
|
||||
// Problem with off-axis
|
||||
// projection 2401, 240
|
Loading…
Add table
Add a link
Reference in a new issue