Crate bevy_blender[][src]

Expand description

bevy_blender

bevy_blender is a Bevy library that allows you to use assets created in Blender directly from the .blend file.

Usage

  1. Add bevy_blender to your Cargo.toml dependencies.
  2. Add bevy_blender::BlenderPlugin plugin to the bevy App
  3. Load Blender mesh assets by using the included macro with asset_server.load. For example: asset_server.load(blender_mesh!("blend_file.blend", "mesh_name"))

If the asset name in Blender starts with an underscore, it will not be loaded. You can use this to have extra assets in the .blend file that you do not want loaded to the AssetServer.

Example

fn main() {
    App::build()
        .add_plugin(bevy_blender::BlenderPlugin)
        .add_startup_system(setup.system())
        // ...
        .run();
}

fn setup(commands: &mut Commands, asset_server: Res<AssetServer>, mut materials: ResMut<Assets<StandardMaterial>>) {
    commands.spawn_bundle(PbrBundle {
            mesh: asset_server.load(blender_mesh!("demo.blend", "Suzanne")),
            material: materials.add(Color::rgb(0.9, 0.4, 0.3).into()),
            ..Default::default()
        })
        // ...
}

A full example can be found in examples/demo.rs. Simply run cargo run --example demo to execute it. This will open a .blend file located at assets/demo.blend.

Macros

Takes a .blend file location and a mesh name and generates an appropriate asset_loader string. For example, blender_mesh!(“demo.blend”, “Suzanne”) turns to “demo.blend#MESuzanne”.

Structs

Plugin for Bevy that allows for interaction with .blend files

Enums

bevy_blender errors