Skip to content

Commit 9575642

Browse files
committed
Allow for scene to be selected via command line args
1 parent 823b25f commit 9575642

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ assets:
55
rm -r assets || true
66
blender -b test_scenes/Cube.blend --python export.py -- --output-file="assets/scenes/Cube.scn" --log-level=DEBUG
77
blender -b test_scenes/PhysicsTest.blend --python export.py -- --output-file="assets/scenes/PhysicsTest.scn" --log-level=DEBUG
8+
blender -b test_scenes/Heirarchy.blend --python export.py -- --output-file="assets/scenes/Heirarchy.scn" --log-level=DEBUG
89

910
run:
10-
cargo run --example scenes
11+
cargo run --example scenes -- scenes/PhysicsTest.scn

examples/scenes/main.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ use bevy::prelude::*;
33
use bevy_rapier3d::physics::RapierPhysicsPlugin;
44
use blender_bevy_toolkit::BlendLoadPlugin;
55

6+
use std::env;
7+
8+
69
fn spawn_scene(
710
mut commands: Commands,
811
asset_server: Res<AssetServer>,
@@ -23,13 +26,20 @@ fn spawn_scene(
2326
..Default::default()
2427
});
2528

26-
let scene_handle: Handle<DynamicScene> = asset_server.load("scenes/PhysicsTest.scn");
29+
let args: Vec<String> = env::args().collect();
30+
31+
if args.len() != 2 {
32+
println!("Please specify a scene file to load. For example:\n cargo run --example scenes -- scenes/Heirarchy.scn");
33+
std::process::exit(1);
34+
}
35+
36+
println!("Running scene: {}", args[1]);
37+
38+
let scene_handle: Handle<DynamicScene> = asset_server.load(args[1].as_str());
2739
scene_spawner.spawn_dynamic(scene_handle);
2840
}
2941

3042
fn main() {
31-
println!("Running example scenes");
32-
3343
App::build()
3444
.add_plugins(DefaultPlugins)
3545
.add_plugin(RapierPhysicsPlugin)

test_scenes/Cube.blend

-46.8 KB
Binary file not shown.

test_scenes/Heirarchy.blend

774 KB
Binary file not shown.

0 commit comments

Comments
 (0)