finnish everything
This commit is contained in:
@@ -18,7 +18,7 @@ use bevy_oxr::{
|
|||||||
input::XrInput,
|
input::XrInput,
|
||||||
resources::{XrFrameState, XrInstance, XrSession},
|
resources::{XrFrameState, XrInstance, XrSession},
|
||||||
xr_input::{
|
xr_input::{
|
||||||
actions::ActionSets,
|
actions::XrActionSets,
|
||||||
debug_gizmos::OpenXrDebugRenderer,
|
debug_gizmos::OpenXrDebugRenderer,
|
||||||
hand::{HandBone, HandInputDebugRenderer, HandResource, HandsResource, OpenXrHandInput},
|
hand::{HandBone, HandInputDebugRenderer, HandResource, HandsResource, OpenXrHandInput},
|
||||||
interactions::{
|
interactions::{
|
||||||
@@ -517,7 +517,7 @@ fn request_cube_spawn(
|
|||||||
mut writer: EventWriter<SpawnCubeRequest>,
|
mut writer: EventWriter<SpawnCubeRequest>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
mut timer: ResMut<SpawnCubeTimer>,
|
mut timer: ResMut<SpawnCubeTimer>,
|
||||||
action_sets: Res<ActionSets>,
|
action_sets: Res<XrActionSets>,
|
||||||
) {
|
) {
|
||||||
timer.0.tick(time.delta());
|
timer.0.tick(time.delta());
|
||||||
if timer.0.finished() {
|
if timer.0.finished() {
|
||||||
@@ -587,7 +587,7 @@ fn prototype_interaction_input(
|
|||||||
Without<OpenXRRightController>,
|
Without<OpenXRRightController>,
|
||||||
),
|
),
|
||||||
>,
|
>,
|
||||||
action_sets: Res<ActionSets>,
|
action_sets: Res<XrActionSets>,
|
||||||
) {
|
) {
|
||||||
//lock frame
|
//lock frame
|
||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use bevy::transform::components::Transform;
|
|||||||
use bevy_oxr::input::XrInput;
|
use bevy_oxr::input::XrInput;
|
||||||
use bevy_oxr::resources::{XrFrameState, XrInstance, XrSession};
|
use bevy_oxr::resources::{XrFrameState, XrInstance, XrSession};
|
||||||
|
|
||||||
use bevy_oxr::xr_input::actions::ActionSets;
|
use bevy_oxr::xr_input::actions::XrActionSets;
|
||||||
use bevy_oxr::xr_input::hand::{HandInputDebugRenderer, OpenXrHandInput};
|
use bevy_oxr::xr_input::hand::{HandInputDebugRenderer, OpenXrHandInput};
|
||||||
use bevy_oxr::xr_input::interactions::{
|
use bevy_oxr::xr_input::interactions::{
|
||||||
draw_interaction_gizmos, draw_socket_gizmos, interactions, socket_interactions,
|
draw_interaction_gizmos, draw_socket_gizmos, interactions, socket_interactions,
|
||||||
@@ -159,7 +159,7 @@ fn prototype_interaction_input(
|
|||||||
Without<OpenXRRightController>,
|
Without<OpenXRRightController>,
|
||||||
),
|
),
|
||||||
>,
|
>,
|
||||||
action_sets: Res<ActionSets>,
|
action_sets: Res<XrActionSets>,
|
||||||
) {
|
) {
|
||||||
//lock frame
|
//lock frame
|
||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
|
|||||||
14
src/lib.rs
14
src/lib.rs
@@ -23,6 +23,8 @@ use xr_input::hand::HandInputSource;
|
|||||||
use xr_input::handtracking::HandTrackingTracker;
|
use xr_input::handtracking::HandTrackingTracker;
|
||||||
use xr_input::OpenXrInput;
|
use xr_input::OpenXrInput;
|
||||||
|
|
||||||
|
use crate::xr_input::oculus_touch::ActionSets;
|
||||||
|
|
||||||
const VIEW_TYPE: xr::ViewConfigurationType = xr::ViewConfigurationType::PRIMARY_STEREO;
|
const VIEW_TYPE: xr::ViewConfigurationType = xr::ViewConfigurationType::PRIMARY_STEREO;
|
||||||
|
|
||||||
pub const LEFT_XR_TEXTURE_HANDLE: ManualTextureViewHandle = ManualTextureViewHandle(1208214591);
|
pub const LEFT_XR_TEXTURE_HANDLE: ManualTextureViewHandle = ManualTextureViewHandle(1208214591);
|
||||||
@@ -96,7 +98,7 @@ impl Plugin for OpenXrPlugin {
|
|||||||
views,
|
views,
|
||||||
frame_state,
|
frame_state,
|
||||||
));
|
));
|
||||||
// app.insert_resource(ActionSets(vec![]));
|
app.insert_resource(ActionSets(vec![]));
|
||||||
app.add_plugins(RenderPlugin {
|
app.add_plugins(RenderPlugin {
|
||||||
render_creation: RenderCreation::Manual(
|
render_creation: RenderCreation::Manual(
|
||||||
device,
|
device,
|
||||||
@@ -131,7 +133,7 @@ impl Plugin for OpenXrPlugin {
|
|||||||
frame_state,
|
frame_state,
|
||||||
) = future_renderer_resources.0.lock().unwrap().take().unwrap();
|
) = future_renderer_resources.0.lock().unwrap().take().unwrap();
|
||||||
|
|
||||||
// let action_sets = app.world.resource::<ActionSets>().clone();
|
let action_sets = app.world.resource::<ActionSets>().clone();
|
||||||
|
|
||||||
app.insert_resource(xr_instance.clone())
|
app.insert_resource(xr_instance.clone())
|
||||||
.insert_resource(session.clone())
|
.insert_resource(session.clone())
|
||||||
@@ -143,8 +145,8 @@ impl Plugin for OpenXrPlugin {
|
|||||||
.insert_resource(swapchain.clone())
|
.insert_resource(swapchain.clone())
|
||||||
.insert_resource(input.clone())
|
.insert_resource(input.clone())
|
||||||
.insert_resource(views.clone())
|
.insert_resource(views.clone())
|
||||||
.insert_resource(frame_state.clone());
|
.insert_resource(frame_state.clone())
|
||||||
// .insert_resource(action_sets.clone());
|
.insert_resource(action_sets.clone());
|
||||||
let hands = xr_instance.exts().ext_hand_tracking.is_some();
|
let hands = xr_instance.exts().ext_hand_tracking.is_some();
|
||||||
let hands = false;
|
let hands = false;
|
||||||
if hands {
|
if hands {
|
||||||
@@ -183,8 +185,8 @@ impl Plugin for OpenXrPlugin {
|
|||||||
.insert_resource(swapchain)
|
.insert_resource(swapchain)
|
||||||
.insert_resource(input)
|
.insert_resource(input)
|
||||||
.insert_resource(views)
|
.insert_resource(views)
|
||||||
.insert_resource(frame_state);
|
.insert_resource(frame_state)
|
||||||
// .insert_resource(action_sets);
|
.insert_resource(action_sets);
|
||||||
|
|
||||||
render_app.add_systems(
|
render_app.add_systems(
|
||||||
Render,
|
Render,
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ use xr::{Action, Binding, Haptic, Posef};
|
|||||||
|
|
||||||
use crate::resources::{XrInstance, XrSession};
|
use crate::resources::{XrInstance, XrSession};
|
||||||
|
|
||||||
|
use super::oculus_touch::ActionSets;
|
||||||
|
|
||||||
pub struct OpenXrActionsPlugin;
|
pub struct OpenXrActionsPlugin;
|
||||||
impl Plugin for OpenXrActionsPlugin {
|
impl Plugin for OpenXrActionsPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
@@ -22,103 +24,123 @@ pub fn setup_oxr_actions(world: &mut World) {
|
|||||||
let right_path = instance.string_to_path("/user/hand/right").unwrap();
|
let right_path = instance.string_to_path("/user/hand/right").unwrap();
|
||||||
let hands = [left_path, right_path];
|
let hands = [left_path, right_path];
|
||||||
|
|
||||||
let mut action_sets = ActionSets { sets: default() };
|
let mut oxr_action_sets = Vec::new();
|
||||||
let mut action_bindings: HashMap<&'static str, Vec<xr::Path>> = HashMap::new();
|
let mut action_sets = XrActionSets { sets: default() };
|
||||||
|
// let mut action_bindings: HashMap<&'static str, Vec<xr::Path>> = HashMap::new();
|
||||||
let mut a_iter = actions.sets.into_iter();
|
let mut a_iter = actions.sets.into_iter();
|
||||||
|
let mut action_bindings: HashMap<
|
||||||
|
(&'static str, &'static str),
|
||||||
|
HashMap<&'static str, Vec<xr::Path>>,
|
||||||
|
> = HashMap::new();
|
||||||
while let Some((set_name, set)) = a_iter.next() {
|
while let Some((set_name, set)) = a_iter.next() {
|
||||||
let mut actions: HashMap<&'static str, TypedAction> = default();
|
let mut actions: HashMap<&'static str, TypedAction> = default();
|
||||||
let oxr_action_set = instance
|
let oxr_action_set = instance
|
||||||
.create_action_set(set_name, set.pretty_name, set.priority)
|
.create_action_set(set_name, set.pretty_name, set.priority)
|
||||||
.unwrap();
|
.expect("Unable to create action set");
|
||||||
for (action_name, action) in set.actions.into_iter() {
|
for (action_name, action) in set.actions.into_iter() {
|
||||||
let typed_action = match action.action_type {
|
let typed_action = match action.action_type {
|
||||||
ActionType::F32 => TypedAction::F32(match action.handednes {
|
ActionType::F32 => TypedAction::F32(match action.handednes {
|
||||||
ActionHandednes::Single => oxr_action_set
|
ActionHandednes::Single => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &[])
|
.create_action(action_name, action.pretty_name, &[])
|
||||||
.unwrap(),
|
.expect(&format!("Unable to create action: {}", action_name)),
|
||||||
ActionHandednes::Double => oxr_action_set
|
ActionHandednes::Double => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &hands)
|
.create_action(action_name, action.pretty_name, &hands)
|
||||||
.unwrap(),
|
.expect(&format!("Unable to create action: {}", action_name)),
|
||||||
}),
|
}),
|
||||||
ActionType::Bool => TypedAction::Bool(match action.handednes {
|
ActionType::Bool => TypedAction::Bool(match action.handednes {
|
||||||
ActionHandednes::Single => oxr_action_set
|
ActionHandednes::Single => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &[])
|
.create_action(action_name, action.pretty_name, &[])
|
||||||
.expect(action.pretty_name),
|
.expect(&format!("Unable to create action: {}", action_name)),
|
||||||
ActionHandednes::Double => oxr_action_set
|
ActionHandednes::Double => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &hands)
|
.create_action(action_name, action.pretty_name, &hands)
|
||||||
.unwrap(),
|
.expect(&format!("Unable to create action: {}", action_name)),
|
||||||
}),
|
}),
|
||||||
ActionType::PoseF => TypedAction::PoseF(match action.handednes {
|
ActionType::PoseF => TypedAction::PoseF(match action.handednes {
|
||||||
ActionHandednes::Single => oxr_action_set
|
ActionHandednes::Single => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &[])
|
.create_action(action_name, action.pretty_name, &[])
|
||||||
.unwrap(),
|
.expect(&format!("Unable to create action: {}", action_name)),
|
||||||
ActionHandednes::Double => oxr_action_set
|
ActionHandednes::Double => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &hands)
|
.create_action(action_name, action.pretty_name, &hands)
|
||||||
.unwrap(),
|
.expect(&format!("Unable to create action: {}", action_name)),
|
||||||
}),
|
}),
|
||||||
ActionType::Haptic => TypedAction::Haptic(match action.handednes {
|
ActionType::Haptic => TypedAction::Haptic(match action.handednes {
|
||||||
ActionHandednes::Single => oxr_action_set
|
ActionHandednes::Single => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &[])
|
.create_action(action_name, action.pretty_name, &[])
|
||||||
.unwrap(),
|
.expect(&format!("Unable to create action: {}", action_name)),
|
||||||
ActionHandednes::Double => oxr_action_set
|
ActionHandednes::Double => oxr_action_set
|
||||||
.create_action(action_name, action.pretty_name, &hands)
|
.create_action(action_name, action.pretty_name, &hands)
|
||||||
.unwrap(),
|
.expect(&format!("Unable to create action: {}", action_name)),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
actions.insert(action_name, typed_action);
|
actions.insert(action_name, typed_action);
|
||||||
for (device_path, bindings) in action.bindings.into_iter() {
|
for (device_path, bindings) in action.bindings.into_iter() {
|
||||||
for b in bindings {
|
for b in bindings {
|
||||||
|
info!("binding {} to {}", action_name, b);
|
||||||
action_bindings
|
action_bindings
|
||||||
|
.entry((set_name, action_name))
|
||||||
|
.or_default()
|
||||||
.entry(device_path)
|
.entry(device_path)
|
||||||
.or_default()
|
.or_default()
|
||||||
.push(instance.string_to_path(b).unwrap());
|
.push(instance.string_to_path(b).unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
oxr_action_sets.push(oxr_action_set);
|
||||||
action_sets.sets.insert(
|
action_sets.sets.insert(
|
||||||
set_name,
|
set_name,
|
||||||
ActionSet {
|
ActionSet {
|
||||||
oxr_action_set,
|
// oxr_action_set,
|
||||||
actions,
|
actions,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (dev, bindings) in action_sets
|
let mut b_indings: HashMap<&'static str, Vec<Binding>> = HashMap::new();
|
||||||
|
for (dev, mut bindings) in action_sets
|
||||||
.sets
|
.sets
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|(_, set)| set.actions.iter().map(|(_, a)| a))
|
.flat_map(|(set_name, set)| {
|
||||||
.zip(action_bindings.into_iter())
|
set.actions
|
||||||
.map(|(action, (dev, bindings))| {
|
.iter()
|
||||||
|
.map(move |(action_name, a)| (set_name, action_name, a))
|
||||||
|
})
|
||||||
|
.zip([&action_bindings].into_iter().cycle())
|
||||||
|
.flat_map(move |((set_name, action_name, action), bindings)| {
|
||||||
|
bindings
|
||||||
|
.get(&(set_name.clone(), action_name.clone()))
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.map(move |(dev, bindings)| (action.clone(), dev.clone(), bindings))
|
||||||
|
})
|
||||||
|
.map(|(action, dev, bindings)| {
|
||||||
|
info!("Hi");
|
||||||
(
|
(
|
||||||
dev,
|
dev,
|
||||||
bindings
|
bindings
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(move |binding| match &action {
|
.map(move |binding| match &action {
|
||||||
TypedAction::F32(a) => Binding::new(a, binding),
|
TypedAction::F32(a) => Binding::new(a, *binding),
|
||||||
TypedAction::Bool(a) => Binding::new(a, binding),
|
TypedAction::Bool(a) => Binding::new(a, *binding),
|
||||||
TypedAction::PoseF(a) => Binding::new(a, binding),
|
TypedAction::PoseF(a) => Binding::new(a, *binding),
|
||||||
TypedAction::Haptic(a) => Binding::new(a, binding),
|
TypedAction::Haptic(a) => Binding::new(a, *binding),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
b_indings.entry(dev).or_default().append(&mut bindings);
|
||||||
|
}
|
||||||
|
for (dev, bindings) in b_indings.into_iter() {
|
||||||
info!(dev);
|
info!(dev);
|
||||||
instance
|
instance
|
||||||
.suggest_interaction_profile_bindings(instance.string_to_path(dev).unwrap(), &bindings)
|
.suggest_interaction_profile_bindings(instance.string_to_path(dev).unwrap(), &bindings)
|
||||||
.unwrap();
|
.expect("Unable to suggest interaction bindings!");
|
||||||
}
|
}
|
||||||
session
|
session
|
||||||
.attach_action_sets(
|
.attach_action_sets(&oxr_action_sets.iter().collect::<Vec<_>>())
|
||||||
&action_sets
|
.expect("Unable to attach action sets!");
|
||||||
.sets
|
|
||||||
.iter()
|
|
||||||
.map(|(_, set)| &set.oxr_action_set)
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
|
world.insert_resource(ActionSets(oxr_action_sets));
|
||||||
world.insert_resource(action_sets);
|
world.insert_resource(action_sets);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,17 +246,17 @@ impl SetupActionSets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct ActionSet {
|
pub struct ActionSet {
|
||||||
oxr_action_set: xr::ActionSet,
|
// oxr_action_set: xr::ActionSet,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
actions: HashMap<&'static str, TypedAction>,
|
actions: HashMap<&'static str, TypedAction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
pub struct ActionSets {
|
pub struct XrActionSets {
|
||||||
sets: HashMap<&'static str, ActionSet>,
|
sets: HashMap<&'static str, ActionSet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActionSets {
|
impl XrActionSets {
|
||||||
pub fn get_action_f32(
|
pub fn get_action_f32(
|
||||||
&self,
|
&self,
|
||||||
action_set: &'static str,
|
action_set: &'static str,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::xr_input::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
actions::ActionSets,
|
actions::XrActionSets,
|
||||||
handtracking::{HandTrackingRef, HandTrackingTracker},
|
handtracking::{HandTrackingRef, HandTrackingTracker},
|
||||||
trackers::{OpenXRLeftController, OpenXRRightController, OpenXRTrackingRoot},
|
trackers::{OpenXRLeftController, OpenXRRightController, OpenXRTrackingRoot},
|
||||||
QuatConv,
|
QuatConv,
|
||||||
@@ -56,7 +56,7 @@ pub fn draw_gizmos(
|
|||||||
Without<OpenXRTrackingRoot>,
|
Without<OpenXRTrackingRoot>,
|
||||||
)>,
|
)>,
|
||||||
hand_tracking: Option<Res<HandTrackingTracker>>,
|
hand_tracking: Option<Res<HandTrackingTracker>>,
|
||||||
action_sets: Res<ActionSets>,
|
action_sets: Res<XrActionSets>,
|
||||||
) {
|
) {
|
||||||
if let Some(hand_tracking) = hand_tracking {
|
if let Some(hand_tracking) = hand_tracking {
|
||||||
let handtracking_ref = hand_tracking.get_ref(&xr_input, &frame_state);
|
let handtracking_ref = hand_tracking.get_ref(&xr_input, &frame_state);
|
||||||
@@ -96,7 +96,6 @@ pub fn draw_gizmos(
|
|||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
//get controller
|
//get controller
|
||||||
let controller = oculus_controller.get_ref(&session, &frame_state, &xr_input, &action_sets);
|
let controller = oculus_controller.get_ref(&session, &frame_state, &xr_input, &action_sets);
|
||||||
info!("{}",controller.x_button());
|
|
||||||
//tracking root?
|
//tracking root?
|
||||||
let mut tracking_transform = &Transform::IDENTITY;
|
let mut tracking_transform = &Transform::IDENTITY;
|
||||||
let root = tracking_root_query.get_single();
|
let root = tracking_root_query.get_single();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
actions::ActionSets,
|
actions::XrActionSets,
|
||||||
hand_poses::get_simulated_open_hand_transforms,
|
hand_poses::get_simulated_open_hand_transforms,
|
||||||
handtracking::HandTrackingTracker,
|
handtracking::HandTrackingTracker,
|
||||||
oculus_touch::OculusController,
|
oculus_touch::OculusController,
|
||||||
@@ -364,7 +364,7 @@ pub fn update_hand_states(
|
|||||||
xr_input: Res<XrInput>,
|
xr_input: Res<XrInput>,
|
||||||
instance: Res<XrInstance>,
|
instance: Res<XrInstance>,
|
||||||
session: Res<XrSession>,
|
session: Res<XrSession>,
|
||||||
action_sets: Res<ActionSets>,
|
action_sets: Res<XrActionSets>,
|
||||||
) {
|
) {
|
||||||
match hand_states_option {
|
match hand_states_option {
|
||||||
Some(mut hands) => {
|
Some(mut hands) => {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use bevy::render::view::{update_frusta, VisibilitySystems};
|
|||||||
use bevy::transform::TransformSystem;
|
use bevy::transform::TransformSystem;
|
||||||
|
|
||||||
use self::actions::{setup_oxr_actions, OpenXrActionsPlugin};
|
use self::actions::{setup_oxr_actions, OpenXrActionsPlugin};
|
||||||
use self::oculus_touch::post_action_setup_oculus_controller;
|
use self::oculus_touch::{post_action_setup_oculus_controller, ActionSets};
|
||||||
use self::trackers::{
|
use self::trackers::{
|
||||||
adopt_open_xr_trackers, update_open_xr_controllers, OpenXRLeftEye, OpenXRRightEye,
|
adopt_open_xr_trackers, update_open_xr_controllers, OpenXRLeftEye, OpenXRRightEye,
|
||||||
OpenXRTrackingRoot,
|
OpenXRTrackingRoot,
|
||||||
@@ -61,7 +61,7 @@ impl Plugin for OpenXrInput {
|
|||||||
}
|
}
|
||||||
//adopt any new trackers
|
//adopt any new trackers
|
||||||
app.add_systems(PreUpdate, adopt_open_xr_trackers);
|
app.add_systems(PreUpdate, adopt_open_xr_trackers);
|
||||||
// app.add_systems(PreUpdate, action_set_system);
|
app.add_systems(PreUpdate, action_set_system);
|
||||||
app.add_systems(PreUpdate, xr_camera_head_sync.after(xr_begin_frame));
|
app.add_systems(PreUpdate, xr_camera_head_sync.after(xr_begin_frame));
|
||||||
//update controller trackers
|
//update controller trackers
|
||||||
app.add_systems(Update, update_open_xr_controllers);
|
app.add_systems(Update, update_open_xr_controllers);
|
||||||
@@ -90,19 +90,19 @@ fn setup_xr_cameras(mut commands: Commands) {
|
|||||||
commands.entity(tracking_root).push_children(&[right, left]);
|
commands.entity(tracking_root).push_children(&[right, left]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn action_set_system(action_sets: Res<ActionSets>, session: Res<XrSession>) {
|
fn action_set_system(action_sets: Res<ActionSets>, session: Res<XrSession>) {
|
||||||
// let mut active_action_sets = vec![];
|
let mut active_action_sets = vec![];
|
||||||
// for i in &action_sets.0 {
|
for i in &action_sets.0 {
|
||||||
// active_action_sets.push(openxr::ActiveActionSet::new(i));
|
active_action_sets.push(openxr::ActiveActionSet::new(i));
|
||||||
// }
|
}
|
||||||
// //info!("action sets: {:#?}", action_sets.0.len());
|
//info!("action sets: {:#?}", action_sets.0.len());
|
||||||
// match session.sync_actions(&active_action_sets) {
|
match session.sync_actions(&active_action_sets) {
|
||||||
// Err(err) => {
|
Err(err) => {
|
||||||
// warn!("{}", err);
|
warn!("{}", err);
|
||||||
// }
|
}
|
||||||
// _ => {}
|
_ => {}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub trait Vec3Conv {
|
pub trait Vec3Conv {
|
||||||
fn to_vec3(&self) -> Vec3;
|
fn to_vec3(&self) -> Vec3;
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ use openxr::{
|
|||||||
use std::convert::identity;
|
use std::convert::identity;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
use super::actions::{ActionHandednes, ActionSets, ActionType, SetupActionSets, XrBinding};
|
use super::actions::{ActionHandednes, XrActionSets, ActionType, SetupActionSets, XrBinding};
|
||||||
|
|
||||||
pub fn post_action_setup_oculus_controller(
|
pub fn post_action_setup_oculus_controller(
|
||||||
action_sets: Res<ActionSets>,
|
action_sets: Res<XrActionSets>,
|
||||||
mut controller: ResMut<OculusController>,
|
mut controller: ResMut<OculusController>,
|
||||||
instance: Res<XrInstance>,
|
instance: Res<XrInstance>,
|
||||||
session: Res<XrSession>,
|
session: Res<XrSession>,
|
||||||
@@ -64,19 +64,19 @@ pub fn post_action_setup_oculus_controller(
|
|||||||
pub fn setup_oculus_controller(
|
pub fn setup_oculus_controller(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
instance: Res<XrInstance>,
|
instance: Res<XrInstance>,
|
||||||
mut action_sets: ResMut<SetupActionSets>,
|
action_sets: ResMut<SetupActionSets>,
|
||||||
) {
|
) {
|
||||||
let oculus_controller = OculusController::new(action_sets).unwrap();
|
let oculus_controller = OculusController::new(action_sets).unwrap();
|
||||||
init_subaction_path(&instance);
|
init_subaction_path(&instance);
|
||||||
commands.insert_resource(oculus_controller);
|
commands.insert_resource(oculus_controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[derive(Resource, Clone)]
|
#[derive(Resource, Clone)]
|
||||||
// pub struct ActionSets(pub Vec<ActionSet>);
|
pub struct ActionSets(pub Vec<ActionSet>);
|
||||||
|
|
||||||
pub struct OculusControllerRef<'a> {
|
pub struct OculusControllerRef<'a> {
|
||||||
oculus_controller: &'a OculusController,
|
oculus_controller: &'a OculusController,
|
||||||
action_sets: &'a ActionSets,
|
action_sets: &'a XrActionSets,
|
||||||
session: &'a Session<AnyGraphics>,
|
session: &'a Session<AnyGraphics>,
|
||||||
frame_state: &'a FrameState,
|
frame_state: &'a FrameState,
|
||||||
xr_input: &'a XrInput,
|
xr_input: &'a XrInput,
|
||||||
@@ -278,7 +278,7 @@ impl OculusController {
|
|||||||
session: &'a Session<AnyGraphics>,
|
session: &'a Session<AnyGraphics>,
|
||||||
frame_state: &'a FrameState,
|
frame_state: &'a FrameState,
|
||||||
xr_input: &'a XrInput,
|
xr_input: &'a XrInput,
|
||||||
action_sets: &'a ActionSets,
|
action_sets: &'a XrActionSets,
|
||||||
) -> OculusControllerRef {
|
) -> OculusControllerRef {
|
||||||
OculusControllerRef {
|
OculusControllerRef {
|
||||||
oculus_controller: self,
|
oculus_controller: self,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
actions::ActionSets, oculus_touch::OculusController, trackers::OpenXRTrackingRoot, Hand,
|
actions::XrActionSets, oculus_touch::OculusController, trackers::OpenXRTrackingRoot, Hand,
|
||||||
QuatConv, Vec3Conv,
|
QuatConv, Vec3Conv,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ pub fn proto_locomotion(
|
|||||||
views: ResMut<XrViews>,
|
views: ResMut<XrViews>,
|
||||||
mut gizmos: Gizmos,
|
mut gizmos: Gizmos,
|
||||||
config_option: Option<ResMut<PrototypeLocomotionConfig>>,
|
config_option: Option<ResMut<PrototypeLocomotionConfig>>,
|
||||||
action_sets: Res<ActionSets>,
|
action_sets: Res<XrActionSets>,
|
||||||
) {
|
) {
|
||||||
match config_option {
|
match config_option {
|
||||||
Some(_) => (),
|
Some(_) => (),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
resources::{XrFrameState, XrInstance, XrSession},
|
resources::{XrFrameState, XrInstance, XrSession},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{actions::ActionSets, oculus_touch::OculusController, Hand, QuatConv, Vec3Conv};
|
use super::{actions::XrActionSets, oculus_touch::OculusController, Hand, QuatConv, Vec3Conv};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct OpenXRTrackingRoot;
|
pub struct OpenXRTrackingRoot;
|
||||||
@@ -64,7 +64,7 @@ pub fn update_open_xr_controllers(
|
|||||||
frame_state: Res<XrFrameState>,
|
frame_state: Res<XrFrameState>,
|
||||||
xr_input: Res<XrInput>,
|
xr_input: Res<XrInput>,
|
||||||
session: Res<XrSession>,
|
session: Res<XrSession>,
|
||||||
action_sets: Res<ActionSets>,
|
action_sets: Res<XrActionSets>,
|
||||||
) {
|
) {
|
||||||
//lock dat frame?
|
//lock dat frame?
|
||||||
let frame_state = *frame_state.lock().unwrap();
|
let frame_state = *frame_state.lock().unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user