GithubHelp home page GithubHelp logo

sdfgeoff / blender_bevy_toolkit Goto Github PK

View Code? Open in Web Editor NEW
196.0 12.0 19.0 5.52 MB

A blender addon and bevy plugin to use Blender as an editor for Bevy

License: Other

Python 78.90% Rust 18.62% Makefile 2.48%

blender_bevy_toolkit's Introduction

FormatCheck ExportCheck

About

Bevy is a game engine written in the Rust programming language. It's currently rather early stages and doesn't have any sort of editor. So until it does, the only way to assign custom components to objects is through code. That's where blender_bevy_toolkit comes in. It provides a UI for adding components to objects in blender and exports the blender scene to bevy's scn format.

Note: I am developing this for my specific game and use case, so the exporter may not include all the features your game requires. PR's welcome!

Instructions

  1. Copy or symlink the blender_bevy_toolkit subfolder (the one with all the python) into your blenders addons folder. On linux this is .config/blender/2.92/scripts/addons.

  2. Create a scene in blender

  3. Add blender_bevy_toolkit to your Cargo.toml

[dependencies]
blender_bevy_toolkit = {path="../blender_bevy_toolkit"}
  1. Add the BlendLoadPlugin
use blender_bevy_toolkit::BlendLoadPlugin;
let mut builder = App::build();
builder = builder.add_plugin(BlendLoadPlugin::default());
  1. You can now load scenes the normal way:
let scene_handle: Handle<DynamicScene> =
    asset_server.load("models/Collections/PhysicsTest.scn");
scene_spawner.spawn_dynamic(scene_handle);

Supported Features:

A UI!

The whole point of this integration is to allow use of a user interface for creating scenes and adding components! So here's what using it looks like:

clip of adding components

Collection Export

The exporter exports all the collections in the blend file, including mesh data and hierarchy.

Note: This will likely change in the near future to exporting the current blender scene.

Physics Export

Physics objects are exported with an integration with bevy_rapier

Custom Components

Custom components allow your game-specific logic to be added through the same blender interface. Most custom components can be defined through simple JSON files, and those that require more complex behaviour can be implemented as python files. Custom components are stored externally to the addon (the addon looks for the folder component_definitions in the directory of the blend file), so you can work on multiple games without conflicts.

screenshot of custom component definition

Version Information:

Rust:

  • bevy 0.6.0
  • bevy_rapier 0.12.0

Blender:

  • blender 3.x (may work on others)

Developing

The makefile runs a script to export some blends from the test_scenes folder.

You should install:

pip install black

blender_bevy_toolkit's People

Contributors

lucaspoffo avatar sdfgeoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blender_bevy_toolkit's Issues

Saved entities, but with no components

Hello, I'm not sure if you want this issue here or in https://github.com/sdfgeoff/blender_bevy_top_down_space_shooter , but I can load Level1.blend in Blender, and I can also load Level1.scn in the game, but when I run the export (make assets) all of the material files are deleted, and Level1.scn is overwritten with a file that has exactly 131 entites, but each of them has an empty component array. I load the game, and, as expected, it's just a black window. I can restore the material .pngs and .scn files from git, but I can't generate assets from even the unmodified .blend files. I'm not sure how to debug Blender scripts, or I'd give more information. I can say that I've tried with both Blender 3.0 and Blender 3.1.

blender_bevy_toolkit dead?

As the title says i am wondering if this project is dead. we're at bevy 0.8 now and the docs still say it only supports bevy 0.6.
i like the idea of this project since it allows you to use a suite of open source tools for game development.

Export the scene rather than collections

This decision to export collections was originally made so that collections could be shared/linked across blend files and not have duplicate object trees exported. However, I think I'd rather the "least surprise" of exporting scenes.

Meshes are shared between blends anyway as the filename is saved as the mesh hash....

bevy 0.6

will this toolkit ever be updated to the latest bevy release? just wondering

Export test run on windows

Currently the makefile and tests are set up for linux, but we want to be able to export scenes from a windows computer as well. Adding windows export as a unit test will ensure that future change do not break windows compatibility

Components are not being detected

@sdfgeoff Hey man.

So I uninstalled the all addon and I installed the new addon.

What you put inside the JSON files depends on what components you have in your game.
Eg from the example above:

So I added this exact same script:

{
    "name": "Engine",
    "description": "Used to apply thrust to an object",
    "id": "space_ship_engine",
    "struct": "game::ship_parts::engine::Engine",
    "fields": [
        {
            "field": "max_thrust_newtons", 
            "type": "f64", 
            "default": 10.0,
            "description": "The max amount of force the engine can apply, measured in Newtons"
        }
    ]
}

into a file called windmill.json inside the folder component_definitions. In the outside directory of component_definitions I have a file called Demo.blend. And I still can't see any components to add.

image

not too sure why this is happening?

Consider Using GLTF as the interchange format rather than bevy's scene format.

Bevy supports importing via GLTF - which includes animations, textures, materials and a zillion other thing. To implement support for these through the RON scene format would be a significant amount of work - and because the RON scene format is tightly coupled to Bevy's internal representations (eg of things like transforms), breakage between bevy versions is extremely likely.

Summary:

Pros:

  • Someone else defines GLTF, so the format is stable
  • Someone else has already implemented blender's exporter for GLTF, and it is good.
  • Someone else has already implemented bevy's importer for GLTF, and it is good.

Cons:

  • May be less suitable for defining large scenes with lots of asset re-use because meshes (etc) are not shared between GLTF files. TBH the way I was doing this currently is rather sketchy, and I'm not that sure that I'm a fan anyway.

Implementation Notes

The main advantage of this repo is the ability to define custom properties and use blender's UI to configure them. This is extremely useful, and the current GLTF pipeline doesn't support costom ECS-like properties in either application. However, support for reading the extra properties from GLTF was implemented in May last year, and by enabling this checkbox in blender's GLTF exporter, you can export custom properties from blender:
properties

Because we store the exporter data in custom properties, enabling this checkbox .... just works!
image

So, what would we need to do:

  1. Implement a function on the bevy side that can hook into GLTF import and convert JSON into components. https://bevy-cheatbook.github.io/3d/gltf.html#gltf-master-asset Shows how you can 'tag' a GLTF on import so it may be possible to create a similar function that is generic and mutates the scene_bundle that comes from the GLTF import. Chances are we can "just use" serde to handle the deserialization. We may have to put all the components into a single "bevy_ecs" property and do some type wrangling/macro stuff.

  2. Delete all the RON stuff and encode/decode logic from the exporter (yay! less code)

  3. ??? Profit?

Adding enum component types

Hey there - as my game is using v0.11 of rapier, I'm trying to create my own component_definitions. As of 0.11, many of the larger structures have been broken down for easier usage within bevy's ECS. That includes components such as RigidBodyType that are a numbered enum.

In the custom components file, I see a struct must be provided with fields. Is there any way currently to define enum components? Perhaps through a py file? (I'm thinking that it might be best to add all components needed for a rigidbody/collider at once, so maybe a py file can define that)

Bevy new version is out

Hey everyone,

Bevy got updated from 0.6.0 to 0.7.0 sometime a while ago. Bevy Rapier also got updated from 0.12.1 to 0.13.2

I tried migrating this project myself. The most notable changes are in rapier_physics.rs and some in blender_mesh.rs. Unfortunately, I couldn't make my project run afterward.

We should migrate the project so that at least it runs new versions of Bevy and Rapier.

How do I get Blender and Cargo to detect `blender_bevy_toolkit` on Windows?

Hey man.

So I am on Windows 10, I ONLY copied the blender_bevy_toolkit (from your entire git project folder) inside C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\addons

In regards to Blender, it doesn't seem to quite pick up this extension. So I suppose I have to manually install it? If I go to addons and click on the Install button, then if I navigate inside the extension's folder:

image

Which file am I installing this from?


In regards to cargo.toml file when I added this:

[dependencies]
blender_bevy_toolkit = {path="C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\addons\blender_bevy_toolkit"}

it fails to pick it up. Now I know that it contains a bunch of py scripts, however according to your instrunctions I am supposed to do this:

[dependencies]
blender_bevy_toolkit = {path="../blender_bevy_toolkit"}

I change the path to match where the current path of blender_bevy_toolkit exists.

Do you know how would I fix this mate?

Exports appear sideways

Hey there - because Bevy is a Y-up world, the export is 90 deg off. I was wondering if there was an option to choose Y as up in the export, or if the solution is to modify the game to just treat Z as up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.