added tracker markers and change detection

This commit is contained in:
Jay Christy
2023-09-24 01:34:20 -04:00
parent 9e69777a45
commit 8cea603cb5
5 changed files with 172 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
pub mod controllers;
pub mod debug_gizmos;
pub mod oculus_touch;
pub mod trackers;
pub mod xr_camera;
use crate::resources::XrSession;
@@ -10,12 +11,16 @@ use crate::xr_input::oculus_touch::{setup_oculus_controller, ActionSets};
use crate::xr_input::xr_camera::{xr_camera_head_sync, Eye, XRProjection, XrCameraBundle};
use bevy::app::{App, PostUpdate, Startup};
use bevy::log::warn;
use bevy::prelude::{default, Commands, Component, Plugin, PreUpdate, Quat, Res, Vec3};
use bevy::prelude::{
default, Commands, Component, Plugin, PreUpdate, Quat, Res, SpatialBundle, Vec3,
};
use bevy::prelude::{BuildChildren, IntoSystemConfigs};
use bevy::render::camera::CameraProjectionPlugin;
use bevy::render::view::{update_frusta, VisibilitySystems};
use bevy::transform::{TransformBundle, TransformSystem};
use self::trackers::{OpenXRLeftEye, OpenXRRightEye, OpenXRTrackingRoot};
#[derive(Copy, Clone)]
pub struct OpenXrInput {
pub controller_type: XrControllerType,
@@ -26,9 +31,6 @@ pub enum Hand {
Right,
}
#[derive(Component)]
pub struct TrackingRoot;
impl OpenXrInput {
pub fn new(controller_type: XrControllerType) -> Self {
Self { controller_type }
@@ -58,9 +60,15 @@ impl Plugin for OpenXrInput {
fn setup_xr_cameras(mut commands: Commands) {
//this needs to do the whole xr tracking volume not just cameras
//get the root?
let tracking_root = commands.spawn((TransformBundle { ..default() }, TrackingRoot)).id();
let right = commands.spawn(XrCameraBundle::new(Eye::Right)).id();
let left = commands.spawn(XrCameraBundle::new(Eye::Left)).id();
let tracking_root = commands
.spawn((SpatialBundle::default(), OpenXRTrackingRoot))
.id();
let right = commands
.spawn((XrCameraBundle::new(Eye::Right), OpenXRRightEye))
.id();
let left = commands
.spawn((XrCameraBundle::new(Eye::Left), OpenXRLeftEye))
.id();
commands.entity(tracking_root).push_children(&[right, left]);
}