Compare commits

...

2 Commits

Author SHA1 Message Date
kaosat.dev e54d41ca5c feat(Blenvy:Bevy): added back & updated animation docs 2024-07-21 02:08:04 +02:00
kaosat.dev 09d1218942 feat(Blenvy): cleanups, docs & tweaks
* fixed & improved the Blenvy crate README
 * make a few things conditional on whether hot reload is enabled or not
 * cleaned up very verbose debug messages
 * a few renames & coherency pass
 * cleanups cleanups, cleanups !
2024-07-21 01:44:05 +02:00
45 changed files with 285 additions and 275 deletions

View File

@ -1,5 +1,5 @@
[![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) [![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) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F5TO32O)
# BLENVY: a friendly Blender <=> Bevy workflow ! # BLENVY: a friendly Blender <=> Bevy workflow !

View File

@ -261,7 +261,7 @@ Bevy Side:
- [ ] fix animations handling - [ ] fix animations handling
- [x] fix/upgrade blueprint level animations - [x] fix/upgrade blueprint level animations
- [x] fix/upgrade scene level animations - [x] fix/upgrade scene level animations
- [ ] rename SceneAnimations to LevelAnimations (more coherent with the rest) - [x] rename SceneAnimations to InstanceAnimations (more coherent with the rest)
- [ ] add back & cleanup animation frame triggers - [ ] add back & cleanup animation frame triggers
- [x] move sub blueprint handling to blueprints_finalize_instances - [x] move sub blueprint handling to blueprints_finalize_instances
- [x] look into component overriding , it seems broken: - [x] look into component overriding , it seems broken:
@ -295,7 +295,7 @@ Bevy Side:
Injection => inject lights & co => spawn => afterSpawn Injection => inject lights & co => spawn => afterSpawn
=> Injection => inject lights & co => Injection => inject lights & co
- [ ] add a way of overriding assets for collection instances => doubt this is possible - [ ] add a way of overriding assets for collection instances => how can we make this possible
- [ ] cleanup all the spurious debug messages - [ ] cleanup all the spurious debug messages
- [x] fix animation handling - [x] fix animation handling
- [x] how to deal with animation graphs ? - [x] how to deal with animation graphs ?
@ -305,6 +305,7 @@ Bevy Side:
- [x] make "InBlueprint" non optional, - [x] make "InBlueprint" non optional,
- [x] and perhaps rename it to "FromBlueprint" - [x] and perhaps rename it to "FromBlueprint"
- [ ] perhaps change it to FromBlueprint(BlueprintInfo) - [ ] perhaps change it to FromBlueprint(BlueprintInfo)
- [ ] in order for this to work correctly, stop iterating descendants as soon as there is one with an Existing FromBlueprint component
- [x] BlueprintInstanceDisabled => BlueprintInstanceDisabled - [x] BlueprintInstanceDisabled => BlueprintInstanceDisabled
- [x] fix "remove component" operator from the rename/fix/update components panel - [x] fix "remove component" operator from the rename/fix/update components panel
@ -312,8 +313,9 @@ Bevy Side:
- [ ] update main docs - [ ] update main docs
- [x] rename project to Blenvy - [x] rename project to Blenvy
- [ ] replace all references to the old 2 add-ons with those to Blenvy - [x] replace all references to the old 2 add-ons with those to Blenvy
- [x] rename repo to "Blenvy" - [x] rename repo to "Blenvy"
- [x] do a deprecation release of all bevy_gltf_xxx crates to point at the new Blenvy crate - [x] do a deprecation release of all bevy_gltf_xxx crates to point at the new Blenvy crate
- [ ] material assets seem to be added to list regardless of whether material exports are enabled or not
clear && pytest -svv --blender-template ../../testing/bevy_example/art/testing_library.blend --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration_prepare.py && pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration.py clear && pytest -svv --blender-template ../../testing/bevy_example/art/testing_library.blend --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration_prepare.py && pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration.py

18
crates/blenvy/OLD.md Normal file
View File

@ -0,0 +1,18 @@
## SystemSet
the ordering of systems is very important !
For example to replace your proxy components (stand-in components when you cannot/ do not want to use real components in the gltf file) with actual ones, which should happen **AFTER** the Blueprint based spawning,
so ```blenvy``` provides a **SystemSet** for that purpose: ```GltfBlueprintsSet```
Typically , the order of systems should be
***blenvy (GltfComponentsSet::Injection)*** => ***blenvy (GltfBlueprintsSet::Spawn, GltfBlueprintsSet::AfterSpawn)*** => ***replace_proxies***
see https://github.com/kaosat-dev/Blenvy/tree/main/examples/blenvy/basic for how to set it up correctly

View File

@ -43,7 +43,7 @@ Here's a minimal usage example:
# Cargo.toml # Cargo.toml
[dependencies] [dependencies]
bevy="0.14" bevy="0.14"
blenvy = { version = "0.1.0"} blenvy = { version = "0.1.0-alpha.1"}
``` ```
@ -54,7 +54,7 @@ use blenvy::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugins(BlenvyPlugin) .add_plugins(BlenvyPlugin::default())
.add_systems(Startup, setup_game) .add_systems(Startup, setup_game)
.add_systems(Update, spawn_blueprint_instance) .add_systems(Update, spawn_blueprint_instance)
@ -78,13 +78,13 @@ fn setup_game(
fn spawn_blueprint_instance( fn spawn_blueprint_instance(
mut commands: Commands, mut commands: Commands,
keycode: Res<Input<KeyCode>>, keycode: Res<ButtonInput<KeyCode>>,
){ ){
if keycode.just_pressed(KeyCode::S) { if keycode.just_pressed(KeyCode::KeyS) {
let new_entity = commands.spawn(( let new_entity = commands.spawn((
BlueprintInfo(name: "Health_Pickup".to_string(), path:""), // mandatory !! BlueprintInfo::from_path("spawnable.glb"), // mandatory !!
SpawnBlueprint, // mandatory !! SpawnBlueprint, // mandatory !!
TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)), // VERY important !! TransformBundle::from_transform(Transform::from_xyz(0.0, 2.0, 0.2)), // VERY important !!
// any other component you want to insert // any other component you want to insert
)); ));
} }
@ -96,7 +96,7 @@ fn spawn_blueprint_instance(
Add the following to your `[dependencies]` section in `Cargo.toml`: Add the following to your `[dependencies]` section in `Cargo.toml`:
```toml ```toml
blenvy = "0.1.0" blenvy = "0.1.0-alpha.1"
``` ```
Or use `cargo add`: Or use `cargo add`:
@ -114,14 +114,13 @@ use blenvy::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(BlenvyPlugin) .add_plugin(BlenvyPlugin::default())
.run(); .run();
} }
``` ```
you may want to configure your "library"/"blueprints" settings: you may want to configure your settings:
```rust no_run ```rust no_run
use bevy::prelude::*; use bevy::prelude::*;
@ -145,7 +144,8 @@ fn main() {
You can spawn entities from blueprints like this: You can spawn entities from blueprints like this:
```rust no_run ```rust no_run
commands.spawn(( commands.spawn((
BlueprintInfo("Health_Pickup".to_string()), // mandatory !! BlueprintInfo::from_path("Health_Pickup.glb"), // mandatory !!
// or the alterive: BlueprintInfo{name:"health pickup1".into(), path:"Health_Pickup.glb".into()}
SpawnBlueprint, // mandatory !! SpawnBlueprint, // mandatory !!
TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)), // optional TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)), // optional
@ -154,7 +154,7 @@ commands.spawn((
``` ```
Once spawning of the actual entity is done, the spawned Blueprint will be *gone/merged* with the contents of Blueprint ! Once spawning of the actual entity is done, the contents (components, children etc) of the Blueprint will have been merged with those of the entity itself.
> Important : > Important :
you can **add** or **override** components present inside your Blueprint when spawning the BluePrint itself: ie you can **add** or **override** components present inside your Blueprint when spawning the BluePrint itself: ie
@ -165,7 +165,7 @@ you can just add any additional components you need when spawning :
```rust no_run ```rust no_run
commands.spawn(( commands.spawn((
BlueprintInfo("Health_Pickup".to_string()), BlueprintInfo::from_path("Health_Pickup.glb"),
SpawnBlueprint, SpawnBlueprint,
TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)), TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)),
// from Rapier/bevy_xpbd: this means the entity will also have a velocity component when inserted into the world // from Rapier/bevy_xpbd: this means the entity will also have a velocity component when inserted into the world
@ -183,7 +183,7 @@ any component you specify when spawning the Blueprint that is also specified **w
for example for example
```rust no_run ```rust no_run
commands.spawn(( commands.spawn((
BlueprintInfo(path: "Health_Pickup.glb".into()), BlueprintInfo::from_path("Health_Pickup.glb"),
SpawnBlueprint, SpawnBlueprint,
TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)), TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)),
HealthPowerUp(20)// if this is component is also present inside the "Health_Pickup" blueprint, that one will be replaced with this component during spawning HealthPowerUp(20)// if this is component is also present inside the "Health_Pickup" blueprint, that one will be replaced with this component during spawning
@ -217,76 +217,11 @@ This way all your levels, your dynamic entities etc, are kept seperated from UI
``` ```
## SystemSet ## Registry
the ordering of systems is very important !
For example to replace your proxy components (stand-in components when you cannot/ do not want to use real components in the gltf file) with actual ones, which should happen **AFTER** the Blueprint based spawning,
so ```blenvy``` provides a **SystemSet** for that purpose: ```GltfBlueprintsSet```
Typically , the order of systems should be
***bevy_gltf_components (GltfComponentsSet::Injection)*** => ***blenvy (GltfBlueprintsSet::Spawn, GltfBlueprintsSet::AfterSpawn)*** => ***replace_proxies***
see https://github.com/kaosat-dev/Blenvy/tree/main/examples/blenvy/basic for how to set it up correctly
## Animation
```blenvy``` provides some lightweight helpers to deal with animations stored in gltf files
* an ```Animations``` component that gets inserted into spawned (root) entities that contains a hashmap of all animations contained inside that entity/gltf file .
(this is a copy of the ```named_animations``` inside Bevy's gltf structures )
* an ```AnimationPlayerLink``` component that gets inserted into spawned (root) entities, to make it easier to trigger/ control animations than it usually is inside Bevy + Gltf files
The workflow for animations is as follows:
* create a gltf file with animations (using Blender & co) as you would normally do
* inside Bevy, use the ```blenvy``` boilerplate (see sections above), no specific setup beyond that is required
* to control the animation of an entity, you need to query for entities that have both ```AnimationPlayerLink``` and ```Animations``` components (added by ```blenvy```) AND entities with the ```AnimationPlayer``` component
For example:
```rust no_run
// example of changing animation of entities based on proximity to the player, for "fox" entities (Tag component)
pub fn animation_change_on_proximity_foxes(
players: Query<&GlobalTransform, With<Player>>,
animated_foxes: Query<(&GlobalTransform, &AnimationPlayerLink, &Animations ), With<Fox>>,
mut animation_players: Query<&mut AnimationPlayer>,
){
for player_transforms in players.iter() {
for (fox_tranforms, link, animations) in animated_foxes.iter() {
let distance = player_transforms
.translation()
.distance(fox_tranforms.translation());
let mut anim_name = "Walk";
if distance < 8.5 {
anim_name = "Run";
}
else if distance >= 8.5 && distance < 10.0{
anim_name = "Walk";
}
else if distance >= 10.0 && distance < 15.0{
anim_name = "Survey";
}
// now play the animation based on the chosen animation name
let mut animation_player = animation_players.get_mut(link.0).unwrap();
animation_player.play_with_transition(
animations.named_animations.get(anim_name).expect("animation name should be in the list").clone(),
Duration::from_secs(3)
).repeat();
}
}
}
```
see https://github.com/kaosat-dev/Blenvy/tree/main/examples/blenvy/animation for how to set it up correctly
particularly from https://github.com/kaosat-dev/Blenvy/tree/main/examples/blenvy/animation/game/in_game.rs
Blenvy automatically exports a Json file containing of all your registered components/ types, in order to be able to create UIs that allows you to add & edit your components directly in Blender in the [Blenvy](https://github.com/kaosat-dev/Blenvy/tree/main/tools/blenvy) Blender add-on
- The output file will be generated in the ```Startup``` schedule whenever you run your app.
- Every time you compile & run your app, the output json file will be updated.
## Materials ## Materials
@ -294,8 +229,69 @@ Ff you enable it on the blender side, Blenvy will be using "material libraries"
Ie for example without this option, 56 different blueprints using the same material with a large texture would lead to the material/texture being embeded Ie for example without this option, 56 different blueprints using the same material with a large texture would lead to the material/texture being embeded
56 times !! 56 times !!
Generating optimised blueprints and material libraries can be automated using the [Blender plugin](https://github.com/kaosat-dev/Blenvy/tree/main/tools/blenvy)
## Animation
```blenvy``` provides some lightweight helpers to deal with animations stored in gltf files
It has both support for blueprint level animations (shared by all blueprint instance of the same blueprint)
* an ```BlueprintAnimations``` component that gets inserted into spawned (root) entities that contains a hashmap of all animations contained inside that entity/gltf file .
* an ```BlueprintAnimationPlayerLink``` component that gets inserted into spawned (root) entities, to make it easier to find Bevy's ```AnimationPlayer``` and ```AnimationTransitions``` components
And instance level animations (specific to one instance)
* an ```InstanceAnimations``` component that gets inserted into spawned (root) entities that contains a hashmap of all animations **specific to that instance** .
* an ```InstanceAnimationPlayerLink``` component that gets inserted into spawned (root) entities, to make it easier to find Bevy's ```AnimationPlayer``` and ```AnimationTransitions``` components for the animations above
The workflow for animations is as follows:
* create a gltf file with animations (using Blender & co) as you would normally do
* inside Bevy, use the ```blenvy``` boilerplate (see sections above), no specific setup beyond that is required
* to control the animation of an entity, you need to query for entities that have both ```BlueprintAnimationPlayerLink``` and ```BlueprintAnimations``` components (added by ```blenvy```) AND entities with the ```AnimationPlayer``` component
For example (blueprint animations):
```rust no_run
pub fn trigger_blueprint_animations(
animated_foxes: Query<(&BlueprintAnimationPlayerLink, &BlueprintAnimations), With<Fox>>,
mut animation_players: Query<(&mut AnimationPlayer, &mut AnimationTransitions)>,
keycode: Res<ButtonInput<KeyCode>>,
){
if keycode.just_pressed(KeyCode::KeyW) {
for (link, animations) in animated_foxes.iter() {
let (mut animation_player, mut animation_transitions) =
animation_players.get_mut(link.0).unwrap();
let anim_name = "Walk";
animation_transitions
.play(
&mut animation_player,
animations
.named_indices
.get(anim_name)
.expect("animation name should be in the list")
.clone(),
Duration::from_secs(5),
)
.repeat();
}
}
}
```
see https://github.com/kaosat-dev/Blenvy/tree/main/examples/blenvy/animation for how to set it up correctly
## Additional features
this crate also includes automatic handling of lights in gltf files, to attempt to match Blender's eevee rendering as close as possible:
* **BlenderLightShadows** (automatically generated by the gltf_auto_export Blender add-on) allows you to toggle light's shadows on/off in Blender and have matching
behaviour in Bevy
* **BlenderBackgroundShader** aka background color is also automatically set on the Bevy side
* **BlenderShadowSettings** sets the cascade_size on the bevy side to match the one configured in Blender
Generating optimised blueprints and material libraries can be automated using the latests version of the [Blender plugin](https://github.com/kaosat-dev/Blenvy/tree/main/tools/blenvy)
## Examples ## Examples
@ -318,7 +314,7 @@ The main branch is compatible with the latest Bevy release, while the branch `be
Compatibility of `blenvy` versions: Compatibility of `blenvy` versions:
| `blenvy` | `bevy` | | `blenvy` | `bevy` |
| :-- | :-- | | :-- | :-- |
| `0.1 - 0.2` | `0.14` | | `0.1` | `0.14` |
| branch `main` | `0.14` | | branch `main` | `0.14` |
| branch `bevy_main` | `main` | | branch `bevy_main` | `main` |

View File

@ -1,6 +1,6 @@
[![Crates.io](https://img.shields.io/crates/v/bevy_gltf_blueprints)](https://crates.io/crates/bevy_gltf_blueprints) [![Crates.io](https://img.shields.io/crates/v/bevy_gltf_blueprints)](https://crates.io/crates/bevy_gltf_blueprints)
[![Docs](https://img.shields.io/docsrs/bevy_gltf_blueprints)](https://docs.rs/bevy_gltf_blueprints/latest/bevy_gltf_blueprints/) [![Docs](https://img.shields.io/docsrs/bevy_gltf_blueprints)](https://docs.rs/bevy_gltf_blueprints/latest/bevy_gltf_blueprints/)
[![License](https://img.shields.io/crates/l/bevy_gltf_blueprints)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/crates/bevy_gltf_blueprints/License.md) [![License](https://img.shields.io/crates/l/bevy_gltf_blueprints)](https://github.com/kaosat-dev/Blenvy/blob/main/crates/bevy_gltf_blueprints/License.md)
[![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) [![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)
# bevy_gltf_blueprints (deprecated in favor of Blenvy) # bevy_gltf_blueprints (deprecated in favor of Blenvy)
@ -18,8 +18,8 @@ A blueprint is a set of **overrideable** components + a hierarchy: ie
* a component called BlueprintName * a component called BlueprintName
Particularly useful when using [Blender](https://www.blender.org/) as an editor for the [Bevy](https://bevyengine.org/) game engine, combined with the Blender add-ons that do a lot of the work for you Particularly useful when using [Blender](https://www.blender.org/) as an editor for the [Bevy](https://bevyengine.org/) game engine, combined with the Blender add-ons that do a lot of the work for you
- [gltf_auto_export](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/gltf_auto_export) - [gltf_auto_export](https://github.com/kaosat-dev/Blenvy/tree/main/tools/gltf_auto_export)
- [bevy_components](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/bevy_components) - [bevy_components](https://github.com/kaosat-dev/Blenvy/tree/main/tools/bevy_components)
## Usage ## Usage
@ -226,7 +226,7 @@ Typically , the order of systems should be
***bevy_gltf_components (GltfComponentsSet::Injection)*** => ***bevy_gltf_blueprints (GltfBlueprintsSet::Spawn, GltfBlueprintsSet::AfterSpawn)*** => ***replace_proxies*** ***bevy_gltf_components (GltfComponentsSet::Injection)*** => ***bevy_gltf_blueprints (GltfBlueprintsSet::Spawn, GltfBlueprintsSet::AfterSpawn)*** => ***replace_proxies***
see an example [here](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_blueprints/basic) for how to set it up correctly see an example [here](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_blueprints/basic) for how to set it up correctly
@ -280,9 +280,9 @@ pub fn animation_change_on_proximity_foxes(
} }
``` ```
see [here](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_blueprints/animation) for how to set it up correctly see [here](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_blueprints/animation) for how to set it up correctly
particularly from [here](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_blueprints/animation/src/game/in_game.rs) particularly from [here](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_blueprints/animation/src/game/in_game.rs)
## Materials ## Materials
@ -303,9 +303,9 @@ material_library_folder: "materials".into() //defaults to "materials" the folder
```bevy_gltf_blueprints``` currently does NOT take care of loading those at runtime ```bevy_gltf_blueprints``` currently does NOT take care of loading those at runtime
see an example [here](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_blueprints/materials) for how to set it up correctly see an example [here](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_blueprints/materials) for how to set it up correctly
Generating optimised blueprints and material libraries can be automated using the latests version of the [Blender plugin](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/gltf_auto_export) Generating optimised blueprints and material libraries can be automated using the latests version of the [Blender plugin](https://github.com/kaosat-dev/Blenvy/tree/main/tools/gltf_auto_export)
## Legacy mode ## Legacy mode
@ -319,7 +319,7 @@ BlueprintsPlugin{legacy_mode: false}
``` ```
You **need** to disable legacy mode if you want to use the [```bevy_components```](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/tools_bevy_blueprints/tools/bevy_components) Blender addon + the [```bevy_registry_export crate```](https://crates.io/crates/bevy_registry_export) ! You **need** to disable legacy mode if you want to use the [```bevy_components```](https://github.com/kaosat-dev/Blenvy/tree/tools_bevy_blueprints/tools/bevy_components) Blender addon + the [```bevy_registry_export crate```](https://crates.io/crates/bevy_registry_export) !
As it create custom properties that are writen in real **ron** file format instead of a simplified version (the one in the legacy mode) As it create custom properties that are writen in real **ron** file format instead of a simplified version (the one in the legacy mode)
@ -328,15 +328,15 @@ As it create custom properties that are writen in real **ron** file format inste
## Examples ## Examples
* [basic](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_blueprints/basic) * [basic](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_blueprints/basic)
* [xbpd](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_blueprints/basic_xpbd_physics) * [xbpd](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_blueprints/basic_xpbd_physics)
* [animation](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_blueprints/animation) * [animation](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_blueprints/animation)
* [materials](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_blueprints/materials) * [materials](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_blueprints/materials)
* [multiple_levels_multiple_blendfiles](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_blueprints/multiple_levels_multiple_blendfiles) * [multiple_levels_multiple_blendfiles](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_blueprints/multiple_levels_multiple_blendfiles)
## Compatible Bevy versions ## Compatible Bevy versions

View File

@ -1,6 +1,6 @@
[![Crates.io](https://img.shields.io/crates/v/bevy_gltf_components)](https://crates.io/crates/bevy_gltf_components) [![Crates.io](https://img.shields.io/crates/v/bevy_gltf_components)](https://crates.io/crates/bevy_gltf_components)
[![Docs](https://img.shields.io/docsrs/bevy_gltf_components)](https://docs.rs/bevy_gltf_components/latest/bevy_gltf_components/) [![Docs](https://img.shields.io/docsrs/bevy_gltf_components)](https://docs.rs/bevy_gltf_components/latest/bevy_gltf_components/)
[![License](https://img.shields.io/crates/l/bevy_gltf_components)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/crates/bevy_gltf_components/License.md) [![License](https://img.shields.io/crates/l/bevy_gltf_components)](https://github.com/kaosat-dev/Blenvy/blob/main/crates/bevy_gltf_components/License.md)
[![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) [![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)
@ -15,7 +15,7 @@ This crate allows you to define [Bevy](https://bevyengine.org/) components direc
***important*** : the plugin for processing gltf files runs in ***update*** , so you cannot use the components directly if you spawn your scene from gltf in ***setup*** (the additional components will not show up) ***important*** : the plugin for processing gltf files runs in ***update*** , so you cannot use the components directly if you spawn your scene from gltf in ***setup*** (the additional components will not show up)
Please see the Please see the
* [example](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_components/basic) * [example](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_components/basic)
* or use [```bevy_asset_loader```](https://github.com/NiklasEi/bevy_asset_loader) for reliable preloading of files, as this crate does not deal with loading your assets. * or use [```bevy_asset_loader```](https://github.com/NiklasEi/bevy_asset_loader) for reliable preloading of files, as this crate does not deal with loading your assets.
* alternatively, use the [```bevy_gltf_blueprints```](https://crates.io/crates/bevy_gltf_blueprints) crate, built on this crate's features, * alternatively, use the [```bevy_gltf_blueprints```](https://crates.io/crates/bevy_gltf_blueprints) crate, built on this crate's features,
that allows you to directly spawn entities from gltf based blueprints. that allows you to directly spawn entities from gltf based blueprints.
@ -31,7 +31,7 @@ bevy_gltf_components = { version = "0.6"}
``` ```
```rust no_run ```rust no_run
//too barebones of an example to be meaningfull, please see https://github.com/kaosat-dev/Blender_bevy_components_workflow/bevy_gltf_components/examples/basic for a real example //too barebones of an example to be meaningfull, please see https://github.com/kaosat-dev/Blenvy/bevy_gltf_components/examples/basic for a real example
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
@ -86,7 +86,7 @@ Or disable the legacy mode: (enabled by default)
ComponentsFromGltfPlugin{legacy_mode: false} ComponentsFromGltfPlugin{legacy_mode: false}
``` ```
You **need** to disable legacy mode if you want to use the [```bevy_components```](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/bevy_components) Blender addon + the [```bevy_registry_export crate```](https://crates.io/crates/bevy_registry_export) ! You **need** to disable legacy mode if you want to use the [```bevy_components```](https://github.com/kaosat-dev/Blenvy/tree/main/tools/bevy_components) Blender addon + the [```bevy_registry_export crate```](https://crates.io/crates/bevy_registry_export) !
As it create custom properties that are writen in real **ron** file format As it create custom properties that are writen in real **ron** file format
instead of a simplified version (the one in the legacy mode) instead of a simplified version (the one in the legacy mode)
@ -118,7 +118,7 @@ Typically , the order of systems should be
## Examples ## Examples
https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_components/basic https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_components/basic

View File

@ -1,6 +1,6 @@
[![Crates.io](https://img.shields.io/crates/v/bevy_registry_export)](https://crates.io/crates/bevy_registry_export) [![Crates.io](https://img.shields.io/crates/v/bevy_registry_export)](https://crates.io/crates/bevy_registry_export)
[![Docs](https://img.shields.io/docsrs/bevy_registry_export)](https://docs.rs/bevy_registry_export/latest/bevy_registry_export/) [![Docs](https://img.shields.io/docsrs/bevy_registry_export)](https://docs.rs/bevy_registry_export/latest/bevy_registry_export/)
[![License](https://img.shields.io/crates/l/bevy_registry_export)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/crates/bevy_registry_export/License.md) [![License](https://img.shields.io/crates/l/bevy_registry_export)](https://github.com/kaosat-dev/Blenvy/blob/main/crates/bevy_registry_export/License.md)
[![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) [![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)
# bevy_registry_export (deprecated in favor of Blenvy) # bevy_registry_export (deprecated in favor of Blenvy)
@ -9,7 +9,7 @@
This plugin allows you to create a Json export of all your components/ registered types. This plugin allows you to create a Json export of all your components/ registered types.
Its main use case is as a backbone for the [```bevy_components``` Blender add-on](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/bevy_components), that allows you to add & edit components directly in Blender, using the actual type definitions from Bevy Its main use case is as a backbone for the [```bevy_components``` Blender add-on](https://github.com/kaosat-dev/Blenvy/tree/main/tools/bevy_components), that allows you to add & edit components directly in Blender, using the actual type definitions from Bevy
(and any of your custom types & components that you register in Bevy). (and any of your custom types & components that you register in Bevy).
@ -39,7 +39,7 @@ fn main() {
``` ```
take a look at the [example](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_registry_export/basic/src/core/mod.rs) for more clarity take a look at the [example](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_registry_export/basic/src/core/mod.rs) for more clarity
## Installation ## Installation
@ -105,7 +105,7 @@ All examples are here:
> the examples use ```bevy_gltf_blueprints``` with the **legacy_mode** set to **FALSE** as the new custom properties generated by the Blender add-on require newer/ non legacy logic. > the examples use ```bevy_gltf_blueprints``` with the **legacy_mode** set to **FALSE** as the new custom properties generated by the Blender add-on require newer/ non legacy logic.
- https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_registry_export/basic - https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_registry_export/basic
## Compatible Bevy versions ## Compatible Bevy versions

View File

@ -1,6 +1,6 @@
[![Crates.io](https://img.shields.io/crates/v/bevy_gltf_save_load)](https://crates.io/crates/bevy_gltf_save_load) [![Crates.io](https://img.shields.io/crates/v/bevy_gltf_save_load)](https://crates.io/crates/bevy_gltf_save_load)
[![Docs](https://img.shields.io/docsrs/bevy_gltf_save_load)](https://docs.rs/bevy_gltf_save_load/latest/bevy_gltf_save_load/) [![Docs](https://img.shields.io/docsrs/bevy_gltf_save_load)](https://docs.rs/bevy_gltf_save_load/latest/bevy_gltf_save_load/)
[![License](https://img.shields.io/crates/l/bevy_gltf_save_load)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/crates/bevy_gltf_save_load/License.md) [![License](https://img.shields.io/crates/l/bevy_gltf_save_load)](https://github.com/kaosat-dev/Blenvy/blob/main/crates/bevy_gltf_save_load/License.md)
[![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) [![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)
# bevy_gltf_save_load (deprecated in favor of Blenvy) # bevy_gltf_save_load (deprecated in favor of Blenvy)
@ -19,7 +19,7 @@ Built upon [bevy_gltf_blueprints](https://crates.io/crates/bevy_gltf_blueprints)
* ability to specify **which resources** to save or to exclude * ability to specify **which resources** to save or to exclude
* small(er) save files (only a portion of the entities is saved) * small(er) save files (only a portion of the entities is saved)
Particularly useful when using [Blender](https://www.blender.org/) as an editor for the [Bevy](https://bevyengine.org/) game engine, combined with the [Blender plugin](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/gltf_auto_export) that does a lot of the work for you (including spliting generating seperate gltf files for your static vs dynamic assets) Particularly useful when using [Blender](https://www.blender.org/) as an editor for the [Bevy](https://bevyengine.org/) game engine, combined with the [Blender plugin](https://github.com/kaosat-dev/Blenvy/tree/main/tools/gltf_auto_export) that does a lot of the work for you (including spliting generating seperate gltf files for your static vs dynamic assets)
A bit of heads up: A bit of heads up:
@ -135,7 +135,7 @@ pub fn setup_game(
``` ```
take a look at the [example](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/examples/bevy_gltf_save_load/basic/src/game/mod.rs) for more clarity take a look at the [example](https://github.com/kaosat-dev/Blenvy/blob/main/examples/bevy_gltf_save_load/basic/src/game/mod.rs) for more clarity
## Installation ## Installation
@ -265,7 +265,7 @@ pub fn request_load(
- ```LoadingFinished``` for loading - ```LoadingFinished``` for loading
> Note: I **highly** recomend you change states when you start/finish saving & loading, otherwise things **will** get unpredictable > Note: I **highly** recomend you change states when you start/finish saving & loading, otherwise things **will** get unpredictable
Please see [the example](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_save_load/basic/src/game/mod.rs) for this. Please see [the example](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_save_load/basic/src/game/mod.rs) for this.
## Additional notes ## Additional notes
@ -284,13 +284,13 @@ For convenience ```bevy_gltf_save_load``` provides two **SystemSets**
Highly advised to get a better understanding of how things work ! Highly advised to get a better understanding of how things work !
To get started I recomend looking at To get started I recomend looking at
- [world setup](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_save_load/basic/src/game/in_game.rs) - [world setup](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_save_load/basic/src/game/in_game.rs)
- [various events & co](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_save_load/basic/src/game/mod.rs) - [various events & co](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_save_load/basic/src/game/mod.rs)
All examples are here: All examples are here:
- https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_gltf_save_load/basic - https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_gltf_save_load/basic
## Compatible Bevy versions ## Compatible Bevy versions

View File

@ -3,7 +3,7 @@ use bevy::utils::HashMap;
#[derive(Component, Reflect, Default, Debug)] #[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)] #[reflect(Component)]
/// storage for animations for a given entity's BLUEPRINT (ie for example a characters animations), essentially a clone of gltf's `named_animations` /// storage for animations for a given entity's BLUEPRINT (ie for example a characters animations)
pub struct BlueprintAnimations { pub struct BlueprintAnimations {
pub named_animations: HashMap<String, Handle<AnimationClip>>, pub named_animations: HashMap<String, Handle<AnimationClip>>,
pub named_indices: HashMap<String, AnimationNodeIndex>, pub named_indices: HashMap<String, AnimationNodeIndex>,
@ -24,8 +24,8 @@ pub struct BlueprintAnimationInfosLink(pub Entity);
#[derive(Component, Reflect, Default, Debug)] #[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)] #[reflect(Component)]
/// storage for scene level animations for a given entity (hierarchy), essentially a clone of gltf's `named_animations` /// storage for per instance / scene level animations for a given entity (hierarchy)
pub struct SceneAnimations { pub struct InstanceAnimations {
pub named_animations: HashMap<String, Handle<AnimationClip>>, pub named_animations: HashMap<String, Handle<AnimationClip>>,
pub named_indices: HashMap<String, AnimationNodeIndex>, pub named_indices: HashMap<String, AnimationNodeIndex>,
pub graph: Handle<AnimationGraph>, pub graph: Handle<AnimationGraph>,
@ -36,12 +36,12 @@ pub struct SceneAnimations {
/// so that the root entity knows which of its children contains an actualy `AnimationPlayer` component /// so that the root entity knows which of its children contains an actualy `AnimationPlayer` component
/// this is for convenience, because currently , Bevy's gltf parsing inserts `AnimationPlayers` "one level down" /// this is for convenience, because currently , Bevy's gltf parsing inserts `AnimationPlayers` "one level down"
/// ie armature/root for animated models, which means more complex queries to trigger animations that we want to avoid /// ie armature/root for animated models, which means more complex queries to trigger animations that we want to avoid
pub struct SceneAnimationPlayerLink(pub Entity); pub struct InstanceAnimationPlayerLink(pub Entity);
#[derive(Component, Debug)] #[derive(Component, Debug)]
/// Same as the above but for scene's `AnimationInfos` components which get added (on the Blender side) to the entities that actually have the animations /// Same as the above but for scene's `AnimationInfos` components which get added (on the Blender side) to the entities that actually have the animations
/// which often is not the Blueprint or blueprint instance entity itself. /// which often is not the Blueprint or blueprint instance entity itself.
pub struct SceneAnimationInfosLink(pub Entity); pub struct InstanceAnimationInfosLink(pub Entity);
/// Stores Animation information: name, frame informations etc /// Stores Animation information: name, frame informations etc
#[derive(Reflect, Default, Debug)] #[derive(Reflect, Default, Debug)]
@ -161,8 +161,8 @@ pub fn trigger_instance_animation_markers_events(
animation_infos: Query<( animation_infos: Query<(
Entity, Entity,
&AnimationMarkers, &AnimationMarkers,
&SceneAnimationPlayerLink, &InstanceAnimationPlayerLink,
&SceneAnimations, &InstanceAnimations,
&AnimationInfos, &AnimationInfos,
)>, )>,
animation_players: Query<&AnimationPlayer>, animation_players: Query<&AnimationPlayer>,

View File

@ -99,8 +99,10 @@ impl Plugin for BlueprintsPlugin {
.register_type::<BlueprintInfo>() .register_type::<BlueprintInfo>()
.register_type::<MaterialInfo>() .register_type::<MaterialInfo>()
.register_type::<SpawnBlueprint>() .register_type::<SpawnBlueprint>()
.register_type::<BlueprintInstanceDisabled>()
.register_type::<HideUntilReady>()
.register_type::<BlueprintAnimations>() .register_type::<BlueprintAnimations>()
.register_type::<SceneAnimations>() .register_type::<InstanceAnimations>()
.register_type::<AnimationInfo>() .register_type::<AnimationInfo>()
.register_type::<AnimationInfos>() .register_type::<AnimationInfos>()
.register_type::<Vec<AnimationInfo>>() .register_type::<Vec<AnimationInfo>>()
@ -113,7 +115,6 @@ impl Plugin for BlueprintsPlugin {
.register_type::<Vec<String>>() .register_type::<Vec<String>>()
.register_type::<BlueprintAssets>() .register_type::<BlueprintAssets>()
.register_type::<HashMap<String, Vec<String>>>() .register_type::<HashMap<String, Vec<String>>>()
.register_type::<HideUntilReady>()
.configure_sets( .configure_sets(
Update, Update,
(GltfBlueprintsSet::Spawn, GltfBlueprintsSet::AfterSpawn) (GltfBlueprintsSet::Spawn, GltfBlueprintsSet::AfterSpawn)
@ -128,7 +129,7 @@ impl Plugin for BlueprintsPlugin {
blueprints_assets_loaded, blueprints_assets_loaded,
blueprints_scenes_spawned, blueprints_scenes_spawned,
blueprints_cleanup_spawned_scene, blueprints_cleanup_spawned_scene,
// post process // beyond this point : post processing to finalize blueprint instances
inject_materials, inject_materials,
compute_scene_aabbs, // .run_if(aabbs_enabled), compute_scene_aabbs, // .run_if(aabbs_enabled),
blueprints_finalize_instances, blueprints_finalize_instances,
@ -145,6 +146,7 @@ impl Plugin for BlueprintsPlugin {
trigger_instance_animation_markers_events trigger_instance_animation_markers_events
), ),
) )
// hot reload // hot reload
.add_systems(Update, react_to_asset_changes.run_if(hot_reload)); .add_systems(Update, react_to_asset_changes.run_if(hot_reload));
} }

View File

@ -1,10 +1,10 @@
use std::path::PathBuf; use std::path::Path;
use bevy::{gltf::Gltf, prelude::*, scene::SceneInstance, utils::hashbrown::HashMap}; use bevy::{gltf::Gltf, prelude::*, scene::SceneInstance, utils::hashbrown::HashMap};
use serde_json::Value; use serde_json::Value;
use crate::{ use crate::{
AnimationInfos, AssetLoadTracker, AssetToBlueprintInstancesMapper, BlenvyConfig, BlueprintAnimationInfosLink, BlueprintAnimationPlayerLink, BlueprintAnimations, BlueprintAssets, BlueprintAssetsLoadState, BlueprintAssetsLoaded, BlueprintAssetsNotLoaded, SceneAnimationInfosLink, SceneAnimationPlayerLink, SceneAnimations AnimationInfos, AssetLoadTracker, AssetToBlueprintInstancesMapper, BlenvyConfig, BlueprintAnimationInfosLink, BlueprintAnimationPlayerLink, BlueprintAnimations, BlueprintAssets, BlueprintAssetsLoadState, BlueprintAssetsLoaded, BlueprintAssetsNotLoaded, InstanceAnimationInfosLink, InstanceAnimationPlayerLink, InstanceAnimations, WatchingForChanges
}; };
/// this is a flag component for our levels/game world /// this is a flag component for our levels/game world
@ -20,7 +20,6 @@ pub struct BlueprintInfo {
pub name: String, pub name: String,
pub path: String, pub path: String,
} }
use std::path::Path;
impl BlueprintInfo { impl BlueprintInfo {
pub fn from_path(path: &str) -> BlueprintInfo { pub fn from_path(path: &str) -> BlueprintInfo {
@ -39,9 +38,15 @@ pub struct SpawnBlueprint;
#[derive(Component, Reflect, Default, Debug)] #[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)] #[reflect(Component)]
/// flag component marking any spwaned child of blueprints /// flag component marking any spawned child of blueprints
pub struct FromBlueprint; pub struct FromBlueprint;
// TODO: move to save_load
#[derive(Component, Reflect, Debug, Default)]
#[reflect(Component)]
/// component used to mark any entity as Dynamic: aka add this to make sure your entity is going to be saved
pub struct DynamicBlueprintInstance;
#[derive(Component, Reflect, Default, Debug)] #[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)] #[reflect(Component)]
/// flag component to force adding newly spawned entity as child of game world /// flag component to force adding newly spawned entity as child of game world
@ -58,7 +63,8 @@ pub(crate) struct OriginalChildren(pub Vec<Entity>);
/// as it would first become invisible before re-appearing again /// as it would first become invisible before re-appearing again
pub struct HideUntilReady; pub struct HideUntilReady;
#[derive(Component)] #[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
/// marker component, gets added to all children of a currently spawning blueprint instance, can be usefull to avoid manipulating still in progress entities /// marker component, gets added to all children of a currently spawning blueprint instance, can be usefull to avoid manipulating still in progress entities
pub struct BlueprintInstanceDisabled; pub struct BlueprintInstanceDisabled;
@ -83,13 +89,7 @@ pub enum BlueprintEvent {
}, },
} }
// TODO: move this somewhere else ?
#[derive(Component, Reflect, Debug, Default)]
#[reflect(Component)]
/// component used to mark any entity as Dynamic: aka add this to make sure your entity is going to be saved
pub struct DynamicBlueprintInstance;
// TODO: move these somewhere else ?
#[derive(Component, Reflect, Debug, Default)] #[derive(Component, Reflect, Debug, Default)]
#[reflect(Component)] #[reflect(Component)]
/// component gets added when a blueprint starts spawning, removed when spawning is completely done /// component gets added when a blueprint starts spawning, removed when spawning is completely done
@ -98,8 +98,6 @@ pub struct BlueprintSpawning;
use gltf::Gltf as RawGltf; use gltf::Gltf as RawGltf;
/* /*
Overview of the Blueprint Spawning process Overview of the Blueprint Spawning process
- Blueprint Load Assets - Blueprint Load Assets
@ -118,23 +116,22 @@ Overview of the Blueprint Spawning process
pub(crate) fn blueprints_prepare_spawn( pub(crate) fn blueprints_prepare_spawn(
blueprint_instances_to_spawn: Query< blueprint_instances_to_spawn: Query<
(Entity, &BlueprintInfo, Option<&Name>), (Entity, &BlueprintInfo),
Added<SpawnBlueprint>, Added<SpawnBlueprint>,
>, >,
mut commands: Commands, mut commands: Commands,
asset_server: Res<AssetServer>, asset_server: Res<AssetServer>,
// for hot reload // for hot reload
watching_for_changes: Res<WatchingForChanges>,
mut assets_to_blueprint_instances: ResMut<AssetToBlueprintInstancesMapper>, mut assets_to_blueprint_instances: ResMut<AssetToBlueprintInstancesMapper>,
// for debug // for debug
all_names: Query<&Name> // all_names: Query<&Name>
) { ) {
for (entity, blueprint_info, entity_name) in blueprint_instances_to_spawn.iter() { for (entity, blueprint_info) in blueprint_instances_to_spawn.iter() {
info!( info!(
"BLUEPRINT: to spawn detected: {:?} path:{:?}", "BLUEPRINT: to spawn detected: {:?} path:{:?}",
blueprint_info.name, blueprint_info.path blueprint_info.name, blueprint_info.path
); );
//println!("all assets {:?}", all_assets);
//////////////
// we add the asset of the blueprint itself // we add the asset of the blueprint itself
// TODO: add detection of already loaded data // TODO: add detection of already loaded data
let untyped_handle = asset_server.load_untyped(&blueprint_info.path); let untyped_handle = asset_server.load_untyped(&blueprint_info.path);
@ -167,7 +164,6 @@ pub(crate) fn blueprints_prepare_spawn(
// println!("all_assets {:?}", all_assets); // println!("all_assets {:?}", all_assets);
for asset in all_assets.assets.iter() { for asset in all_assets.assets.iter() {
println!("ASSET {}",asset.path);
let untyped_handle = asset_server.load_untyped(&asset.path); let untyped_handle = asset_server.load_untyped(&asset.path);
let asset_id = untyped_handle.id(); let asset_id = untyped_handle.id();
let loaded = asset_server.is_loaded_with_dependencies(asset_id); let loaded = asset_server.is_loaded_with_dependencies(asset_id);
@ -184,15 +180,19 @@ pub(crate) fn blueprints_prepare_spawn(
// FIXME: dang, too early, asset server has not yet started loading yet // FIXME: dang, too early, asset server has not yet started loading yet
// let path_id = asset_server.get_path_id(&asset.path).expect("we should have alread checked for this asset"); // let path_id = asset_server.get_path_id(&asset.path).expect("we should have alread checked for this asset");
let path_id = asset.path.clone(); let path_id = asset.path.clone();
// TODO: make this dependant on if hot reload is enabled or not
if !assets_to_blueprint_instances.untyped_id_to_blueprint_entity_ids.contains_key(&path_id) { // Only do this if hot reload is enabled
assets_to_blueprint_instances.untyped_id_to_blueprint_entity_ids.insert(path_id.clone(), vec![]); if watching_for_changes.0 {
} if !assets_to_blueprint_instances.untyped_id_to_blueprint_entity_ids.contains_key(&path_id) {
// only insert if not already present in mapping assets_to_blueprint_instances.untyped_id_to_blueprint_entity_ids.insert(path_id.clone(), vec![]);
if !assets_to_blueprint_instances.untyped_id_to_blueprint_entity_ids[&path_id].contains(&entity) { }
println!("adding mapping between {} and entity {:?}", path_id, all_names.get(entity)); // only insert if not already present in mapping
assets_to_blueprint_instances.untyped_id_to_blueprint_entity_ids.get_mut(&path_id).unwrap().push(entity); if !assets_to_blueprint_instances.untyped_id_to_blueprint_entity_ids[&path_id].contains(&entity) {
// println!("adding mapping between {} and entity {:?}", path_id, all_names.get(entity));
assets_to_blueprint_instances.untyped_id_to_blueprint_entity_ids.get_mut(&path_id).unwrap().push(entity);
}
} }
} }
} }
} }
@ -231,6 +231,8 @@ pub(crate) fn blueprints_check_assets_loading(
asset_server: Res<AssetServer>, asset_server: Res<AssetServer>,
mut commands: Commands, mut commands: Commands,
mut blueprint_events: EventWriter<BlueprintEvent>, mut blueprint_events: EventWriter<BlueprintEvent>,
// for hot reload
watching_for_changes: Res<WatchingForChanges>,
) { ) {
for (entity, blueprint_info, mut assets_to_load) in blueprint_assets_to_load.iter_mut() { for (entity, blueprint_info, mut assets_to_load) in blueprint_assets_to_load.iter_mut() {
let mut all_loaded = true; let mut all_loaded = true;
@ -266,8 +268,12 @@ pub(crate) fn blueprints_check_assets_loading(
.entity(entity) .entity(entity)
.insert(BlueprintAssetsLoaded) .insert(BlueprintAssetsLoaded)
.remove::<BlueprintAssetsNotLoaded>() .remove::<BlueprintAssetsNotLoaded>()
//.remove::<BlueprintAssetsLoadState>() //REMOVE this component in release mode/ when hot reload is off, keep it for dev/hot reload
; ;
if !watching_for_changes.0 {
commands.entity(entity)
.remove::<BlueprintAssetsLoadState>(); //we REMOVE this component when in hot reload is OFF, as we
}
} }
} }
} }
@ -321,7 +327,7 @@ pub(crate) fn blueprints_assets_loaded(
); );
// info!("attempting to spawn {:?}", model_path); // info!("attempting to spawn {:?}", model_path);
let model_handle: Handle<Gltf> = asset_server.load(blueprint_info.path.clone()); // FIXME: kinda weird now let model_handle: Handle<Gltf> = asset_server.load(blueprint_info.path.clone());
let blueprint_gltf = assets_gltf.get(&model_handle).unwrap_or_else(|| { let blueprint_gltf = assets_gltf.get(&model_handle).unwrap_or_else(|| {
panic!( panic!(
@ -365,8 +371,8 @@ pub(crate) fn blueprints_assets_loaded(
} }
let graph = graphs.add(graph); let graph = graphs.add(graph);
println!("Named animations : {:?}", named_animations.keys()); //println!("Named animations : {:?}", named_animations.keys());
println!("ANIMATION INFOS: {:?}", animation_infos); //println!("ANIMATION INFOS: {:?}", animation_infos);
commands.entity(entity).insert(( commands.entity(entity).insert((
SceneBundle { SceneBundle {
@ -376,7 +382,7 @@ pub(crate) fn blueprints_assets_loaded(
}, },
OriginalChildren(original_children), OriginalChildren(original_children),
BlueprintAnimations { BlueprintAnimations {
// TODO: perhaps swap this out with SceneAnimations depending on whether we are spawning a level or a simple blueprint // TODO: perhaps swap this out with InstanceAnimations depending on whether we are spawning a level or a simple blueprint
// these are animations specific to the blueprint // these are animations specific to the blueprint
named_animations, named_animations,
named_indices, named_indices,
@ -472,11 +478,11 @@ pub(crate) fn blueprints_scenes_spawned(
if with_blueprint_infos.get(parent).is_ok() { if with_blueprint_infos.get(parent).is_ok() {
if parent == entity { if parent == entity {
//println!("yohoho"); //println!("yohoho");
println!( /*println!(
"Parent blueprint instance of {:?} is {:?}", "Parent blueprint instance of {:?} is {:?}",
all_names.get(child), all_names.get(child),
all_names.get(parent) all_names.get(parent)
); );*/
commands.entity(child).insert(SubBlueprintSpawnRoot(entity)); // Injecting to know which entity is the root commands.entity(child).insert(SubBlueprintSpawnRoot(entity)); // Injecting to know which entity is the root
@ -504,8 +510,6 @@ pub(crate) fn blueprints_scenes_spawned(
} }
} }
println!("sub blueprint instances {:?}", sub_blueprint_instance_names);
if tracker_data.keys().len() > 0 { if tracker_data.keys().len() > 0 {
commands.entity(entity).insert(SubBlueprintsSpawnTracker { commands.entity(entity).insert(SubBlueprintsSpawnTracker {
sub_blueprint_instances: tracker_data.clone(), sub_blueprint_instances: tracker_data.clone(),
@ -555,9 +559,9 @@ pub(crate) fn blueprints_cleanup_spawned_scene(
for (original, children, original_children, name, animations) in for (original, children, original_children, name, animations) in
blueprint_scenes.iter() blueprint_scenes.iter()
{ {
info!("YOOO ready !! removing empty nodes {:?}", name); info!("Cleaning up spawned scene {:?}", name);
if children.len() == 0 { if children.len() == 0 { // TODO: investigate, Honestly not sure if this issue from Bevy 0.12 is still present at all anymore
warn!("timing issue ! no children found, please restart your bevy app (bug being investigated)"); warn!("timing issue ! no children found, please restart your bevy app (bug being investigated)");
continue; continue;
} }
@ -617,7 +621,7 @@ pub(crate) fn blueprints_cleanup_spawned_scene(
.insert((transitions, animations.graph.clone())); .insert((transitions, animations.graph.clone()));
} }
} }
// VERY convoluted, but it works // FIXME VERY convoluted, but it works
for child in all_children.iter_descendants(blueprint_root_entity) { for child in all_children.iter_descendants(blueprint_root_entity) {
if with_animation_infos.get(child).is_ok() { if with_animation_infos.get(child).is_ok() {
// player is already on the same entity as the animation_infos // player is already on the same entity as the animation_infos
@ -630,26 +634,26 @@ pub(crate) fn blueprints_cleanup_spawned_scene(
); );
commands commands
.entity(original) .entity(original)
.insert(( .insert(
//BlueprintAnimationPlayerLink(bla), //BlueprintAnimationPlayerLink(bla),
BlueprintAnimationInfosLink(child) BlueprintAnimationInfosLink(child)
)) )
; ;
} else { } else {
for parent in all_parents.iter_ancestors(child) { for parent in all_parents.iter_ancestors(child) {
if animation_players.get(parent).is_ok() { if animation_players.get(parent).is_ok() {
println!( /*println!(
"found SCENE animation player for {:?} at {:?} Root: {:?}", "found SCENE animation player for {:?} at {:?} Root: {:?}",
all_names.get(child), all_names.get(child),
all_names.get(parent), all_names.get(parent),
all_names.get(original) all_names.get(original)
); );
println!("INSERTING SCENE ANIMATIONS INTO"); println!("INSERTING SCENE ANIMATIONS INTO");*/
let original_animations = anims.get(original).unwrap(); let original_animations = anims.get(original).unwrap();
commands.entity(child).insert(( commands.entity(child).insert((
SceneAnimationPlayerLink(parent), InstanceAnimationPlayerLink(parent),
SceneAnimations { InstanceAnimations {
named_animations: original_animations named_animations: original_animations
.named_animations .named_animations
.clone(), .clone(),
@ -659,7 +663,7 @@ pub(crate) fn blueprints_cleanup_spawned_scene(
)); ));
} }
if with_animation_infos.get(parent).is_ok() { if with_animation_infos.get(parent).is_ok() {
commands.entity(child).insert(SceneAnimationInfosLink(parent)); commands.entity(child).insert(InstanceAnimationInfosLink(parent));
} }
} }
@ -703,8 +707,7 @@ pub(crate) fn blueprints_finalize_instances(
all_children: Query<&Children>, all_children: Query<&Children>,
mut blueprint_events: EventWriter<BlueprintEvent>, mut blueprint_events: EventWriter<BlueprintEvent>,
mut commands: Commands, mut commands: Commands,
// all_names: Query<&Name>
all_names: Query<&Name>
) { ) {
for (entity, name, blueprint_info, parent_blueprint, hide_until_ready) in for (entity, name, blueprint_info, parent_blueprint, hide_until_ready) in
blueprint_instances.iter() blueprint_instances.iter()
@ -744,11 +747,9 @@ pub(crate) fn blueprints_finalize_instances(
} }
} }
if all_spawned { if all_spawned {
// let root_name = all_names.get(track_root.0);
let root_name = all_names.get(track_root.0); // println!("ALLLLL SPAAAAWNED for {} named {:?}", track_root.0, root_name);
println!("ALLLLL SPAAAAWNED for {} named {:?}", track_root.0, root_name); commands.entity(track_root.0).insert(BlueprintChildrenReady);
commands.entity(track_root.0).insert(BlueprintChildrenReady);
} }
} }
} }

View File

@ -21,7 +21,7 @@ use bevy::{
/// ``` /// ```
/// # use bevy::prelude::*; /// # use bevy::prelude::*;
/// # use bevy::gltf::*; /// # use bevy::gltf::*;
/// # use bevy_gltf_components::ComponentsFromGltfPlugin; /// # use blenvy::ComponentsFromGltfPlugin;
/// ///
/// //too barebones of an example to be meaningfull, please see https://github.com/kaosat-dev/Blenvy/examples/basic for a real example /// //too barebones of an example to be meaningfull, please see https://github.com/kaosat-dev/Blenvy/examples/basic for a real example
/// fn main() { /// fn main() {

View File

@ -1,5 +1,5 @@
use bevy::{prelude::*, scene::SceneInstance}; use bevy::{prelude::*, scene::SceneInstance};
use bevy_gltf_blueprints::{BluePrintBundle, BlueprintName, GameWorldTag, Library}; use blenvy::{BluePrintBundle, BlueprintName, GameWorldTag, Library};
use std::path::Path; use std::path::Path;
use crate::{DynamicEntitiesRoot, SaveLoadConfig, StaticEntitiesRoot, StaticEntitiesStorage}; use crate::{DynamicEntitiesRoot, SaveLoadConfig, StaticEntitiesRoot, StaticEntitiesStorage};

View File

@ -12,7 +12,7 @@ pub use loading::*;
use bevy::core_pipeline::core_3d::{Camera3dDepthTextureUsage, ScreenSpaceTransmissionQuality}; use bevy::core_pipeline::core_3d::{Camera3dDepthTextureUsage, ScreenSpaceTransmissionQuality};
use bevy::prelude::*; use bevy::prelude::*;
use bevy::prelude::{App, IntoSystemConfigs, Plugin}; use bevy::prelude::{App, IntoSystemConfigs, Plugin};
use bevy_gltf_blueprints::GltfBlueprintsSet; use blenvy::GltfBlueprintsSet;
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)] #[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
pub enum SavingSet { pub enum SavingSet {

View File

@ -4,3 +4,4 @@ use bevy::prelude::*;
#[reflect(Component)] #[reflect(Component)]
/// component used to mark any entity as Dynamic: aka add this to make sure your entity is going to be saved /// component used to mark any entity as Dynamic: aka add this to make sure your entity is going to be saved
pub struct Dynamic(pub bool); pub struct Dynamic(pub bool);

View File

@ -1,6 +1,6 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy::tasks::IoTaskPool; use bevy::tasks::IoTaskPool;
use bevy_gltf_blueprints::{BlueprintName, InBlueprint, Library, SpawnHere}; use blenvy::{BlueprintName, InBlueprint, Library, SpawnHere};
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;

View File

@ -6,5 +6,5 @@ license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.14", features = ["dynamic_linking"] }
blenvy = { path = "../../../crates/blenvy" } blenvy = { path = "../../crates/blenvy" }
rand = "0.8.5" rand = "0.8.5"

View File

@ -12264,11 +12264,11 @@
"type": "object", "type": "object",
"typeInfo": "Struct" "typeInfo": "Struct"
}, },
"blenvy::blueprints::animation::SceneAnimations": { "blenvy::blueprints::animation::InstanceAnimations": {
"additionalProperties": false, "additionalProperties": false,
"isComponent": true, "isComponent": true,
"isResource": false, "isResource": false,
"long_name": "blenvy::blueprints::animation::SceneAnimations", "long_name": "blenvy::blueprints::animation::InstanceAnimations",
"properties": { "properties": {
"graph": { "graph": {
"type": { "type": {
@ -12291,7 +12291,7 @@
"named_indices", "named_indices",
"graph" "graph"
], ],
"short_name": "SceneAnimations", "short_name": "InstanceAnimations",
"type": "object", "type": "object",
"typeInfo": "Struct" "typeInfo": "Struct"
}, },

View File

@ -6,5 +6,5 @@ license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.14", features = ["dynamic_linking"] }
blenvy = { path = "../../../crates/blenvy" } blenvy = { path = "../../crates/blenvy" }
rand = "0.8.5" rand = "0.8.5"

View File

@ -1,10 +1,10 @@
# Materials example/demo # Blueprints example
Example of blueprints :
- how to use them to spawn levels
- how to use them to spawn dynamic entities
Example of materials use & reuse (including textures) to avoid redundant materials in blueprints gltfs that lead to asset & memory bloat
- to be used together with ```blenvy``` version >0.6 with the "materials library" option for exports
- It shows you how ou can configure```Bevy_gltf_blueprints``` to support material libraries
- material library is [here](./assets/materials/)
## Running this example ## Running this example

View File

@ -6,4 +6,4 @@ license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.14", features = ["dynamic_linking"] }
blenvy = { path = "../../../crates/blenvy" } blenvy = { path = "../../crates/blenvy" }

View File

@ -1,14 +1,7 @@
# Basic physics example/demo # Basic physics example/demo
This example showcases various components & blueprints extracted from the gltf files, including physics colliders & rigid bodies This example showcases various Bevy components added to objects/ blueprints/ meshes and materials extracted from the gltf files
## Notes Workflow with blender / demo information
This example, is actually closer to a boilerplate + tooling showcases how to use a minimalistic [Blender](https://www.blender.org/) (gltf) centric workflow for [Bevy](https://bevyengine.org/), ie defining entites & their components
inside Blender using Blender's objects **custom properties**.
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 .
## Running this example ## Running this example
@ -50,4 +43,3 @@ run a web server in the current folder, and navigate to the page, you should see
## Additional notes ## Additional notes
* You usually define either the Components directly or use ```Proxy components``` that get replaced in Bevy systems with the actual Components that you want (usually when for some reason, ie external crates with unregistered components etc) you cannot use the components directly. * You usually define either the Components directly or use ```Proxy components``` that get replaced in Bevy systems with the actual Components that you want (usually when for some reason, ie external crates with unregistered components etc) you cannot use the components directly.
* this example contains code for future features, not finished yet ! please disregard anything related to saving & loading

View File

@ -12264,11 +12264,11 @@
"type": "object", "type": "object",
"typeInfo": "Struct" "typeInfo": "Struct"
}, },
"blenvy::blueprints::animation::SceneAnimations": { "blenvy::blueprints::animation::InstanceAnimations": {
"additionalProperties": false, "additionalProperties": false,
"isComponent": true, "isComponent": true,
"isResource": false, "isResource": false,
"long_name": "blenvy::blueprints::animation::SceneAnimations", "long_name": "blenvy::blueprints::animation::InstanceAnimations",
"properties": { "properties": {
"graph": { "graph": {
"type": { "type": {
@ -12291,7 +12291,7 @@
"named_indices", "named_indices",
"graph" "graph"
], ],
"short_name": "SceneAnimations", "short_name": "InstanceAnimations",
"type": "object", "type": "object",
"typeInfo": "Struct" "typeInfo": "Struct"
}, },

View File

@ -6,6 +6,6 @@ license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.14", features = ["dynamic_linking"] }
blenvy = { path = "../../../crates/blenvy" } blenvy = { path = "../../crates/blenvy" }
bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] } bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5" rand = "0.8.5"

View File

@ -5,7 +5,7 @@ pub mod camera_replace_proxies;
pub use camera_replace_proxies::*; pub use camera_replace_proxies::*;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_gltf_blueprints::GltfBlueprintsSet; use blenvy::GltfBlueprintsSet;
pub struct CameraPlugin; pub struct CameraPlugin;
impl Plugin for CameraPlugin { impl Plugin for CameraPlugin {

View File

@ -1,5 +1,5 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy_gltf_blueprints::*; use blenvy::*;
pub struct CorePlugin; pub struct CorePlugin;
impl Plugin for CorePlugin { impl Plugin for CorePlugin {

View File

@ -7,7 +7,7 @@ pub(crate) mod controls;
pub(crate) use controls::*; pub(crate) use controls::*;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_gltf_blueprints::GltfBlueprintsSet; use blenvy::GltfBlueprintsSet;
use bevy_gltf_worlflow_examples_common::state::GameState; use bevy_gltf_worlflow_examples_common::state::GameState;
use bevy_rapier3d::{ use bevy_rapier3d::{
prelude::{NoUserData, RapierPhysicsPlugin}, prelude::{NoUserData, RapierPhysicsPlugin},

View File

@ -9,7 +9,7 @@ pub(crate) use controls::*;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_xpbd_3d::prelude::*; use bevy_xpbd_3d::prelude::*;
use bevy_gltf_blueprints::GltfBlueprintsSet; use blenvy::GltfBlueprintsSet;
use bevy_gltf_worlflow_examples_common::state::GameState; use bevy_gltf_worlflow_examples_common::state::GameState;
pub(crate) fn plugin(app: &mut App) { pub(crate) fn plugin(app: &mut App) {

View File

@ -1,5 +1,5 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy_gltf_blueprints::{BluePrintBundle, BlueprintName, GameWorldTag}; use blenvy::{BluePrintBundle, BlueprintName, GameWorldTag};
use bevy_gltf_worlflow_examples_common_rapier::{assets::GameAssets, GameState, InAppRunning}; use bevy_gltf_worlflow_examples_common_rapier::{assets::GameAssets, GameState, InAppRunning};
use bevy_rapier3d::prelude::Velocity; use bevy_rapier3d::prelude::Velocity;

View File

@ -1,5 +1,5 @@
use bevy::{gltf::Gltf, prelude::*}; use bevy::{gltf::Gltf, prelude::*};
use bevy_gltf_blueprints::GameWorldTag; use blenvy::GameWorldTag;
use bevy_gltf_worlflow_examples_common_rapier::{ use bevy_gltf_worlflow_examples_common_rapier::{
assets::GameAssets, GameState, InAppRunning, Player, assets::GameAssets, GameState, InAppRunning, Player,
}; };

View File

@ -1,6 +1,6 @@
use crate::Player; use crate::Player;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_gltf_blueprints::GltfBlueprintsSet; use blenvy::GltfBlueprintsSet;
#[derive(Component, Reflect, Default, Debug)] #[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)] #[reflect(Component)]

View File

@ -1,5 +1,4 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy_gltf_worlflow_examples_common_rapier::CommonPlugin;
mod core; mod core;
use crate::core::*; use crate::core::*;
@ -15,7 +14,6 @@ fn main() {
.add_plugins(( .add_plugins((
DefaultPlugins.set(AssetPlugin::default()), DefaultPlugins.set(AssetPlugin::default()),
// our custom plugins // our custom plugins
CommonPlugin,
CorePlugin, // reusable plugins CorePlugin, // reusable plugins
GamePlugin, // specific to our game GamePlugin, // specific to our game
ComponentsTestPlugin, // Showcases different type of components /structs ComponentsTestPlugin, // Showcases different type of components /structs

View File

@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.14", features = ["dynamic_linking"] }
blenvy = { path = "../../../crates/blenvy" } blenvy = { path = "../../crates/blenvy" }
serde_json = "1.0.108" serde_json = "1.0.108"
serde = "1.0.193" serde = "1.0.193"

View File

@ -1,6 +1,6 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy_gltf_blueprints::{BluePrintBundle, BlueprintName, GameWorldTag, Library, NoInBlueprint}; use blenvy::{BluePrintBundle, BlueprintName, GameWorldTag, Library, NoInBlueprint};
use bevy_gltf_save_load::{Dynamic, DynamicEntitiesRoot, StaticEntitiesRoot}; use blenvy::{Dynamic, DynamicEntitiesRoot, StaticEntitiesRoot};
use bevy_gltf_worlflow_examples_common_rapier::{GameState, InAppRunning, Player}; use bevy_gltf_worlflow_examples_common_rapier::{GameState, InAppRunning, Player};
use bevy_rapier3d::prelude::Velocity; use bevy_rapier3d::prelude::Velocity;
use rand::Rng; use rand::Rng;

View File

@ -12,7 +12,7 @@ pub mod in_game_saving;
pub use in_game_saving::*; pub use in_game_saving::*;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_gltf_save_load::{LoadRequest, LoadingFinished, SaveRequest, SavingFinished}; use blenvy::{LoadRequest, LoadingFinished, SaveRequest, SavingFinished};
pub fn request_save( pub fn request_save(
mut save_requests: EventWriter<SaveRequest>, mut save_requests: EventWriter<SaveRequest>,

View File

@ -1,8 +1,8 @@
# Bevy registry export example/demo # Bevy registry export example/demo
This example showcases This example showcases
* the use of the bevy_registry_export crate to extract all components & types information into a json file. * the use of the blenvy crate to extract all components & types information into a json file.
* That file is then used by the [Blender addon](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/bevy_components) to create Uis for each component, * That file is then used by the [Blender addon](https://github.com/kaosat-dev/Blenvy/tree/main/tools/bevy_components) to create Uis for each component,
to be able to add & edit Bevy components easilly in Blender ! to be able to add & edit Bevy components easilly in Blender !

View File

@ -3,8 +3,8 @@ use std::any::TypeId;
use bevy::{prelude::*, utils::HashSet}; use bevy::{prelude::*, utils::HashSet};
use blenvy::*; use blenvy::*;
/*use bevy_gltf_blueprints::*; /*use blenvy::*;
use bevy_registry_export::*; */ use blenvy::*; */
use crate::{ComponentAToFilterOut, ComponentBToFilterOut}; use crate::{ComponentAToFilterOut, ComponentBToFilterOut};

View File

@ -1,15 +1,15 @@
use std::time::Duration; use std::time::Duration;
/*use bevy_gltf_blueprints::{ /*use blenvy::{
AnimationInfos, AnimationMarkerReached, BlueprintAnimationPlayerLink, BlueprintAnimations, AnimationInfos, AnimationMarkerReached, BlueprintAnimationPlayerLink, BlueprintAnimations,
SceneAnimationPlayerLink, SceneAnimations, InstanceAnimationPlayerLink, InstanceAnimations,
};*/ };*/
use bevy::{animation::RepeatAnimation, gltf::Gltf, prelude::*}; use bevy::{animation::RepeatAnimation, gltf::Gltf, prelude::*};
use blenvy::{ use blenvy::{
AnimationInfos, AnimationMarkerReached, BlueprintAnimationPlayerLink, BlueprintAnimations, AnimationInfos, AnimationMarkerReached, BlueprintAnimationPlayerLink, BlueprintAnimations,
BlueprintInstanceDisabled, SceneAnimationPlayerLink, SceneAnimations, BlueprintInstanceDisabled, InstanceAnimationPlayerLink, InstanceAnimations,
}; };
#[derive(Component, Reflect, Default, Debug)] #[derive(Component, Reflect, Default, Debug)]
@ -63,7 +63,7 @@ pub fn animations(
name, entity name, entity
); );
println!("Found match {:?}", gltf.named_animations); println!("Found match {:?}", gltf.named_animations);
commands.entity(entity).insert(SceneAnimations { commands.entity(entity).insert(InstanceAnimations {
named_animations: gltf.named_animations.clone(), named_animations: gltf.named_animations.clone(),
}); });
for ancestor in parents.iter_ancestors(entity) { for ancestor in parents.iter_ancestors(entity) {
@ -71,7 +71,7 @@ pub fn animations(
// println!("found match with animationPlayer !! {:?}",names.get(ancestor)); // println!("found match with animationPlayer !! {:?}",names.get(ancestor));
commands commands
.entity(entity) .entity(entity)
.insert(SceneAnimationPlayerLink(ancestor)); .insert(InstanceAnimationPlayerLink(ancestor));
} }
// info!("{:?} is an ancestor of {:?}", ancestor, player); // info!("{:?} is an ancestor of {:?}", ancestor, player);
} }
@ -85,7 +85,7 @@ pub fn check_animations(
( (
Entity, Entity,
Option<&BlueprintAnimationPlayerLink>, Option<&BlueprintAnimationPlayerLink>,
Option<&SceneAnimationPlayerLink>, Option<&InstanceAnimationPlayerLink>,
), ),
(With<MarkerAllFoxes>, Without<BlueprintInstanceDisabled>), (With<MarkerAllFoxes>, Without<BlueprintInstanceDisabled>),
>, >,
@ -94,7 +94,7 @@ pub fn check_animations(
( (
Entity, Entity,
Option<&BlueprintAnimationPlayerLink>, Option<&BlueprintAnimationPlayerLink>,
Option<&SceneAnimationPlayerLink>, Option<&InstanceAnimationPlayerLink>,
), ),
(With<Marker1>, Without<BlueprintInstanceDisabled>), (With<Marker1>, Without<BlueprintInstanceDisabled>),
>, >,
@ -102,7 +102,7 @@ pub fn check_animations(
( (
Entity, Entity,
Option<&BlueprintAnimationPlayerLink>, Option<&BlueprintAnimationPlayerLink>,
Option<&SceneAnimationPlayerLink>, Option<&InstanceAnimationPlayerLink>,
), ),
(With<Marker2>, Without<BlueprintInstanceDisabled>), (With<Marker2>, Without<BlueprintInstanceDisabled>),
>, >,
@ -110,7 +110,7 @@ pub fn check_animations(
( (
Entity, Entity,
Option<&BlueprintAnimationPlayerLink>, Option<&BlueprintAnimationPlayerLink>,
Option<&SceneAnimationPlayerLink>, Option<&InstanceAnimationPlayerLink>,
), ),
(With<Marker3>, Without<BlueprintInstanceDisabled>), (With<Marker3>, Without<BlueprintInstanceDisabled>),
>, >,
@ -153,19 +153,19 @@ pub fn play_animations(
>, >,
animated_marker1: Query< animated_marker1: Query<
(&SceneAnimationPlayerLink, &SceneAnimations), (&InstanceAnimationPlayerLink, &InstanceAnimations),
(With<AnimationInfos>, With<Marker1>), (With<AnimationInfos>, With<Marker1>),
>, >,
animated_marker2: Query< animated_marker2: Query<
(&SceneAnimationPlayerLink, &SceneAnimations), (&InstanceAnimationPlayerLink, &InstanceAnimations),
(With<AnimationInfos>, With<Marker2>), (With<AnimationInfos>, With<Marker2>),
>, >,
with_blueprint_and_scene_animations: Query< with_blueprint_and_scene_animations: Query<
( (
&SceneAnimationPlayerLink, &InstanceAnimationPlayerLink,
&SceneAnimations, &InstanceAnimations,
&BlueprintAnimationPlayerLink, &BlueprintAnimationPlayerLink,
&BlueprintAnimations, &BlueprintAnimations,
), ),

View File

@ -8,7 +8,7 @@ use std::{collections::HashMap, fs, time::Duration};
use blenvy::{ use blenvy::{
BlueprintAnimationPlayerLink, BlueprintAssets, BlueprintEvent, BlueprintInfo, BlueprintAnimationPlayerLink, BlueprintAssets, BlueprintEvent, BlueprintInfo,
GltfBlueprintsSet, SceneAnimations, GltfBlueprintsSet, InstanceAnimations,
}; };
use crate::{AppState, GameState}; use crate::{AppState, GameState};
@ -37,7 +37,7 @@ fn validate_export(
names: Query<&Name>, names: Query<&Name>,
blueprints: Query<(Entity, &Name, &BlueprintInfo)>, blueprints: Query<(Entity, &Name, &BlueprintInfo)>,
animation_player_links: Query<(Entity, &BlueprintAnimationPlayerLink)>, animation_player_links: Query<(Entity, &BlueprintAnimationPlayerLink)>,
scene_animations: Query<(Entity, &SceneAnimations)>, scene_animations: Query<(Entity, &InstanceAnimations)>,
empties_candidates: Query<(Entity, &Name, &GlobalTransform)>, empties_candidates: Query<(Entity, &Name, &GlobalTransform)>,
assets_list: Query<(Entity, &BlueprintAssets)>, assets_list: Query<(Entity, &BlueprintAssets)>,

View File

@ -10,11 +10,11 @@ You can enable this option to automatically replace all the **collection instanc
- this means you will have - this means you will have
* one small main gltf file (your level/world) * one small main gltf file (your level/world)
* as many gltf files as you have used collections in the level scene , in the library path you specified : * as many gltf files as you have used collections in the level scene , in the library path you specified :
for the included [basic](../../examples/bevy_gltf_blueprints/basic/) example's [assets](../../examples/bevy_gltf_blueprints/basic/assets/), it looks something like this: for the included [basic](../../examples/blenvy/basic/) example's [assets](../../examples/blenvy/basic/assets/), it looks something like this:
![library](./docs/exported_library_files.png) ![library](./docs/exported_library_files.png)
the .blend file that they are generated from can be found [here](../../examples/bevy_gltf_blueprints/basic/assets/advanced.blend) the .blend file that they are generated from can be found [here](../../examples/blenvy/basic/assets/advanced.blend)
- the above only applies to collections that have **instances** in your level scene! - the above only applies to collections that have **instances** in your level scene!
if you want a specific collection in your library to always get exported regardless of its use, you need to add if you want a specific collection in your library to always get exported regardless of its use, you need to add

View File

@ -1,7 +1,7 @@
# Blenvy: Blender add-on # Blenvy: Blender add-on
This [Blender addon](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/blenvy) gives you: This [Blender addon](https://github.com/kaosat-dev/Blenvy/tree/main/tools/blenvy) gives you:
- an easy to use UI to add and configure your [Bevy](https://bevyengine.org/) components inside Blender - an easy to use UI to add and configure your [Bevy](https://bevyengine.org/) components inside Blender
- the UI is **automatically generated** based on a **registry schema** file, an export of all your **registered** Bevy components's information, generated - the UI is **automatically generated** based on a **registry schema** file, an export of all your **registered** Bevy components's information, generated
by the registry export part of the [Blenvy](https://crates.io/crates/blenvy) crate by the registry export part of the [Blenvy](https://crates.io/crates/blenvy) crate

View File

@ -6,8 +6,8 @@ bl_info = {
"location": "File > Import-Export", "location": "File > Import-Export",
"description": "tooling for the Bevy engine", "description": "tooling for the Bevy engine",
"warning": "", "warning": "",
"wiki_url": "https://github.com/kaosat-dev/Blender_bevy_components_workflow", "wiki_url": "https://github.com/kaosat-dev/Blenvy",
"tracker_url": "https://github.com/kaosat-dev/Blender_bevy_components_workflow/issues/new", "tracker_url": "https://github.com/kaosat-dev/Blenvy/issues/new",
"category": "Import-Export" "category": "Import-Export"
} }

View File

@ -232,5 +232,5 @@ given object is located)
## Examples ## Examples
you can find an example [here](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/bevy_registry_export/) you can find an example [here](https://github.com/kaosat-dev/Blenvy/tree/main/examples/bevy_registry_export/)

View File

@ -83,18 +83,18 @@ expected_custom_property_values = {'bevy_animation::AnimationPlayer': '(animatio
'bevy_example::test_components::VecOfF32s': '([])', 'bevy_example::test_components::VecOfF32s': '([])',
'bevy_example::test_components::VecOfVec3s2': '([])', 'bevy_example::test_components::VecOfVec3s2': '([])',
'bevy_gltf::GltfExtras': '(value: " ")', 'bevy_gltf::GltfExtras': '(value: " ")',
'bevy_gltf_blueprints::animation::AnimationInfos': '(animations: [])', 'blenvy::animation::AnimationInfos': '(animations: [])',
'bevy_gltf_blueprints::animation::AnimationMarkers': '({})', 'blenvy::animation::AnimationMarkers': '({})',
'bevy_gltf_blueprints::animation::BlueprintAnimations': '(named_animations: "")', 'blenvy::animation::BlueprintAnimations': '(named_animations: "")',
'bevy_gltf_blueprints::animation::SceneAnimations': '(named_animations: "")', 'blenvy::animation::InstanceAnimations': '(named_animations: "")',
'bevy_gltf_blueprints::materials::MaterialInfo': '(name: " ", source: " ")', 'blenvy::materials::MaterialInfo': '(name: " ", source: " ")',
'bevy_gltf_blueprints::spawn_from_blueprints::BlueprintsList': '({})', 'blenvy::spawn_from_blueprints::BlueprintsList': '({})',
'bevy_gltf_blueprints::spawn_from_blueprints::SpawnBlueprint': '()', 'blenvy::spawn_from_blueprints::SpawnBlueprint': '()',
'bevy_gltf_components::GltfProcessed': '()', 'blenvy::GltfProcessed': '()',
'bevy_gltf_components::blender_settings::lighting::BlenderBackgroundShader': '(color: Rgba(red:1.0, green:1.0, ' 'blenvy::blender_settings::lighting::BlenderBackgroundShader': '(color: Rgba(red:1.0, green:1.0, '
'blue:0.0, alpha:1.0), strength: 0.0)', 'blue:0.0, alpha:1.0), strength: 0.0)',
'bevy_gltf_components::blender_settings::lighting::BlenderLightShadows': '(buffer_bias: 0.0, enabled: true)', 'blenvy::blender_settings::lighting::BlenderLightShadows': '(buffer_bias: 0.0, enabled: true)',
'bevy_gltf_components::blender_settings::lighting::BlenderShadowSettings': '(cascade_size: 0)', 'blenvy::blender_settings::lighting::BlenderShadowSettings': '(cascade_size: 0)',
'bevy_gltf_worlflow_examples_common::core::camera::camera_replace_proxies::SSAOSettings': '()', 'bevy_gltf_worlflow_examples_common::core::camera::camera_replace_proxies::SSAOSettings': '()',
'bevy_gltf_worlflow_examples_common::core::camera::camera_tracking::CameraTrackable': '()', 'bevy_gltf_worlflow_examples_common::core::camera::camera_tracking::CameraTrackable': '()',
'bevy_gltf_worlflow_examples_common::core::camera::camera_tracking::CameraTracking': '(offset: Vec3(x:0.0, y:0.0, ' 'bevy_gltf_worlflow_examples_common::core::camera::camera_tracking::CameraTracking': '(offset: Vec3(x:0.0, y:0.0, '
@ -338,25 +338,25 @@ expected_custom_property_values_randomized = {'bevy_animation::AnimationPlayer':
'bevy_example::test_components::VecOfVec3s2': '([(Vec3(x:0.42888906598091125, y:0.5780913233757019, ' 'bevy_example::test_components::VecOfVec3s2': '([(Vec3(x:0.42888906598091125, y:0.5780913233757019, '
'z:0.20609822869300842))])', 'z:0.20609822869300842))])',
'bevy_gltf::GltfExtras': '(value: "sbnpsago")', 'bevy_gltf::GltfExtras': '(value: "sbnpsago")',
'bevy_gltf_blueprints::animation::AnimationInfos': '(animations: [(frame_end: 0.42888906598091125, ' 'blenvy::animation::AnimationInfos': '(animations: [(frame_end: 0.42888906598091125, '
'frame_end_override: 0.5780913233757019, frame_start: ' 'frame_end_override: 0.5780913233757019, frame_start: '
'0.20609822869300842, frame_start_override: 0.8133212327957153, ' '0.20609822869300842, frame_start_override: 0.8133212327957153, '
'frames_length: 0.8235888481140137, name: "uzfbqpkc")])', 'frames_length: 0.8235888481140137, name: "uzfbqpkc")])',
'bevy_gltf_blueprints::animation::AnimationMarkers': '({})', 'blenvy::animation::AnimationMarkers': '({})',
'bevy_gltf_blueprints::animation::BlueprintAnimations': '(named_animations: "")', 'blenvy::animation::BlueprintAnimations': '(named_animations: "")',
'bevy_gltf_blueprints::animation::SceneAnimations': '(named_animations: "")', 'blenvy::animation::InstanceAnimations': '(named_animations: "")',
'bevy_gltf_blueprints::materials::MaterialInfo': '(name: "sbnpsago", source: "piuzfbqp")', 'blenvy::materials::MaterialInfo': '(name: "sbnpsago", source: "piuzfbqp")',
'bevy_gltf_blueprints::spawn_from_blueprints::BlueprintsList': '({})', 'blenvy::spawn_from_blueprints::BlueprintsList': '({})',
'bevy_gltf_blueprints::spawn_from_blueprints::SpawnBlueprint': '()', 'blenvy::spawn_from_blueprints::SpawnBlueprint': '()',
'bevy_gltf_components::GltfProcessed': '()', 'blenvy::GltfProcessed': '()',
'bevy_gltf_components::blender_settings::lighting::BlenderBackgroundShader': '(color: Rgba(red:0.5714026093482971, ' 'blenvy::blender_settings::lighting::BlenderBackgroundShader': '(color: Rgba(red:0.5714026093482971, '
'green:0.42888906598091125, ' 'green:0.42888906598091125, '
'blue:0.5780913233757019, ' 'blue:0.5780913233757019, '
'alpha:0.20609822869300842), strength: ' 'alpha:0.20609822869300842), strength: '
'0.8133212327957153)', '0.8133212327957153)',
'bevy_gltf_components::blender_settings::lighting::BlenderLightShadows': '(buffer_bias: 0.5714026093482971, enabled: ' 'blenvy::blender_settings::lighting::BlenderLightShadows': '(buffer_bias: 0.5714026093482971, enabled: '
'false)', 'false)',
'bevy_gltf_components::blender_settings::lighting::BlenderShadowSettings': '(cascade_size: 73)', 'blenvy::blender_settings::lighting::BlenderShadowSettings': '(cascade_size: 73)',
'bevy_gltf_worlflow_examples_common::core::camera::camera_replace_proxies::SSAOSettings': '()', 'bevy_gltf_worlflow_examples_common::core::camera::camera_replace_proxies::SSAOSettings': '()',
'bevy_gltf_worlflow_examples_common::core::camera::camera_tracking::CameraTrackable': '()', 'bevy_gltf_worlflow_examples_common::core::camera::camera_tracking::CameraTrackable': '()',
'bevy_gltf_worlflow_examples_common::core::camera::camera_tracking::CameraTracking': '(offset: ' 'bevy_gltf_worlflow_examples_common::core::camera::camera_tracking::CameraTracking': '(offset: '

View File

@ -13,11 +13,11 @@ def test_generate_example_gltf_files():
if __name__ == "__main__": if __name__ == "__main__":
examples = [ examples = [
'../examples/bevy_gltf_blueprints/basic', '../examples/blenvy/basic',
"""'../examples/bevy_gltf_blueprints/animation', """'../examples/blenvy/animation',
'../examples/bevy_gltf_blueprints/basic_xpbd_physics', '../examples/blenvy/basic_xpbd_physics',
'../examples/bevy_gltf_blueprints/materials', '../examples/blenvy/materials',
'../examples/bevy_gltf_blueprints/multiple_levels_multiple_blendfiles',""" '../examples/blenvy/multiple_levels_multiple_blendfiles',"""
] ]
for example_path in examples: for example_path in examples: