-
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.
physnet: initial project scaffold (#107)
- Loading branch information
Showing
8 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Networked Physics in VR | ||
|
||
An implementation of [this excellent GafferOnGames article][article] about | ||
writing netcode for a distributed physics simulation in VR. | ||
|
||
Unlike the original article, this demo will be utilizing WebTransport for its | ||
networking and will not be as focused on hyper-optimized message payload sizes | ||
like in the original article. | ||
|
||
|
||
## Project Status | ||
|
||
WIP / active development. | ||
|
||
[article]: https://gafferongames.com/post/networked_physics_in_virtual_reality/ |
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,18 @@ | ||
[package] | ||
name = "physnet_client" | ||
version.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
description = "A demo for Networked Physics in VR" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
bevy.workspace = true | ||
bevy_oxr.workspace = true | ||
color-eyre.workspace = true | ||
openxr.workspace = true |
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,77 @@ | ||
use bevy::{ | ||
app::{App, Startup}, | ||
asset::Assets, | ||
core_pipeline::core_3d::Camera3dBundle, | ||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, | ||
ecs::system::{Commands, ResMut}, | ||
log::info, | ||
math::{ | ||
primitives::{Cuboid, Plane3d}, | ||
Vec3, | ||
}, | ||
pbr::{PbrBundle, PointLight, PointLightBundle, StandardMaterial}, | ||
prelude::{bevy_main, default}, | ||
render::{ | ||
color::Color, | ||
mesh::{Mesh, Meshable}, | ||
}, | ||
transform::components::Transform, | ||
}; | ||
use bevy_oxr::DefaultXrPlugins; | ||
|
||
const APP_NAME: &str = env!("CARGO_PKG_NAME"); | ||
|
||
#[bevy_main] | ||
pub fn main() { | ||
color_eyre::install().unwrap(); | ||
|
||
info!("Running {}", APP_NAME); | ||
App::new() | ||
.add_plugins(DefaultXrPlugins { | ||
app_info: bevy_oxr::graphics::XrAppInfo { | ||
name: env!("CARGO_PKG_NAME").to_string(), | ||
}, | ||
..default() | ||
}) | ||
.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(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0)), | ||
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))), | ||
..default() | ||
}); | ||
// cube | ||
commands.spawn(PbrBundle { | ||
mesh: meshes.add(Mesh::from(Cuboid::from_size(Vec3::splat(0.1)))), | ||
material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.7, 0.6))), | ||
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() | ||
},)); | ||
} |
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 @@ | ||
fn main() { | ||
physnet_client::main() | ||
} |
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,11 @@ | ||
[package] | ||
name = "physnet_server" | ||
version.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
description = "A demo for Networked Physics in VR" | ||
publish = false | ||
|
||
[dependencies] |
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 @@ | ||
|