Compare commits
2 commits
fb45ec2233
...
105faee1b6
Author | SHA1 | Date | |
---|---|---|---|
105faee1b6 | |||
ed66390929 |
8 changed files with 1054 additions and 865 deletions
1738
Cargo.lock
generated
1738
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -9,7 +9,8 @@ readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# bevy = "0.9.0"
|
# bevy = "0.9.0"
|
||||||
bevy = { version = "0.9.1", features = ["dynamic"] }
|
# bevy = { version = "0.10.1", features = ["dynamic"] }
|
||||||
|
bevy = { version = "0.10.1" }
|
||||||
rand = "0.8.4"
|
rand = "0.8.4"
|
||||||
# vrpn = "0.1.0" # not compatible with 2021
|
# vrpn = "0.1.0" # not compatible with 2021
|
||||||
vrpn = { git = "https://github.com/seichter/vrpn-rs" }
|
vrpn = { git = "https://github.com/seichter/vrpn-rs" }
|
||||||
|
|
|
@ -3,20 +3,22 @@ use bevy::prelude::*;
|
||||||
|
|
||||||
// this seems to crash
|
// this seems to crash
|
||||||
|
|
||||||
pub fn toggle_fullscreeen(
|
// pub fn toggle_fullscreeen(
|
||||||
input: Res<Input<KeyCode>>,
|
// input: Res<Input<KeyCode>>,
|
||||||
mut windows: ResMut<Windows>,
|
// mut windows: ResMut<Windows>,
|
||||||
) {
|
// ) {
|
||||||
let window = windows
|
// let window = windows
|
||||||
.get_primary_mut()
|
// .get_primary_mut()
|
||||||
.unwrap();
|
// .unwrap();
|
||||||
|
|
||||||
if input.pressed(KeyCode::F) /*&& input.just_pressed(KeyCode::Return) */ {
|
// if input.pressed(KeyCode::F) /*&& input.just_pressed(KeyCode::Return) */ {
|
||||||
if window.mode() == WindowMode::Windowed {
|
// /*
|
||||||
window.set_mode(WindowMode::BorderlessFullscreen);
|
// if window.mode() == WindowMode::Windowed {
|
||||||
} else {
|
// window.set_mode(WindowMode::BorderlessFullscreen);
|
||||||
window.set_mode(WindowMode::Windowed);
|
// } else {
|
||||||
}
|
// window.set_mode(WindowMode::Windowed);
|
||||||
}
|
// }
|
||||||
}
|
// */
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
35
src/main.rs
35
src/main.rs
|
@ -12,8 +12,10 @@ use crate::tracker::*;
|
||||||
use crate::console::*;
|
use crate::console::*;
|
||||||
|
|
||||||
|
|
||||||
|
use bevy::render::primitives::Frustum;
|
||||||
|
use bevy::transform::commands;
|
||||||
use bevy::{prelude::*, window::PresentMode, render::camera::CameraProjectionPlugin};
|
use bevy::{prelude::*, window::PresentMode, render::camera::CameraProjectionPlugin};
|
||||||
use offaxis::{offaxis_camera_setup, OffAxisProjection};
|
use offaxis::{offaxis_camera_setup, setup_offaxis_010, OffAxisProjection};
|
||||||
|
|
||||||
mod offaxis;
|
mod offaxis;
|
||||||
mod scene;
|
mod scene;
|
||||||
|
@ -24,20 +26,22 @@ mod projection;
|
||||||
mod tracker;
|
mod tracker;
|
||||||
mod console;
|
mod console;
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
|
.add_plugins(DefaultPlugins)
|
||||||
.insert_resource(ClearColor(Color::rgb(0.5, 0.5, 0.5)))
|
.insert_resource(ClearColor(Color::rgb(0.5, 0.5, 0.5)))
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
// .add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||||
window: WindowDescriptor {
|
// window: WindowDescriptor {
|
||||||
title: "PixSpace".to_string(),
|
// title: "PixSpace".to_string(),
|
||||||
width: 1280.0,
|
// width: 1280.0,
|
||||||
height: 720.0,
|
// height: 720.0,
|
||||||
present_mode: PresentMode::AutoVsync,
|
// present_mode: PresentMode::AutoVsync,
|
||||||
// mode: WindowMode::BorderlessFullscreen,
|
// // mode: WindowMode::BorderlessFullscreen,
|
||||||
..default()
|
// ..default()
|
||||||
},
|
// },
|
||||||
..default()
|
// ..default()
|
||||||
}))
|
// }))
|
||||||
// use hot reloading
|
// use hot reloading
|
||||||
// .add_plugins(DefaultPlugins.set(AssetPlugin {
|
// .add_plugins(DefaultPlugins.set(AssetPlugin {
|
||||||
// watch_for_changes: true,
|
// watch_for_changes: true,
|
||||||
|
@ -45,11 +49,12 @@ fn main() {
|
||||||
// }))
|
// }))
|
||||||
// .add_plugin(scene::BuildScenePlugin)
|
// .add_plugin(scene::BuildScenePlugin)
|
||||||
.add_system(bevy::window::close_on_esc)
|
.add_system(bevy::window::close_on_esc)
|
||||||
.add_system(cycle_msaa)
|
// .add_system(cycle_msaa)
|
||||||
.add_startup_system(build_scene)
|
.add_startup_system(build_scene)
|
||||||
// .add_system(modify_projection)
|
// .add_system(modify_projection)
|
||||||
|
|
||||||
.add_startup_system(offaxis_camera_setup)
|
// .add_startup_system(offaxis_camera_setup)
|
||||||
|
.add_startup_system(setup_offaxis_010)
|
||||||
// .add_startup_system(setup_tracker)
|
// .add_startup_system(setup_tracker)
|
||||||
// .add_system(update_tracker)
|
// .add_system(update_tracker)
|
||||||
// .add_startup_system(setup_threaded_tracker)
|
// .add_startup_system(setup_threaded_tracker)
|
||||||
|
@ -60,7 +65,7 @@ fn main() {
|
||||||
// .add_system(simulate_viewer_with_circle)
|
// .add_system(simulate_viewer_with_circle)
|
||||||
.add_system(simulate_viewer_with_keyboard)
|
.add_system(simulate_viewer_with_keyboard)
|
||||||
.add_system(apply_viewer_to_projections)
|
.add_system(apply_viewer_to_projections)
|
||||||
.add_system(toggle_fullscreeen)
|
// .add_system(cargo butoggle_fullscreeen)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use bevy::render::camera::{Camera, CameraProjection};
|
use bevy::render::camera::{Camera, CameraProjection};
|
||||||
use bevy::render::view::visibility::*;
|
use bevy::render::view::{visibility::*, self};
|
||||||
use bevy::render::primitives::Frustum;
|
use bevy::render::primitives::Frustum;
|
||||||
use bevy::render::view::VisibleEntities;
|
use bevy::render::view::VisibleEntities;
|
||||||
use bevy::math::Mat4;
|
use bevy::math::Mat4;
|
||||||
|
@ -54,6 +54,25 @@ impl Default for OffAxisProjection {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn setup_offaxis_010(
|
||||||
|
mut commands: Commands
|
||||||
|
) {
|
||||||
|
|
||||||
|
let projection = OffAxisProjection::default();
|
||||||
|
|
||||||
|
// let transform = Transform::from_xyz(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
let view_projection = projection.get_projection_matrix();
|
||||||
|
|
||||||
|
commands.spawn(Camera3dBundle{
|
||||||
|
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
|
frustum: Frustum::from_view_projection(&view_projection),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub fn offaxis_camera_setup(mut commands: Commands) {
|
pub fn offaxis_camera_setup(mut commands: Commands) {
|
||||||
|
|
||||||
let projection = OffAxisProjection::default();
|
let projection = OffAxisProjection::default();
|
||||||
|
@ -66,12 +85,14 @@ pub fn offaxis_camera_setup(mut commands: Commands) {
|
||||||
// frustum construction code copied from Bevy
|
// frustum construction code copied from Bevy
|
||||||
let view_projection = projection.get_projection_matrix() * transform.compute_matrix().inverse();
|
let view_projection = projection.get_projection_matrix() * transform.compute_matrix().inverse();
|
||||||
|
|
||||||
let frustum = Frustum::from_view_projection(
|
// let frustum = Frustum::from_view_projection(
|
||||||
&view_projection,
|
// &view_projection,
|
||||||
&transform.translation,
|
// &transform.translation,
|
||||||
&transform.back(),
|
// &transform.back(),
|
||||||
projection.far,
|
// projection.far,
|
||||||
);
|
// );
|
||||||
|
|
||||||
|
let frustum = Frustum::from_view_projection(&view_projection);
|
||||||
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
bevy::render::camera::CameraRenderGraph::new(bevy::core_pipeline::core_3d::graph::NAME),
|
bevy::render::camera::CameraRenderGraph::new(bevy::core_pipeline::core_3d::graph::NAME),
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub fn build_scene(
|
||||||
) {
|
) {
|
||||||
// plane
|
// plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Mesh::from(shape::Plane { size: 2.5 })),
|
mesh: meshes.add(shape::Plane::from_size(5.0).into()),
|
||||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
|
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
|
||||||
transform: Transform::from_xyz(0.0, -0.5, 0.0),
|
transform: Transform::from_xyz(0.0, -0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -98,7 +98,10 @@ impl FromWorld for Tracker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Self {
|
||||||
|
// rx = receiver.clone()
|
||||||
|
}
|
||||||
|
|
||||||
Self { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
69
src/utils.rs
69
src/utils.rs
|
@ -7,43 +7,46 @@ use crate::viewer::Viewer;
|
||||||
|
|
||||||
use bevy::{prelude::*, window::PresentMode, render::camera::CameraProjectionPlugin};
|
use bevy::{prelude::*, window::PresentMode, render::camera::CameraProjectionPlugin};
|
||||||
|
|
||||||
pub fn cycle_msaa(input: Res<Input<KeyCode>>, mut msaa: ResMut<Msaa>) {
|
// pub fn cycle_msaa(input: Res<Input<KeyCode>>, mut msaa: ResMut<Msaa>) {
|
||||||
if input.just_pressed(KeyCode::M) {
|
// if input.just_pressed(KeyCode::M) {
|
||||||
if msaa.samples == 4 {
|
|
||||||
info!("Not using MSAA");
|
|
||||||
msaa.samples = 1;
|
|
||||||
} else {
|
|
||||||
info!("Using 4x MSAA");
|
|
||||||
msaa.samples = 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// pub fn update_offaxis(mut query : Query<(
|
// // msaa
|
||||||
// &mut OffAxisProjection,
|
|
||||||
// &mut Transform,
|
|
||||||
// &ScreenInfo,
|
|
||||||
// &Viewer
|
|
||||||
// )>
|
|
||||||
// ) {
|
|
||||||
// for (mut projection,mut transform,screen_info,viewer) in query.iter_mut() {
|
|
||||||
|
|
||||||
// // we fake access to far for updating the matrix
|
// // if msaa.samples == 4 {
|
||||||
// (*projection).far *= 1.0;
|
// // info!("Not using MSAA");
|
||||||
|
// // msaa.samples = 1;
|
||||||
// info!("Projection {:?}",*projection);
|
// // } else {
|
||||||
|
// // info!("Using 4x MSAA");
|
||||||
// info!("Screen Info {:?}",screen_info.name);
|
// // msaa.samples = 4;
|
||||||
|
// // }
|
||||||
// info!("Viewer {:?}",viewer.position);
|
// // }
|
||||||
|
|
||||||
// *transform = Transform::from_translation(viewer.position).with_rotation(transform.rotation);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// // pub fn update_offaxis(mut query : Query<(
|
||||||
|
// // &mut OffAxisProjection,
|
||||||
|
// // &mut Transform,
|
||||||
|
// // &ScreenInfo,
|
||||||
|
// // &Viewer
|
||||||
|
// // )>
|
||||||
|
// // ) {
|
||||||
|
// // for (mut projection,mut transform,screen_info,viewer) in query.iter_mut() {
|
||||||
|
|
||||||
|
// // // we fake access to far for updating the matrix
|
||||||
|
// // (*projection).far *= 1.0;
|
||||||
|
|
||||||
|
// // info!("Projection {:?}",*projection);
|
||||||
|
|
||||||
|
// // info!("Screen Info {:?}",screen_info.name);
|
||||||
|
|
||||||
|
// // info!("Viewer {:?}",viewer.position);
|
||||||
|
|
||||||
|
// // *transform = Transform::from_translation(viewer.position).with_rotation(transform.rotation);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
|
||||||
fn intersection_point(
|
fn intersection_point(
|
||||||
center_point: Vec3,
|
center_point: Vec3,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue