-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added demo example from skilltree repo
- Loading branch information
Showing
8 changed files
with
194 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[target.aarch64-linux-android.openxr_loader] | ||
rustc-link-search = ["assets/runtime_libs/arm64-v8a"] | ||
rustc-link-lib = ["openxr_loader"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}; | ||
use bevy::prelude::*; | ||
use bevy::transform::components::Transform; | ||
use bevy_oxr::input::XrInput; | ||
use bevy_oxr::resources::XrFrameState; | ||
use bevy_oxr::xr_input::oculus_touch::OculusController; | ||
use bevy_oxr::xr_input::{QuatConv, Vec3Conv}; | ||
use bevy_oxr::DefaultXrPlugins; | ||
|
||
#[bevy_main] | ||
pub fn main() { | ||
color_eyre::install().unwrap(); | ||
|
||
info!("Running `rvid-client`"); | ||
App::new() | ||
.add_plugins(DefaultXrPlugins) | ||
.add_plugins(LogDiagnosticsPlugin::default()) | ||
.add_plugins(FrameTimeDiagnosticsPlugin) | ||
.add_systems(Startup, setup) | ||
.add_systems(Update, hands) | ||
.run(); | ||
} | ||
|
||
/// set up a simple 3D scene | ||
fn setup( | ||
mut commands: Commands, | ||
mut meshes: ResMut<Assets<Mesh>>, | ||
mut materials: ResMut<Assets<StandardMaterial>>, | ||
) { | ||
// plane | ||
commands.spawn(PbrBundle { | ||
mesh: meshes.add(shape::Plane::from_size(5.0).into()), | ||
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()), | ||
..default() | ||
}); | ||
// cube | ||
commands.spawn(PbrBundle { | ||
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.1 })), | ||
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()), | ||
transform: Transform::from_xyz(0.0, 0.5, 0.0), | ||
..default() | ||
}); | ||
// light | ||
commands.spawn(PointLightBundle { | ||
point_light: PointLight { | ||
intensity: 1500.0, | ||
shadows_enabled: true, | ||
..default() | ||
}, | ||
transform: Transform::from_xyz(4.0, 8.0, 4.0), | ||
..default() | ||
}); | ||
// camera | ||
commands.spawn((Camera3dBundle { | ||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), | ||
..default() | ||
},)); | ||
} | ||
|
||
fn hands( | ||
mut gizmos: Gizmos, | ||
oculus_controller: Res<OculusController>, | ||
frame_state: Res<XrFrameState>, | ||
xr_input: Res<XrInput>, | ||
) { | ||
let mut func = || -> color_eyre::Result<()> { | ||
let frame_state = *frame_state.lock().unwrap(); | ||
|
||
let right_controller = oculus_controller | ||
.grip_space | ||
.right | ||
.relate(&xr_input.stage, frame_state.predicted_display_time)?; | ||
let left_controller = oculus_controller | ||
.grip_space | ||
.left | ||
.relate(&xr_input.stage, frame_state.predicted_display_time)?; | ||
gizmos.rect( | ||
right_controller.0.pose.position.to_vec3(), | ||
right_controller.0.pose.orientation.to_quat(), | ||
Vec2::new(0.05, 0.2), | ||
Color::YELLOW_GREEN, | ||
); | ||
gizmos.rect( | ||
left_controller.0.pose.position.to_vec3(), | ||
left_controller.0.pose.orientation.to_quat(), | ||
Vec2::new(0.05, 0.2), | ||
Color::YELLOW_GREEN, | ||
); | ||
Ok(()) | ||
}; | ||
|
||
let _ = func(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
rvid_client::main() | ||
} |