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

Overview

bevy_blender

Crate version Crate license

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

Purpose

  1. I am learning Rust and it seemed like a not-too-easy and not-too-hard problem.
  2. I would like to be able to maintain several assets in the same .blend file and not have to worry about exporting them.
  3. It seems like a good way to contribute to the Bevy project.

Related Works

  1. Arsenal is a project with the goal of using Blender as a UI for creating Bevy games.
  2. Reddit/Github user sdfgeoff created the Blender Bevy Toolkit which exports Blender objects to Bevy readable scene files (as well as some other cool things).

Both of these projects are neat, but do not serve my desired use case. They both act as extensions of the Bevy game engine, using Blender almost as a front-end framework. I simply want to create assets in Blender and have a ridiculously easy way to access those assets in Bevy with a minimal amount of middle work.

Credit where credit is due

  1. This project was heavily modeled after the bevy_stl project, so thanks nilclass!
  2. Much of the heavy lifting is accomplished using the Blend crate, thanks lukebitts!

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, mut materials: ResMut>) {
    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. Running this demo will look like this (note that the ngon cap on the cylinder is missing, see the limitations section for more details): demo bevy window

Aspirations

Currently, bevy_blend can only load mesh data from a .blend file. I plan to extend this to allow users to import any asset type supported by both Blender and Bevy (assuming there is some reasonable way to convert between the two). Ultimately I would like to create a BlenderObjectBundle which would load all assets belonging to a Blender object, as well as it descendents. The goal would be that, barring minor rendering differences, an object rendered in Blender will look the same rendered in Bevy.

If you have other ideas for how this project could be used, please let me know!

Known limitations

  • Currently only tri and quad faces are supported, ngon face support is coming though.
  • Only non-compressed .blend files work. Though Blender uses the standard zlib compression (I think), so it should be easy enough to detect a compressed .blend file and uncompress it.
  • Only the named mesh is constructed, children meshes have to be manually constructed and placed relative to the parent mesh. See the above aspiration section.
  • Blender modifiers are not applied before constructing the mesh.
  • The .blend file is read, and all meshes are parsed, for each call to asset_server.load(). Ideally we would parse the .blend file once and just make all of the meshes available. Still trying to find the best way to accomplish this.
You might also like...
Flexcord! A custom Discord client to allow you to do what you want!

Disclaimer Flexcord is NO WHERE near done. Flexcord What is it? Flexcord is a Discord client that flexes for your needs, it allows you to do exactly w

Bongo Copy Cat wants to be involved in everything you do but instead just imitates you hitting your keyboard all day. After all it's just a cat.
Bongo Copy Cat wants to be involved in everything you do but instead just imitates you hitting your keyboard all day. After all it's just a cat.

Bongo Copy Cat Introduction Bongo Copy Cat wants to be involved in everything you do but instead just imitates you hitting your keyboard all day. Afte

This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to the arrow format.

Arrow2-derive - derive for Arrow2 This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to th

Postgres proxy which allows tools that don't natively supports IAM auth to connect to AWS RDS instances.

rds-iamauth-proxy rds-proxy lets you make use of IAM-based authentication to AWS RDS instances from tools that don't natively support that method of a

A program written in Rust, that allows the user to find the current location of the International Space Station and see it on a map.

ISS Location ViewFinder A program written in Rust, that allows the user to find the current location of the International Space Station and see it on

A VtubeStudio plugin that allows iFacialMocap to stream data to the app, enabling full apple ARkit facial tracking to be used for 2D Vtuber models.

facelink_rs A VtubeStudio plugin that allows iFacialMocap to stream data to the app, enabling full apple ARkit facial tracking to be used for 2D Vtube

Peekable iterator that allows to peek the next N elements without consuming them.

peekaboo docs - crates.io Peekable iterator that allows to peek the next N elements without consuming them. It's no_std compatible by default. It also

A merkle-based token distributor for the Solana network that allows distributing a combination of unlocked and linearly unlocked tokens.

merkle-distributor A program for distributing tokens efficiently via uploading a Merkle root. Claiming Airdrop via CLI To claim via CLI instead of usi

Rust library to scan files and expand multi-file crates source code as a single tree

syn-file-expand This library allows you to load full source code of multi-file crates into a single syn::File. Features: Based on syn crate. Handling

Owner
Jerald Thomas
Jerald Thomas
UnTeX is both a library and an executable that allows you to manipulate and understand TeX files.

UnTeX UnTeX is both a library and an executable that allows you to manipulate and understand TeX files. Usage Executable If you wish to use the execut

Jérome Eertmans 1 Apr 5, 2022
📮 load, write, and copy remote and local assets

axoasset This library offers read, write, and copy functions, for local and remote assets given a string that contains a relative or absolute local pa

axo 7 Jan 25, 2023
A cli utility written in Rust that allows fetching all the labels of a project, save those as a YAML file

A cli utility written in Rust that allows fetching all the labels of a project, save those as a YAML file that you can easily edit or save as backup and apply a saved preset to new repositories.

Chevdor 4 May 5, 2022
This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

Christofer Nolander 11 Dec 22, 2022
Twidge is a fresh approach to productivity. It integrates with your workflow and allows you to be your most productive self.

Twidge A productivity app which is an extension to your mind Twidge is a cross platform productivity app, powered by rust, tauri, prisma-client-rust T

Twidge 187 Jun 28, 2023
The lambda-chaos-extension allows you to inject faults into Lambda functions without modifying the function code.

Chaos Extension - Seamless, Universal & Lightning-Fast The lambda-chaos-extension allows you to inject faults into Lambda functions without modifying

AWS CLI Tools 5 Aug 2, 2023
Sketches I created using Rust + Nannou

Sketches Motivation I have followed generative artists like Ben Kovach and Tyler Hobbs for a while, and their artwork is truly impressive. Check them

Franklin van Nes 4 Jun 11, 2022
A tool that generates a Sublime Text project file that helps you get started using Scoggle.

README A tool that generates a Sublime Text project file that helps you get started using Scoggle. While Scoggle-Gen may not find every single source

Sanjiv Sahayam 0 Jan 10, 2022
Use winit like the async runtime you've always wanted

async-winit Use winit like the async runtime you've always wanted. winit is actually asynchronous, contrary to popular belief; it's just not async. It

John Nunley 17 Apr 23, 2023
Searchbuddy is a browser extension that lets you chat with people that are searching for what you're searching for.

searchbuddy Make friends while searching! Searchbuddy is a browser extension that lets you chat with people that are searching for what you're searchi

Joseph Gerber 14 May 23, 2022