Skip to content

Commit

Permalink
feat(Blenvy): complete overhaul and re branding to : Blenvy (#192)
Browse files Browse the repository at this point in the history
- replaced the various crates with a single one
- replaced the Blender add-ons with a single one
- this is an alpha release !
- for features etc see the various docs
  • Loading branch information
kaosat-dev committed Aug 14, 2024
1 parent 9b50d77 commit d1b5d26
Show file tree
Hide file tree
Showing 636 changed files with 58,586 additions and 24,769 deletions.
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
[workspace]
members = [
"crates/*",
"examples/common*",
"examples/bevy_gltf_components/*",
"examples/bevy_gltf_blueprints/*",
"examples/bevy_gltf_save_load/*",
"examples/bevy_registry_export/*",
"examples/*",
"testing/bevy_example/",
]
resolver = "2"
Expand Down
148 changes: 148 additions & 0 deletions Migration_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Blender add-ons

- gltf_auto_export and bevy_components have been replaced with a single Blenvy add-on for simplicity , I recomend reading the [documentation](./tools/blenvy/README.md)
* settings are **not** transfered from the legacy add-ons !
* first uninstall the old add-ons
* install Blenvy
* configure Blenvy (for these , see the Blenvy add-on docs)
* [upgrade your components](./tools/blenvy/README-components.md#renamingupgradingfixing-components)


## Components:

- no more need to add your components to an empty called xxx_components, you can now directly add your components to the blueprint's collection itself
- you will need to "upgrade" your components from the previous add-on, as they are stored in a completely different way

## Multiple components with the same short name

Up until now , it was not possible to have multiple components with the same name (ie foo::bar::componentA & some::other::componentA) as all the logic was based on short names,
this is not an issue anymore

## Auto export:

- the previous stripped down gltf export settings are not part of the add-on anymore, please configure them like this:
- you need to reconfigure your auto export settings , as they have changed significantly as has their storage

## All the Bevy crates have been replaced with a single one

- the new crate doesn't even really need configuring, so
- in your cargo.toml file, replace any references to the old crates (bevy_gltf_components, bevy_gltf_blueprints, bevy_registry_export, bevy_gltf_save_load etc)
with:

```toml
# Cargo.toml
[dependencies]
bevy="0.14"
blenvy = { version = "0.1.0"}
```

and set things up in your code:

```rust no_run
use bevy::prelude::*;
use blenvy::*;

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(BlenvyPlugin)

.run();
}
```

## Removed almost all setting for the crate

- the ONLY setting is **aabbs** // defaults to true

## Legacy mode has been removed

- less headaches when using the tools!
If you still want to manually specify components using Blender's custom properties you need to


## BlueprintName replaced with BlueprintInfo

- this is a very important change ! to avoid possible path clashes , the ```BlueprintInfo``` component contains
the actual path (with your **assets** folder) to the Blueprint, and a name (for convenience)

## SpawnHere renamed to SpawnBlueprint

changed the naming for more clarity & specificity


## Automatic assets loading

- no more need to preload gltf files, you can spawn a level & all its blueprint like this:

```rust no_run
commands.spawn((
BlueprintInfo::from_path("levels/World.gltf"),
HideUntilReady, // Only if you want to keep the level hidden until it is finished spawning
SpawnBlueprint, // See note above
GameWorldTag,
InAppRunning,
));
```

Blenvy will take care of loading all needed blueprints & other assets for you

## Blueprint instance events

- you can now use the ```BlueprintEvent``` to get notified of crucial blueprint instance events

* ```AssetsLoaded```
```rust no run
/// event fired when a blueprint instance has finished loading all of its assets & before it attempts spawning
AssetsLoaded {
entity: Entity,
blueprint_name: String,
blueprint_path: String,
// TODO: add assets list ?
}
```

* ```InstanceReady```
```rust no run
/// event fired when a blueprint instance has completely finished spawning, ie
/// - all its assests have been loaded
/// - all of its child blueprint instances are ready
/// - all the post processing is finished (aabb calculation, material replacements etc)
InstanceReady {
entity: Entity,
blueprint_name: String,
blueprint_path: String,
},

```

## BlueprintInstanceDisabled

you can now query for this component

## Track loading blueprint instances with the BlueprintSpawning component

- other than with events, you can also query for the ```BlueprintSpawning``` component to be sure an entity you are manipulating is finished with its blueprint instance spawning process

## Keep your currently spawning blueprint instances hidden until they are ready with the HideUntilReady component

If you want your blueprint instance to be hidden until it is ready, just add this component to the entity.
This can be particularly usefull in at least two use cases:
- when spawning levels
- when spawning bluprint instances that contain **lights** at runtime: in previous versions I have noticed some very unpleasant "flashing" effect when spawning blueprints with lights,
this component avoids that issue

## Hot reload

if you have configured your Bevy project to use hot reload you will automatically get hot reloading of levels & blueprints

## Improved animation handling

- sceneAnimations
- animationTriggers

## Completely restructured blueprint spawning process


Additionally
- you do not really need to worry about SystemSets anymore
6 changes: 3 additions & 3 deletions README-workflow-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ The workflow goes as follows (once you got your Bevy code setup)

## Bevy side
- create & register all your components you want to be able to set from the Blender side (this is basic Bevy, no specific work needed)
- follow the instructions in the [bevy_registry_export](./crates/bevy_registry_export/) to generate a registry export
- follow the instructions in the [blenvy](./crates/blenvy/) to generate a registry export

## Component creation

Setup the Blender [bevy_components](./tools/bevy_components/README.md) add-on
Setup the Blender [Blenvy](./tools/blenvy/README.md) blender add-on
to add & edit your components visually & reliably

![bevy_components](./docs/bevy_components.png)
Expand All @@ -22,7 +22,7 @@ to add & edit your components visually & reliably
- custom properties
- cameras & lights if you want a complete level (as in this example)
![gltf_export](./docs/gltf_export.png)
- or much better, using [gltf_auto_export](./tools/gltf_auto_export/)
- or much better, using [blenvy](./tools/blenvy/)

## Now use your gltf files in Bevy

Expand Down
144 changes: 72 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,123 +1,123 @@
[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)
[![License](https://img.shields.io/crates/l/bevy_gltf_components)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/LICENSE.md)
[![License](https://img.shields.io/crates/l/blenvy)](https://github.com/kaosat-dev/Blenvy/blob/main/LICENSE.md)
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F5TO32O)

# Blender_bevy_components_workflow
# BLENVY: a friendly Blender <=> Bevy workflow

![demo](./docs/blender_bevy.png)
![demo](https://github.com/kaosat-dev/Blenvy/blob/main/docs/blender_bevy.png)

Crates & tools for adding components from gltf files in the [Bevy](https://bevyengine.org/) game engine.

It enables minimalistic [Blender](https://www.blender.org/) (gltf) centric workflow for Bevy, ie defining entites & their components
inside Blender using Blender's objects **custom properties**.
Aka "Blender as editor for Bevy"
It enables a [Blender](https://www.blender.org/) (gltf) centric workflow for Bevy, ie defining entites & their components
inside Blender. Aka "Blender as editor for Bevy"

It also allows you to setup 'blueprints' in Blender by using collections (the recomended way to go most of the time), or directly on single use objects .

## Features

* Useful if you want to use Blender (or any editor allowing to export gltf with configurable gltf_extras) as your Editor
* define Bevy components as custom properties in Blender (some visually , some using RON, though an older JSON version is also available)
* no plugin or extra tools needed in Blender (but I provide a [little Blender add-on](./tools/gltf_auto_export/README.md) to auto-export to gltf on save (and more !) if you want !)
* now also with a nice UI tool to add & edit Bevy components in [Blender](./tools/bevy_components/README.md)
* define components in Blender Collections & override any of them in your collection instances if you want
* ability to automatically turn your Blender collections into [gltf Blueprints](./crates/bevy_gltf_blueprints/README.md) for reuse
* minimal setup & code, you can have something basic running fast
* minimal dependencies: Bevy, Serde & Ron only !
* opensource


## Crates

- [bevy_gltf_components](./crates/bevy_gltf_components/) This crate allows you to define components direclty inside gltf files and instanciate/inject the components on the Bevy side.
> [!CAUTION]
> Blenvy is currently in **Alpha 1** state so there are still quite a few bugs, missing functionality, missing docs, broken examples etc
> Please make sure you back up your Blender files before using it !
There is a [video tutorial/explanation](https://youtu.be/-lcScjQCA3c) if you want, or you can read the crate docs.
The examples for the crate are [here](./examples/bevy_gltf_components/)
> [!CAUTION]
> Please make sure to use matching versions numbers for the Blender add-on & the rust crate !
> This is the only way to make sure everything works as intended
- [bevy_gltf_blueprints](./crates/bevy_gltf_blueprints/) This crate adds the ability to define Blueprints/Prefabs for Bevy inside gltf files and spawn them in Bevy. With the ability to override and add components when spawning, efficient "level" loading etc
## Quickstart

There is a [video tutorial/explanation](https://youtu.be/CgyNtwgYwdM) for this one too, or you can read the crate docs
The examples for the crate are [here](./examples/bevy_gltf_blueprints/)
> Note: this is the recomended crate to use and uses ```bevy_gltf_components``` under the hood
Want to jump right in? See the [quickstart guide](https://github.com/kaosat-dev/Blenvy/blob/main/docs/quickstart/README.md) for how to setup a basic project as fast as possible.

- [bevy_gltf_save_load](./crates/bevy_gltf_save_load/) This crate adds the ability to save & load your game state in a relatively simple way, by leveraging the blueprint functionality of
bevy_gltf_blueprints to only save a minimal subset of dynamic data, seperating dynamic & static parts of levels etc.
The examples for the crate are [here](./examples/bevy_gltf_save_load/)
> Note: this uses ```bevy_gltf_blueprints``` under the hood
## Features

- [bevy_registry_export](./crates/bevy_registry_export/) This crate adds the ability to export your project's Bevy registry to json, in order to be able to generate custom component UIs on the Blender side in the Blender [bevy_components](./tools/bevy_components/README.md) add-on

* Useful if you want to use Blender as your Editor
* define Bevy components as custom properties in Blender with an UI tool to add & edit Bevy components, automatically export gltf blueprints & more in [Blender](./tools/blenvy/README.md)
* blueprints & levels system : turn your Blender collections into [gltf Blueprints](./crates/blenvy/README.md) for reuse inside levels that are just Blender scenes
* setup & tweak components in Blender Collections & override any of them in your collection instances if you want
* setup & tweak components for objects, meshes and materials as well !
* automatically load all assets for each blueprint (gltf files, manually added assets), with no setup required
* hot reload of your levels & blueprints
* minimal setup & code, you can have something basic running fast
* minimal dependencies: Bevy, Serde & RON only!
* opensource

## Tools
> If you were previously using the individual bevy_gltf_xxx crates & Blender add-ons please see the [migration guide](./Migration_guide.md)
### Blender: gltf_auto_export
## Crates

- for convenience I also added a [Blender addon](./tools/gltf_auto_export/README.md) that automatically exports your level/world from Blender to gltf whenever you save your Blend file
- it also supports automatical exports of collections as [Gltf blueprints](./crates/bevy_gltf_blueprints/README.md) & more !
One crate to rule them all !

Please read the [README]((./tools/gltf_auto_export/README.md)) of the add-on for installation & use instructions
* [blenvy](./crates/blenvy/) This crate allows you to
* define components direclty inside gltf files and instanciate/inject the components on the Bevy side.
* export your project's Bevy registry to json, in order to be able to generate custom component UIs on the Blender side in the Blender [blenvy](./tools/blenvy/README.md) add-on
* define Blueprints/Prefabs for Bevy inside gltf files and spawn them in Bevy. With the ability to override and add components when spawning, efficient "level" loading etc
* the ability to save & load your game state in a relatively simple way, by leveraging the blueprint functionality to only save a minimal subset of dynamic data, seperating dynamic & static parts of levels etc.

### Blender: bevy_components
OLD videos:
There is a [video tutorial/explanation](https://youtu.be/-lcScjQCA3c) if you want, or you can read the crate docs.
There is a [video tutorial/explanation](https://youtu.be/CgyNtwgYwdM) for this one too, or you can read the crate docs

- an add-on for Blender to allow easilly adding & editing Bevy components , using automatically generated UIs for each component
The examples for the crate are [here](./examples/blenvy/)

Please read the [README]((./tools/bevy_components/README.md)) of the add-on for installation & use instructions
## Tools

### Blender: blenvy

* an all in one [Blender addon](./tools/blenvy/README.md) for the Blender side of the workflow:
* allow easilly adding & editing Bevy components , using automatically generated UIs for each component
* automatically exports your level/world from Blender to gltf whenever you save your Blend file
* automatically export your [Gltf blueprints](./crates/blenvy/README.md) & assets

## Examples

you can find all examples, by crate as seperate crates for clearer dependencies in [here](./examples/)
you can find all examples, [here](./examples/blenvy)

- [bevy_gltf_components](./examples/bevy_gltf_components/)
* [basic](./examples/bevy_gltf_components/basic/) use of ```bevy_gltf_components``` only, to spawn entities with components defined inside gltf files
* [components](./examples/blenvy/components/) use of ```components``` only, to spawn entities with components defined inside gltf files
* [blueprints](./examples/blenvy/blueprints/) use of ```blueprints``` and ```levels``` to spawn a level and then populate it with entities coming from different gltf files, live (at runtime) spawning of entities etc
* [animation](./examples/blenvy/animation/) how to use and trigger animations from gltf files
* [save_load](./examples/blenvy/save_load/) how to save & load levels
* [demo](./examples/demo/) a full demo showcasing all features , including physics, animation

- [bevy_gltf_blueprints](./examples/bevy_gltf_blueprints/)
* [basic](./examples/bevy_gltf_blueprints/basic/) more advanced example : use of ```bevy_gltf_blueprints``` to spawn a level and then populate it with entities coming from different gltf files, live (at runtime) spawning of entities etc
* [animation](./examples/bevy_gltf_blueprints/animation/) how to use and trigger animations from gltf files (a feature of ```bevy_gltf_blueprints```)
* & lots more
## Workflow

- [bevy_gltf_save_load](./examples/bevy_gltf_save_load/)
The workflow goes as follows (once you got your Bevy code setup)

- [bevy_registry_export](./examples/bevy_registry_export/)
* create & register all your components you want to be able to set from the Blender side (this is basic Bevy, no specific work needed)

![component registration](https://github.com/kaosat-dev/Blenvy/blob/main/docs/component_registration.png)

## Workflow
* setup & then use the Blenvy [Bevy crate](./crates/blenvy/README.md)
* setup & then use the Blenvy [Blender add-on](./tools/blenvy/README.md)
* iterate
* have fun !

The workflow goes as follows (once you got your Bevy code setup)
* then add your components to objects in Blender **with a nice UI** see [here](./README-workflow-ui.md) for more details

- create & register all your components you want to be able to set from the Blender side (this is basic Bevy, no specific work needed)
See the [quickstart](https://github.com/kaosat-dev/Blenvy/blob/main/docs/quickstart/README.md) for a full step-by-step guide.

![component registration](./docs/component_registration.png)
## Third Party Integration

- then you have two options
- add your components to objects in Blender **manually** as **custom properties** : see [here](./README-workflow-classic.md) for more details
- add your components to objects in Blender **with a nice UI** see [here](./README-workflow-ui.md) for more details
Read about the [Avian Physics Integration](https://github.com/kaosat-dev/Blenvy/blob/main/docs/avian/README.md) to learn how to setup colliders in Blender that will be used by the Avian physics engine in Bevy.

## Limitations / issues
- Some of `bevy_rapier`/physics code / ways to define colliders could perhaps be done better/visually within Blender (currently it also goes via RON)

## Future work
- I have a number of other tools/ code helpers that I have not yet included here, because they need cleanup/ might make this example too complex

## Credits

- somebody I cannot recall helped me originally with the gltf loading tracker in the Bevy Discord, so thanks ! And if it was you, please let me know so I can give credit where credit is due :)
* Some of `avian` or `bevy_rapier` /physics code / ways to define colliders could perhaps be done better/visually within Blender

## Contributors

Thanks to all the contributors helping out with this project ! Big kudos to you, contributions are always appreciated ! :)

- [GitGhillie](https://github.com/GitGhillie)
- [Azorlogh](https://github.com/Azorlogh)
- [BSDGuyShawn](https://github.com/BSDGuyShawn)
- [yukkop](https://github.com/yukkop)
- [killercup](https://github.com/killercup)
- [janhohenheim ](https://github.com/janhohenheim)
* [GitGhillie](https://github.com/GitGhillie)
* [Azorlogh](https://github.com/Azorlogh)
* [BSDGuyShawn](https://github.com/BSDGuyShawn)
* [yukkop](https://github.com/yukkop)
* [killercup](https://github.com/killercup)
* [janhohenheim](https://github.com/janhohenheim)
* [BUGO07](https://github.com/BUGO07)
* [ChristopherBiscardi](https://github.com/ChristopherBiscardi)
* [slyedoc](https://github.com/slyedoc)

## License

This repo, all its code, contents & assets is Dual-licensed under either of

- Apache License, Version 2.0, ([LICENSE-APACHE](./LICENSE_APACHE.md) or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](./LICENSE_MIT.md) or https://opensource.org/licenses/MIT)
* Apache License, Version 2.0, ([LICENSE-APACHE](./LICENSE_APACHE.md) or <https://www.apache.org/licenses/LICENSE-2.0>)
* MIT license ([LICENSE-MIT](./LICENSE_MIT.md) or <https://opensource.org/licenses/MIT>)
Loading

0 comments on commit d1b5d26

Please sign in to comment.