Skip to content

Commit

Permalink
Now loads and displays something with bevy 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
sdfgeoff committed Jan 17, 2022
1 parent 699ebac commit 61f29e5
Show file tree
Hide file tree
Showing 9 changed files with 1,044 additions and 1,181 deletions.
1,913 changes: 847 additions & 1,066 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "blender_bevy_toolkit"
version = "0.1.0"
version = "0.2.0"
authors = ["Geoffrey Irons <sdfgeoff@gmail.com>"]
edition = "2018"
edition = "2021"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -13,7 +13,8 @@ serde = {version = "1", features = ["derive"]}
smallvec = { version = "1.4", features = ["serde"] }

[dependencies.bevy]
version="0.5.0"
version="0.6.0"
# default-features=false

[dependencies.bevy_rapier3d]
version="0.9.0"
version="0.12.0"
10 changes: 5 additions & 5 deletions examples/scenes/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This example loads the various test scenes
use bevy::prelude::*;
use bevy_rapier3d::physics::RapierPhysicsPlugin;
use bevy_rapier3d::physics::{NoUserData, RapierPhysicsPlugin};
use blender_bevy_toolkit::BlendLoadPlugin;

fn spawn_scene(
Expand All @@ -18,7 +18,7 @@ fn spawn_scene(
});

// Create a Light
commands.spawn().insert_bundle(LightBundle {
commands.spawn().insert_bundle(PointLightBundle {
transform: Transform::from_translation(Vec3::new(0.0, 8.0, 0.0)),
..Default::default()
});
Expand All @@ -30,10 +30,10 @@ fn spawn_scene(
fn main() {
println!("Running example scenes");

App::build()
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
.add_plugin(BlendLoadPlugin::default())
.add_startup_system(spawn_scene.system())
.run();
}
}
6 changes: 6 additions & 0 deletions export.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import traceback
import argparse

import logging
logging.basicConfig(level=logging.INFO)

sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import blender_bevy_toolkit

Expand All @@ -21,6 +24,9 @@ def export_all(args):
required=True)
config = parser.parse_args(args)

blender_bevy_toolkit.register()
blender_bevy_toolkit.load_handler(None)

blender_bevy_toolkit.do_export({
"output_filepath": config.output_file,
"mesh_output_folder": "meshes",
Expand Down
1 change: 1 addition & 0 deletions src/blend_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use bevy::prelude::*;
/// of the entity with this component
#[derive(Reflect, Default)]
#[reflect(Component)]
#[derive(Component)]
pub struct BlendCollectionLoader {
path: String,
}
Expand Down
1 change: 1 addition & 0 deletions src/blend_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use bevy::prelude::*;
/// Component that contains the name of the object
#[derive(Reflect, Default)]
#[reflect(Component)]
#[derive(Component)]
pub struct BlendLabel {
pub name: String,
}
13 changes: 8 additions & 5 deletions src/blend_mesh.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use bevy::{
asset::{AssetLoader, LoadContext},
prelude::*,
render::{mesh::Indices, pipeline::PrimitiveTopology},
render::{mesh::Indices, render_resource::PrimitiveTopology},
utils::BoxedFuture,
};
use std::convert::TryInto;

#[derive(Reflect, Default)]
#[reflect(Component)] // this tells the reflect derive to also reflect component behaviors
#[derive(Component)]
pub struct BlendMeshLoader {
path: String,
}
Expand Down Expand Up @@ -40,11 +41,13 @@ pub fn blend_mesh_loader(
commands.entity(entity).insert_bundle((
bundle.mesh,
bundle.material,
bundle.main_pass,
bundle.draw,
bundle.visible,
bundle.render_pipelines,
// bundle.main_pass,
// bundle.draw,
bundle.visibility,
bundle.computed_visibility,
// bundle.render_pipelines,
));
//commands.entity(entity).insert_bundle(bundle);
}
}

Expand Down
13 changes: 8 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ impl BlendLoadPlugin {
}

impl Plugin for BlendLoadPlugin {
fn build(&self, app: &mut AppBuilder) {
fn build(&self, app: &mut App) {
app.register_type::<blend_label::BlendLabel>();
app.register_type::<blend_collection::BlendCollectionLoader>();

app.register_type::<blend_mesh::BlendMeshLoader>();
app.register_type::<rapier_physics::RigidBodyDescription>();
app.register_type::<rapier_physics::ColliderDescription>();


app.init_asset_loader::<blend_mesh::BlendMeshAssetLoader>();

app.add_system(blend_collection::blend_collection_loader.system());
app.add_system(blend_mesh::blend_mesh_loader.system());
app.add_system(rapier_physics::body_description_to_builder.system());
app.add_system(rapier_physics::collider_description_to_builder.system());

app.register_type::<rapier_physics::ColliderDescription>();
// app.add_system(rapier_physics::body_description_to_builder.system());
// app.add_system(rapier_physics::collider_description_to_builder.system());
}
}
Loading

0 comments on commit 61f29e5

Please sign in to comment.