Skip to content

Commit 0ad6b43

Browse files
committed
Added bevy_rmesh
1 parent a6aafca commit 0ad6b43

File tree

16 files changed

+640
-288
lines changed

16 files changed

+640
-288
lines changed

Cargo.toml

+3-30
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,3 @@
1-
[package]
2-
name = "rmesh"
3-
version = "0.3.0"
4-
edition = "2021"
5-
license = "MIT OR Apache-2.0"
6-
description = "A parser for the rmesh extension"
7-
homepage = "https://github.com/DotWith/rmesh/"
8-
documentation = "https://docs.rs/rmesh"
9-
repository = "https://github.com/DotWith/rmesh/"
10-
readme = "README.md"
11-
exclude = ["/assets/*"]
12-
13-
[dependencies]
14-
thiserror = "1.0.38"
15-
binrw = "0.11.1"
16-
17-
[dev-dependencies]
18-
three-d = "0.14.0"
19-
20-
[[example]]
21-
name = "read"
22-
path = "examples/read.rs"
23-
24-
[[example]]
25-
name = "write"
26-
path = "examples/write.rs"
27-
28-
[[example]]
29-
name = "view"
30-
path = "examples/view.rs"
1+
[workspace]
2+
members = ["rmesh", "bevy_rmesh"]
3+
resolver = "2"

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ assert_eq!(rmesh.entities.len(), 13);
1515

1616
### Examples
1717

18-
- [Read](../examples/read.rs)
19-
- [Write](../examples/write.rs)
20-
- [View](../examples/view.rs)
18+
- [read](../rmesh/examples/read.rs)
19+
- [write](../rmesh/examples/write.rs)
20+
- [bevy_rmesh](../bevy_rmesh/examples/view.rs)
2121

2222
### Task list
2323

2424
- [ ] Write documentation
2525
- [X] Create a writer
26+
- [ ] Add X file loader for bevy_rmesh

bevy_rmesh/Cargo.toml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "bevy_rmesh"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "MIT OR Apache-2.0"
6+
description = "A Bevy extension for RMesh loading"
7+
homepage = "https://github.com/scpcbredux/rmesh/"
8+
documentation = "https://docs.rs/rmesh"
9+
repository = "https://github.com/scpcbredux/rmesh/"
10+
readme = "../README.md"
11+
keywords = ["bevy"]
12+
exclude = ["assets/*"]
13+
14+
[dependencies]
15+
bevy = { version = "0.10.1", default-features = false, features = ["bevy_asset", "bevy_pbr", "bevy_render", "bevy_scene"] }
16+
anyhow = "1.0.68"
17+
rmesh = { path = "../rmesh", version = "0.3.1" }
18+
19+
[dev-dependencies]
20+
bevy = "0.10.1"
21+
22+
[[example]]
23+
name = "view"
24+
path = "examples/view.rs"
File renamed without changes.

bevy_rmesh/examples/view.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use bevy::prelude::*;
2+
use bevy_rmesh::RMeshPlugin;
3+
4+
fn main() {
5+
App::new()
6+
.add_plugins(DefaultPlugins)
7+
.add_plugin(RMeshPlugin)
8+
.add_startup_system(setup)
9+
.run();
10+
}
11+
12+
fn setup(
13+
mut commands: Commands,
14+
mut materials: ResMut<Assets<StandardMaterial>>,
15+
asset_server: Res<AssetServer>,
16+
) {
17+
// cube
18+
commands.spawn(PbrBundle {
19+
mesh: asset_server.load("cube.rmesh#Mesh0"),
20+
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
21+
transform: Transform::from_xyz(0.0, 0.5, 0.0),
22+
..default()
23+
});
24+
// camera
25+
commands.spawn(Camera3dBundle {
26+
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
27+
..default()
28+
});
29+
}

bevy_rmesh/src/lib.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
mod loader;
2+
pub use loader::*;
3+
4+
use bevy::{prelude::*, reflect::TypeUuid};
5+
6+
#[derive(Default)]
7+
pub struct RMeshPlugin;
8+
9+
impl Plugin for RMeshPlugin {
10+
fn build(&self, app: &mut App) {
11+
app.init_asset_loader::<RMeshLoader>()
12+
.add_asset::<Room>()
13+
.add_asset::<RoomMesh>();
14+
}
15+
}
16+
17+
#[derive(Debug, TypeUuid)]
18+
#[uuid = "f652caee-aace-49da-9ea3-a314de33b38f"]
19+
pub struct Room {
20+
pub scene: Handle<Scene>,
21+
pub meshes: Vec<RoomMesh>,
22+
// pub entity_meshes: Vec<RoomMesh>,
23+
}
24+
25+
#[derive(Debug, TypeUuid)]
26+
#[uuid = "2d373e3d-cb2a-468c-ab25-2724f624dd2f"]
27+
pub struct RoomMesh {
28+
pub mesh: Handle<Mesh>,
29+
pub material: Handle<StandardMaterial>,
30+
}

0 commit comments

Comments
 (0)