├── .github └── workflows │ └── ci.yml ├── .gitignore ├── Cargo.toml ├── FUNDING.yml ├── LICENSE.md ├── LICENSE_APACHE.md ├── LICENSE_MIT.md ├── Migration_guide.md ├── README-workflow-classic.md ├── README-workflow-ui.md ├── README.md ├── RELEASE_NOTES.md ├── TODO.md ├── crates └── blenvy │ ├── Cargo.toml │ ├── LICENSE.md │ ├── LICENSE_APACHE.md │ ├── LICENSE_MIT.md │ ├── README.md │ └── src │ ├── blueprints │ ├── aabb.rs │ ├── animation.rs │ ├── assets.rs │ ├── copy_components.rs │ ├── hot_reload.rs │ ├── materials.rs │ ├── mod.rs │ └── spawn_from_blueprints.rs │ ├── components │ ├── blender_settings.rs │ ├── blender_settings │ │ └── lighting.rs │ ├── mod.rs │ ├── process_gltfs.rs │ ├── ronstring_to_reflect_component.rs │ └── utils.rs │ ├── lib.rs │ ├── registry │ ├── export_types.rs │ └── mod.rs │ └── save_load │ ├── common.rs │ ├── loading.rs │ ├── mod.rs │ ├── old │ ├── loading.rs │ ├── mod_old.rs │ └── saving.rs │ └── saving.rs ├── docs ├── avian │ ├── README.md │ └── img │ │ ├── board.png │ │ ├── create_cylinder.png │ │ ├── create_cylinder_options.png │ │ ├── cube_primitive.png │ │ ├── cylinder_collider.png │ │ ├── cylinder_collider_on_mesh.png │ │ ├── data.png │ │ ├── dimensions.png │ │ ├── direct_in_world.png │ │ ├── dynamic.png │ │ ├── empty_child.png │ │ ├── empty_collections.png │ │ ├── empty_scaled.png │ │ ├── empty_selected.png │ │ ├── empty_world.png │ │ ├── falling.gif │ │ ├── falling_concave.gif │ │ ├── falling_convex.gif │ │ ├── falling_direct.gif │ │ ├── falling_direct_on_static.gif │ │ ├── falling_empty.gif │ │ ├── falling_wireframe.gif │ │ ├── ground collider.png │ │ ├── hiding.png │ │ ├── parenting.png │ │ ├── select_mesh.png │ │ ├── three_object_collection.png │ │ ├── torus.png │ │ ├── torus_component.png │ │ └── wireframe.png ├── bevy_components.png ├── blender_bevy.png ├── blender_collections.png ├── blender_gltf_components.png ├── camera_tracking_component.png ├── component_registration.png ├── component_warnings.png ├── components_bevy.png ├── components_bevy2.png ├── components_bevy3.png ├── components_blender.png ├── components_blender_parameters.png ├── components_blender_parameters2.png ├── demo_simple_components.png ├── gltf_export.png └── quickstart │ ├── README.md │ └── img │ ├── art_file_structure.png │ ├── blenvy_after_setup.png │ ├── blenvy_menu.png │ ├── blueprint_file.png │ ├── camera_transform.png │ ├── component_manager.png │ ├── create_scene.png │ ├── default_collection.png │ ├── final_bevy.png │ ├── final_blender.png │ ├── install.png │ ├── level_asset.png │ ├── lots_of_components.png │ ├── player_collection.png │ ├── player_component.png │ ├── registry.png │ ├── registry_settings.png │ ├── scene_name.png │ └── scenes.png ├── examples ├── README.md ├── animation │ ├── Cargo.toml │ ├── README.md │ ├── art │ │ └── animation.blend │ ├── assets │ │ ├── blueprints │ │ │ ├── Fox.glb │ │ │ ├── Player.glb │ │ │ └── Wheelbot.glb │ │ ├── levels │ │ │ └── World.glb │ │ └── registry.json │ └── src │ │ ├── component_examples.rs │ │ └── main.rs ├── blueprints │ ├── Cargo.toml │ ├── README.md │ ├── art │ │ ├── basic.blend │ │ └── materials.blend │ ├── assets │ │ ├── blueprints │ │ │ ├── Container.glb │ │ │ ├── Health_Pickup.glb │ │ │ ├── Magic Sphere.glb │ │ │ ├── MagicTeapot.glb │ │ │ ├── Pillar.glb │ │ │ ├── Pillar2.glb │ │ │ ├── Player.glb │ │ │ ├── Watermelon cut.glb │ │ │ ├── Watermelon.glb │ │ │ └── Watermelon2.glb │ │ ├── levels │ │ │ └── Level1.glb │ │ └── textures │ │ │ ├── juicy-watermelon-5882.png │ │ │ └── watermelon-6441.png │ └── src │ │ ├── component_examples.rs │ │ └── main.rs ├── components │ ├── Cargo.toml │ ├── README.md │ ├── art │ │ └── basic.blend │ ├── assets │ │ ├── blueprints │ │ │ ├── Container.glb │ │ │ ├── Enemy.glb │ │ │ ├── Finger.glb │ │ │ ├── Hand.glb │ │ │ ├── Health_Pickup.glb │ │ │ ├── Humanoid_cactus.glb │ │ │ ├── MagicTeapot.glb │ │ │ ├── Pillar.glb │ │ │ ├── Player.glb │ │ │ └── Unused_in_level_test.glb │ │ ├── levels │ │ │ └── World.glb │ │ └── registry.json │ ├── index.html │ └── src │ │ ├── component_examples.rs │ │ └── main.rs ├── demo │ ├── Cargo.toml │ ├── README.md │ ├── art │ │ ├── common.blend │ │ ├── level1.blend │ │ ├── level2.blend │ │ └── start_level.blend │ ├── assets │ │ ├── materials │ │ │ └── common_materials_library.glb │ │ └── models │ │ │ ├── Level1.glb │ │ │ ├── Level2.glb │ │ │ ├── StartLevel.glb │ │ │ └── library │ │ │ ├── Container.glb │ │ │ ├── Crystal.glb │ │ │ ├── Health_Pickup.glb │ │ │ ├── Interactible.glb │ │ │ ├── LevelTransition.glb │ │ │ ├── MagicTeapot.glb │ │ │ ├── Nest_test.glb │ │ │ ├── Pillar.glb │ │ │ ├── Player.glb │ │ │ ├── Portal.glb │ │ │ ├── Rock Pile.glb │ │ │ ├── Rock.glb │ │ │ ├── Sub_blueprint.glb │ │ │ ├── Template_Demo.glb │ │ │ ├── Unused_in_level_test.glb │ │ │ └── Wall.glb │ └── src │ │ ├── core │ │ ├── audio │ │ │ └── mod.rs │ │ ├── camera │ │ │ ├── camera_replace_proxies.rs │ │ │ ├── camera_tracking.rs │ │ │ └── mod.rs │ │ ├── mod.rs │ │ ├── physics_rapier │ │ │ ├── controls.rs │ │ │ ├── mod.rs │ │ │ ├── physics_replace_proxies.rs │ │ │ └── utils.rs │ │ ├── physics_xpbd │ │ │ ├── controls.rs │ │ │ ├── mod.rs │ │ │ ├── physics_replace_proxies.rs │ │ │ └── utils.rs │ │ └── relationships │ │ │ ├── mod.rs │ │ │ └── relationships_insert_dependant_components.rs │ │ ├── game │ │ ├── interactions │ │ │ └── mod.rs │ │ ├── level_transitions.rs │ │ ├── mod.rs │ │ ├── picking │ │ │ └── mod.rs │ │ └── player │ │ │ └── mod.rs │ │ ├── main.rs │ │ ├── state.rs │ │ └── test_components.rs └── save_load │ ├── Cargo.toml │ ├── README.md │ ├── art │ └── save_load.blend │ ├── assets │ ├── .save.ron │ ├── blueprints │ │ ├── Dynamic_hierarchy.glb │ │ ├── Dynamic_hierarchy.meta.ron │ │ ├── Dynamic_inside_static.glb │ │ ├── Dynamic_inside_static.meta.ron │ │ ├── Mover.glb │ │ ├── Mover.meta.ron │ │ ├── Pillar.glb │ │ └── Pillar.meta.ron │ ├── levels │ │ ├── World.glb │ │ ├── World.meta.ron │ │ └── World_dynamic.glb │ ├── materials │ │ ├── Dots Stroke.glb │ │ ├── Material.001.glb │ │ └── Stone.glb │ ├── registry.json │ └── scenes │ │ ├── save.scn.ron │ │ └── save.scn.ron.save.ron │ └── src │ ├── component_examples.rs │ ├── game │ ├── in_game.rs │ ├── in_game_loading.rs │ ├── in_game_saving.rs │ ├── in_main_menu.rs │ └── mod.rs │ └── main.rs ├── rust-toolchain.toml ├── testing └── bevy_example │ ├── Cargo.toml │ ├── README.md │ ├── art │ ├── testing.blend │ ├── testing_library.blend │ └── testing_simple.blend │ ├── assets │ ├── assets_core.assets.ron │ ├── assets_game.assets.ron │ ├── audio │ │ ├── assets_sounds_breakout_collision.ogg │ │ └── fake.mp3 │ ├── registry.json │ └── text │ │ └── test.txt │ └── src │ ├── core │ └── mod.rs │ ├── dupe_components │ └── mod.rs │ ├── game │ ├── animation.rs │ ├── in_game.rs │ └── mod.rs │ ├── hierarchy_debug.rs │ ├── main.rs │ ├── state.rs │ └── test_components.rs └── tools ├── blenvy ├── README-blueprints.md ├── README-components.md ├── README-export.md ├── README-levels.md ├── README-tech.md ├── README.md ├── __init__.py ├── add_ons │ ├── __init__.py │ ├── auto_export │ │ ├── __init__.py │ │ ├── animations │ │ │ ├── __init__.py │ │ │ ├── export_animations.py │ │ │ └── get_animations_to_export.py │ │ ├── blueprints │ │ │ ├── __init__.py │ │ │ ├── export_blueprints.py │ │ │ └── get_blueprints_to_export.py │ │ ├── common │ │ │ ├── __init__.py │ │ │ ├── auto_export.py │ │ │ ├── duplicate_object.py │ │ │ ├── export_gltf.py │ │ │ ├── generate_temporary_scene_and_export.py │ │ │ ├── prepare_and_export.py │ │ │ ├── project_diff.py │ │ │ ├── serialize_project.py │ │ │ ├── settings_diff.py │ │ │ └── tracker.py │ │ ├── constants.py │ │ ├── levels │ │ │ ├── __init__.py │ │ │ ├── bevy_scene_components.py │ │ │ ├── export_levels.py │ │ │ ├── get_levels_to_export.py │ │ │ └── is_object_dynamic.py │ │ ├── materials │ │ │ ├── __init__.py │ │ │ ├── export_materials.py │ │ │ └── get_materials_to_export.py │ │ ├── settings.py │ │ ├── ui.py │ │ └── utils.py │ └── bevy_components │ │ ├── __init__.py │ │ ├── components │ │ ├── __init__.py │ │ ├── lists.py │ │ ├── maps.py │ │ ├── metadata.py │ │ ├── operators.py │ │ └── ui.py │ │ ├── constants.py │ │ ├── propGroups │ │ ├── __init__.py │ │ ├── conversions_from_prop_group.py │ │ ├── conversions_to_prop_group.py │ │ ├── operators.py │ │ ├── process_component.py │ │ ├── process_enum.py │ │ ├── process_list.py │ │ ├── process_map.py │ │ ├── process_structs.py │ │ ├── process_tupples.py │ │ ├── prop_groups.py │ │ └── utils.py │ │ ├── registry │ │ ├── __init__.py │ │ ├── hashing │ │ │ ├── __init__.py │ │ │ ├── sboxes.py │ │ │ └── tiger.py │ │ ├── operators.py │ │ ├── registry.py │ │ └── ui.py │ │ ├── settings.py │ │ ├── ui.py │ │ └── utils.py ├── assets │ ├── __init__.py │ ├── asset_helpers.py │ ├── assets_folder_browser.py │ ├── assets_registry.py │ ├── assets_scan.py │ ├── generate_asset_file.py │ ├── operators.py │ └── ui.py ├── blender_manifest.toml ├── blueprints │ ├── __init__.py │ ├── blueprint.py │ ├── blueprint_helpers.py │ ├── blueprints_registry.py │ ├── blueprints_scan.py │ ├── operators.py │ └── ui.py ├── core │ ├── __init__.py │ ├── blenvy_manager.py │ ├── helpers_collections.py │ ├── object_makers.py │ ├── operators.py │ ├── path_helpers.py │ ├── scene_helpers.py │ ├── ui │ │ ├── __init__.py │ │ ├── menus_and_shortcuts.py │ │ ├── scenes_list.py │ │ └── ui.py │ └── utils.py ├── docs │ ├── auto_export │ │ ├── blender_addon_add_scene.png │ │ ├── blender_addon_add_scene2.png │ │ ├── blender_addon_add_scene3.png │ │ ├── blender_addon_install2.png │ │ ├── blender_addon_install_zip.png │ │ ├── blender_addon_use.png │ │ ├── blender_addon_use2.png │ │ ├── blender_addon_use3.png │ │ ├── blender_addon_use4.png │ │ ├── exported_collections.png │ │ ├── exported_library_files.png │ │ ├── force_export.jpg │ │ ├── nested_blueprints.png │ │ ├── nested_blueprints2.png │ │ ├── nested_blueprints3.png │ │ ├── options.svg │ │ ├── purge_orphan1_data1.png │ │ ├── purge_orphan1_data2.png │ │ ├── purge_orphan1_data3.png │ │ ├── workflow_empties.jpg │ │ └── workflow_original.jpg │ ├── blender_addon_install.png │ ├── blender_addon_materials.png │ ├── blender_addon_materials2.png │ ├── blenvy_configuration_common.png │ ├── blenvy_configuration_components.png │ ├── blenvy_configuration_export.png │ ├── blenvy_recommended_folder_structure.png │ ├── blenvy_recommended_folder_structure_art.png │ ├── blenvy_recommended_folder_structure_assets.png │ ├── blenvy_ui_location.png │ ├── blueprints_always_export.png │ ├── blueprints_create.png │ ├── blueprints_create2.png │ ├── blueprints_create3.png │ ├── blueprints_mark_asset.png │ ├── blueprints_tab.png │ ├── combine_override.png │ ├── components │ │ ├── add_component.png │ │ ├── blender_addon_install.png │ │ ├── blender_addon_install2.png │ │ ├── blender_addon_install_zip.png │ │ ├── complex_components2.png │ │ ├── component_remove_single.png │ │ ├── component_rename_object_select.png │ │ ├── component_rename_overview2.png │ │ ├── component_rename_remove_bulk.png │ │ ├── component_rename_remove_bulk2.png │ │ ├── component_rename_single.png │ │ ├── components_list.png │ │ ├── components_list2.png │ │ ├── configuration.png │ │ ├── configuration2.png │ │ ├── configuration3.png │ │ ├── copy_component.png │ │ ├── edit_component.png │ │ ├── edit_component2.png │ │ ├── enums.png │ │ ├── enums2.png │ │ ├── filter_components.png │ │ ├── generate_components.png │ │ ├── generate_components2.png │ │ ├── generate_components3.png │ │ ├── other_options.png │ │ ├── other_options2.png │ │ ├── paste_component.png │ │ ├── registry_polling.png │ │ ├── toggle_details.png │ │ ├── unregistered_types.png │ │ ├── update_ui_from_custom_properties.png │ │ └── vecs_lists.png │ ├── components_add.png │ ├── components_add2.png │ ├── components_blueprints.png │ ├── components_blueprints_blueprint.png │ ├── components_blueprints_instance.png │ ├── components_copy.png │ ├── components_details.png │ ├── components_edit.png │ ├── components_invalid.png │ ├── components_list.png │ ├── components_missing_registry_data.png │ ├── components_object.png │ ├── components_paste.png │ ├── components_rename_fix.png │ ├── components_rename_fix2.png │ ├── components_rename_fix3.png │ ├── components_rename_fix4.png │ ├── components_search.png │ ├── components_suported_types.png │ ├── components_unregistered_types.png │ └── process.svg ├── levels │ ├── __init__.py │ ├── operators.py │ └── ui.py ├── materials │ ├── __init__.py │ └── materials_helpers.py ├── old.md ├── pytest.ini ├── settings.py └── tests │ ├── __init__.py │ ├── component_values_shuffler.py │ ├── expected_bevy_hierarchy.json │ ├── expected_component_values.py │ ├── expected_screenshot.png │ ├── setup_data.py │ ├── test_bevy_integration.py │ ├── test_bevy_integration_prepare.py │ ├── test_bevy_integration_simple.py │ ├── test_change_tracking.py │ ├── test_changed_parameters.py │ ├── test_components.py │ ├── test_conversions.py │ ├── test_export_parameters.py │ ├── test_helpers.py │ ├── test_registry.py │ ├── test_rename_components.py │ └── test_shuffler.py ├── internal_generate_example_gltf_files.py └── internal_generate_release_zips.py /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | push: 6 | 7 | jobs: 8 | lint: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/cache@v3 13 | with: 14 | path: | 15 | ~/.cargo/bin/ 16 | ~/.cargo/registry/index/ 17 | ~/.cargo/registry/cache/ 18 | ~/.cargo/git/db/ 19 | target/ 20 | key: ubuntu-latest-cargo-lint-${{ hashFiles('**/Cargo.toml') }} 21 | - uses: dtolnay/rust-toolchain@master 22 | with: 23 | toolchain: 1.76.0 24 | components: rustfmt, clippy 25 | - name: Install alsa and udev 26 | run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev 27 | - name: Run clippy 28 | run: cargo clippy --workspace --all-targets --all-features -- -Dwarnings 29 | - name: Check format 30 | run: cargo fmt --all -- --check 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.blend1 2 | target/ 3 | __pycache__/ 4 | Cargo.lock -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "crates/*", 4 | "examples/*", 5 | "testing/bevy_example/", 6 | ] 7 | resolver = "2" 8 | 9 | [workspace.lints.clippy] 10 | type_complexity = "allow" 11 | doc_markdown = "warn" 12 | manual_let_else = "warn" 13 | undocumented_unsafe_blocks = "warn" 14 | redundant_else = "warn" 15 | match_same_arms = "warn" 16 | semicolon_if_nothing_returned = "warn" 17 | 18 | #### --------------------Dev/ debug------------------------------- 19 | # Enable a small amount of optimization in debug mode 20 | [profile.dev] 21 | opt-level = 1 22 | 23 | # Enable high optimizations for dependencies (incl. Bevy), but not for our code: 24 | [profile.dev.package."*"] 25 | opt-level = 3 26 | 27 | #### --------------------Production/ release------------------------------- 28 | [profile.release] 29 | strip = "debuginfo" 30 | lto = "thin" 31 | -------------------------------------------------------------------------------- /FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: crobocado -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | This crate is available under either: 2 | 3 | * The [MIT License](./LICENSE_MIT) 4 | * The [Apache License, Version 2.0](./LICENSE_APACHE) -------------------------------------------------------------------------------- /LICENSE_MIT.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Mark "kaosat-dev" Moissette 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README-workflow-ui.md: -------------------------------------------------------------------------------- 1 | # Workflow: UI 2 | 3 | The workflow goes as follows (once you got your Bevy code setup) 4 | 5 | ## Bevy side 6 | - create & register all your components you want to be able to set from the Blender side (this is basic Bevy, no specific work needed) 7 | - follow the instructions in the [blenvy](./crates/blenvy/) to generate a registry export 8 | 9 | ## Component creation 10 | 11 | Setup the Blender [Blenvy](./tools/blenvy/README.md) blender add-on 12 | to add & edit your components visually & reliably 13 | 14 | ![bevy_components](./docs/bevy_components.png) 15 | 16 | 17 | ## Exporting to gltf 18 | 19 | - export your level as a glb/gltf file : 20 | - using Blender's default gltf exporter 21 | !!**IMPORTANT** you need to check the following: 22 | - custom properties 23 | - cameras & lights if you want a complete level (as in this example) 24 | ![gltf_export](./docs/gltf_export.png) 25 | - or much better, using [blenvy](./tools/blenvy/) 26 | 27 | ## Now use your gltf files in Bevy 28 | 29 | - load it in Bevy (see the various examples for this) 30 | - you should see the components attached to your entities in Bevy 31 | 32 | ![components in bevy](./docs/components_bevy.png) 33 | ![components in bevy](./docs/components_bevy2.png) 34 | ![components in bevy](./docs/components_bevy3.png) 35 | 36 | 37 | > note: you get a warning if there are any unregistered components in your gltf file (they get ignored) 38 | you will get a warning **per entity** 39 | 40 | ![missing components warnings](./docs/component_warnings.png) 41 | -------------------------------------------------------------------------------- /crates/blenvy/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "blenvy" 3 | version = "0.1.0-alpha.1" 4 | authors = ["Mark 'kaosat-dev' Moissette"] 5 | description = "Allows you to define Bevy components direclty inside gltf files and instanciate the components on the Bevy side." 6 | homepage = "https://github.com/kaosat-dev/Blenvy" 7 | repository = "https://github.com/kaosat-dev/Blenvy" 8 | keywords = ["gamedev", "bevy", "assets", "gltf", "components"] 9 | categories = ["game-development"] 10 | edition = "2021" 11 | license = "MIT OR Apache-2.0" 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf", "animation"] } 18 | serde = "1.0.188" 19 | ron = "0.8.1" 20 | serde_json = "1.0.108" 21 | bevy_common_assets = {version = "0.11", features = ["ron"]} 22 | 23 | 24 | [dev-dependencies] 25 | bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] } -------------------------------------------------------------------------------- /crates/blenvy/LICENSE.md: -------------------------------------------------------------------------------- 1 | This crate is available under either: 2 | 3 | * The [MIT License](./LICENSE_MIT) 4 | * The [Apache License, Version 2.0](./LICENSE_APACHE) -------------------------------------------------------------------------------- /crates/blenvy/LICENSE_MIT.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Mark "kaosat-dev" Moissette 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /crates/blenvy/src/blueprints/aabb.rs: -------------------------------------------------------------------------------- 1 | use bevy::{math::Vec3A, prelude::*, render::primitives::Aabb}; 2 | 3 | use crate::{BlenvyConfig, BlueprintReadyForFinalizing, BlueprintReadyForPostProcess}; 4 | 5 | /// helper system that computes the compound aabbs of the scenes/blueprints 6 | pub fn compute_scene_aabbs( 7 | root_entities: Query<(Entity, &Name), (With, Without)>, 8 | other_entities: Query, With)>, 9 | children: Query<&Children>, 10 | existing_aabbs: Query<&Aabb>, 11 | 12 | mut blenvy_config: ResMut, 13 | mut commands: Commands, 14 | ) { 15 | // compute compound aabb 16 | for (root_entity, name) in root_entities.iter() { 17 | // info!("generating aabb for {:?}", name); 18 | 19 | // only recompute aabb if it has not already been done before 20 | if blenvy_config.aabb_cache.contains_key(&name.to_string()) { 21 | let aabb = blenvy_config 22 | .aabb_cache 23 | .get(&name.to_string()) 24 | .expect("we should have the aabb available"); 25 | commands 26 | .entity(root_entity) 27 | .insert(*aabb) 28 | .insert(BlueprintReadyForFinalizing); 29 | } else { 30 | let aabb = compute_descendant_aabb(root_entity, &children, &existing_aabbs); 31 | blenvy_config.aabb_cache.insert(name.to_string(), aabb); 32 | info!("Step 7: generating aabb for {:?}", name); 33 | commands 34 | .entity(root_entity) 35 | .insert(aabb) 36 | .insert(BlueprintReadyForFinalizing); 37 | } 38 | } 39 | for entity in other_entities.iter() { 40 | commands.entity(entity).insert(BlueprintReadyForFinalizing); 41 | } 42 | } 43 | 44 | pub fn compute_descendant_aabb( 45 | root_entity: Entity, 46 | children: &Query<&Children>, 47 | existing_aabbs: &Query<&Aabb>, 48 | ) -> Aabb { 49 | if let Ok(children_list) = children.get(root_entity) { 50 | let mut chilren_aabbs: Vec = vec![]; 51 | for child in children_list.iter() { 52 | if let Ok(aabb) = existing_aabbs.get(*child) { 53 | chilren_aabbs.push(*aabb); 54 | } else { 55 | let aabb = compute_descendant_aabb(*child, children, existing_aabbs); 56 | chilren_aabbs.push(aabb); 57 | } 58 | } 59 | 60 | let mut min = Vec3A::splat(f32::MAX); 61 | let mut max = Vec3A::splat(f32::MIN); 62 | for aabb in chilren_aabbs.iter() { 63 | min = min.min(aabb.min()); 64 | max = max.max(aabb.max()); 65 | } 66 | let aabb = Aabb::from_min_max(Vec3::from(min), Vec3::from(max)); 67 | 68 | return aabb; 69 | } 70 | 71 | Aabb::default() 72 | } 73 | -------------------------------------------------------------------------------- /crates/blenvy/src/components/blender_settings.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | mod lighting; 4 | pub use lighting::*; 5 | 6 | pub(crate) fn plugin(app: &mut App) { 7 | app.add_plugins(lighting::plugin); 8 | } 9 | -------------------------------------------------------------------------------- /crates/blenvy/src/components/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod utils; 2 | pub use utils::*; 3 | 4 | pub mod ronstring_to_reflect_component; 5 | pub use ronstring_to_reflect_component::*; 6 | 7 | pub mod process_gltfs; 8 | pub use process_gltfs::*; 9 | 10 | pub mod blender_settings; 11 | 12 | use bevy::{ 13 | ecs::{component::Component, reflect::ReflectComponent}, 14 | prelude::{App, IntoSystemConfigs, Plugin, SystemSet, Update}, 15 | reflect::Reflect, 16 | }; 17 | 18 | /// A Bevy plugin for extracting components from gltf files and automatically adding them to the relevant entities 19 | /// It will automatically run every time you load a gltf file 20 | /// Add this plugin to your Bevy app to get access to this feature 21 | /// ``` 22 | /// # use bevy::prelude::*; 23 | /// # use bevy::gltf::*; 24 | /// # use blenvy::ComponentsFromGltfPlugin; 25 | /// 26 | /// //too barebones of an example to be meaningfull, please see https://github.com/kaosat-dev/Blenvy/examples/basic for a real example 27 | /// fn main() { 28 | /// App::new() 29 | /// .add_plugins(DefaultPlugins) 30 | /// .add_plugin(ComponentsFromGltfPlugin) 31 | /// .add_system(spawn_level) 32 | /// .run(); 33 | /// } 34 | /// 35 | /// fn spawn_level( 36 | /// asset_server: Res, 37 | /// mut commands: bevy::prelude::Commands, 38 | /// keycode: Res>, 39 | 40 | /// ){ 41 | /// if keycode.just_pressed(KeyCode::Return) { 42 | /// commands.spawn(SceneBundle { 43 | /// scene: asset_server.load("basic/models/level1.glb"), 44 | /// transform: Transform::from_xyz(2.0, 0.0, -5.0), 45 | /// ..Default::default() 46 | /// }); 47 | /// } 48 | ///} 49 | /// ``` 50 | 51 | /// this is a flag component to tag a processed gltf, to avoid processing things multiple times 52 | #[derive(Component, Reflect, Default, Debug)] 53 | #[reflect(Component)] 54 | pub struct GltfProcessed; 55 | 56 | #[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)] 57 | /// systemset to order your systems after the component injection when needed 58 | pub enum GltfComponentsSet { 59 | Injection, 60 | } 61 | 62 | #[derive(Default)] 63 | pub struct ComponentsFromGltfPlugin {} 64 | 65 | impl Plugin for ComponentsFromGltfPlugin { 66 | fn build(&self, app: &mut App) { 67 | app.add_plugins(blender_settings::plugin) 68 | .register_type::() 69 | .add_systems( 70 | Update, 71 | (add_components_from_gltf_extras).in_set(GltfComponentsSet::Injection), 72 | ); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /crates/blenvy/src/components/utils.rs: -------------------------------------------------------------------------------- 1 | pub fn capitalize_first_letter(s: &str) -> String { 2 | s[0..1].to_uppercase() + &s[1..] 3 | } 4 | -------------------------------------------------------------------------------- /crates/blenvy/src/registry/mod.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | pub mod export_types; 4 | pub use export_types::*; 5 | 6 | use bevy::{ 7 | app::Startup, 8 | asset::AssetPlugin, 9 | prelude::{App, IntoSystemConfigs, Plugin, Res, Resource}, 10 | scene::SceneFilter, 11 | }; 12 | 13 | use crate::BlenvyConfig; 14 | 15 | pub struct ExportRegistryPlugin { 16 | pub component_filter: SceneFilter, 17 | pub resource_filter: SceneFilter, 18 | pub save_path: PathBuf, 19 | } 20 | 21 | impl Default for ExportRegistryPlugin { 22 | fn default() -> Self { 23 | Self { 24 | component_filter: SceneFilter::default(), 25 | resource_filter: SceneFilter::default(), 26 | save_path: PathBuf::from("registry.json"), // relative to assets folder 27 | } 28 | } 29 | } 30 | 31 | fn export_registry(blenvy_config: Res) -> bool { 32 | // TODO: add detection of Release builds, wasm, and android in order to avoid exporting registry in those cases 33 | blenvy_config.export_registry 34 | } 35 | 36 | impl Plugin for ExportRegistryPlugin { 37 | fn build(&self, app: &mut App) { 38 | app.register_asset_root() 39 | .add_systems(Startup, export_types.run_if(export_registry)); 40 | } 41 | } 42 | 43 | trait RegistryExportApp { 44 | fn register_asset_root(&mut self) -> &mut Self; 45 | } 46 | impl RegistryExportApp for App { 47 | fn register_asset_root(&mut self) -> &mut Self { 48 | let asset_plugin = get_asset_plugin(self); 49 | let path_str = asset_plugin.file_path.clone(); 50 | let path = PathBuf::from(path_str); 51 | self.insert_resource(AssetRoot(path)) 52 | } 53 | } 54 | 55 | fn get_asset_plugin(app: &App) -> &AssetPlugin { 56 | let asset_plugins: Vec<&AssetPlugin> = app.get_added_plugins(); 57 | asset_plugins.into_iter().next().expect(ASSET_ERROR) 58 | } 59 | 60 | const ASSET_ERROR: &str = "Bevy_registry_export requires access to the Bevy asset plugin. \ 61 | Please add `ExportRegistryPlugin` after `AssetPlugin`, which is commonly added as part of the `DefaultPlugins`"; 62 | 63 | #[derive(Debug, Clone, PartialEq, Eq, Hash, Resource)] 64 | pub(crate) struct AssetRoot(pub(crate) PathBuf); 65 | -------------------------------------------------------------------------------- /crates/blenvy/src/save_load/common.rs: -------------------------------------------------------------------------------- 1 | pub use bevy::prelude::*; 2 | 3 | use crate::{BlueprintInfo, GameWorldTag, HideUntilReady, SpawnBlueprint}; 4 | 5 | use super::BlueprintWorld; 6 | 7 | pub(crate) fn spawn_from_blueprintworld( 8 | added_blueprint_worlds: Query<(Entity, &BlueprintWorld), Added>, 9 | mut commands: Commands, 10 | ) { 11 | for (__entity, blueprint_world) in added_blueprint_worlds.iter() { 12 | debug!("added blueprintWorld {:?}", blueprint_world); 13 | 14 | // here we spawn the static part our game world/level, which is also a blueprint ! 15 | let __static_world = commands 16 | .spawn(( 17 | BlueprintInfo::from_path(blueprint_world.path.as_str()), // all we need is a Blueprint info... 18 | SpawnBlueprint, // and spawnblueprint to tell blenvy to spawn the blueprint now 19 | HideUntilReady, // only reveal the level once it is ready 20 | GameWorldTag, 21 | )) 22 | .id(); 23 | 24 | // here we spawn the dynamic entities part of our game world/level, which is also a blueprint ! 25 | let __dynamic_world = commands 26 | .spawn(( 27 | BlueprintInfo::from_path( 28 | blueprint_world 29 | .path 30 | .replace(".glb", "_dynamic.glb") 31 | .replace(".gltf", "_dynamic.gltf") 32 | .as_str(), 33 | ), // all we need is a Blueprint info... 34 | SpawnBlueprint, // and spawnblueprint to tell blenvy to spawn the blueprint now 35 | HideUntilReady, // only reveal the level once it is ready 36 | GameWorldTag, 37 | )) 38 | .id(); 39 | 40 | // commands.entity(entity).add_child(static_world); 41 | // commands.entity(entity).add_child(dynamic_world); 42 | } 43 | } 44 | 45 | /* 46 | pub(crate) fn inject_dynamic_into_children( 47 | added_dynamic: Query >, 48 | all_children: Query<&Children>, 49 | mut commands: Commands, 50 | ) { 51 | for entity in added_dynamic.iter() { 52 | for child in all_children.iter_descendants(entity) { 53 | commands.entity(child).insert(Dynamic); 54 | } 55 | } 56 | }*/ 57 | -------------------------------------------------------------------------------- /crates/blenvy/src/save_load/old/mod_old.rs: -------------------------------------------------------------------------------- 1 | pub mod saveable; 2 | use std::path::PathBuf; 3 | 4 | pub use saveable::*; 5 | 6 | pub mod saving; 7 | pub use saving::*; 8 | 9 | pub mod loading; 10 | pub use loading::*; 11 | 12 | use bevy::core_pipeline::core_3d::{Camera3dDepthTextureUsage, ScreenSpaceTransmissionQuality}; 13 | use bevy::prelude::*; 14 | use bevy::prelude::{App, IntoSystemConfigs, Plugin}; 15 | use blenvy::GltfBlueprintsSet; 16 | 17 | #[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)] 18 | pub enum SavingSet { 19 | Save, 20 | } 21 | 22 | #[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)] 23 | pub enum LoadingSet { 24 | Load, 25 | } 26 | 27 | 28 | #[derive(Component, Reflect, Debug, Default)] 29 | #[reflect(Component)] 30 | pub struct StaticEntitiesRoot; 31 | 32 | #[derive(Component, Reflect, Debug, Default)] 33 | #[reflect(Component)] 34 | pub struct DynamicEntitiesRoot; 35 | 36 | impl Plugin for SaveLoadPlugin { 37 | fn build(&self, app: &mut App) { 38 | app.register_type::() 39 | .register_type::() 40 | // TODO: remove these in bevy 0.13, as these are now registered by default 41 | .register_type::() 42 | .register_type::() 43 | .register_type::() 44 | .add_event::() 45 | .add_event::() 46 | .add_event::() 47 | .add_event::() 48 | .configure_sets( 49 | Update, 50 | (LoadingSet::Load).chain().before(GltfBlueprintsSet::Spawn), //.before(GltfComponentsSet::Injection) 51 | ) 52 | .add_systems( 53 | PreUpdate, 54 | (prepare_save_game, apply_deferred, save_game, cleanup_save) 55 | .chain() 56 | .run_if(should_save), 57 | ) 58 | .add_systems(Update, mark_load_requested) 59 | .add_systems( 60 | Update, 61 | (unload_world, apply_deferred, load_game) 62 | .chain() 63 | .run_if(resource_exists::) 64 | .run_if(not(resource_exists::)) 65 | .in_set(LoadingSet::Load), 66 | ) 67 | .add_systems( 68 | Update, 69 | (load_static, apply_deferred, cleanup_loaded_scene) 70 | .chain() 71 | .run_if(resource_exists::) 72 | // .run_if(in_state(AppState::LoadingGame)) 73 | .in_set(LoadingSet::Load), 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /docs/avian/img/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/board.png -------------------------------------------------------------------------------- /docs/avian/img/create_cylinder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/create_cylinder.png -------------------------------------------------------------------------------- /docs/avian/img/create_cylinder_options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/create_cylinder_options.png -------------------------------------------------------------------------------- /docs/avian/img/cube_primitive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/cube_primitive.png -------------------------------------------------------------------------------- /docs/avian/img/cylinder_collider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/cylinder_collider.png -------------------------------------------------------------------------------- /docs/avian/img/cylinder_collider_on_mesh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/cylinder_collider_on_mesh.png -------------------------------------------------------------------------------- /docs/avian/img/data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/data.png -------------------------------------------------------------------------------- /docs/avian/img/dimensions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/dimensions.png -------------------------------------------------------------------------------- /docs/avian/img/direct_in_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/direct_in_world.png -------------------------------------------------------------------------------- /docs/avian/img/dynamic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/dynamic.png -------------------------------------------------------------------------------- /docs/avian/img/empty_child.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/empty_child.png -------------------------------------------------------------------------------- /docs/avian/img/empty_collections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/empty_collections.png -------------------------------------------------------------------------------- /docs/avian/img/empty_scaled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/empty_scaled.png -------------------------------------------------------------------------------- /docs/avian/img/empty_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/empty_selected.png -------------------------------------------------------------------------------- /docs/avian/img/empty_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/empty_world.png -------------------------------------------------------------------------------- /docs/avian/img/falling.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/falling.gif -------------------------------------------------------------------------------- /docs/avian/img/falling_concave.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/falling_concave.gif -------------------------------------------------------------------------------- /docs/avian/img/falling_convex.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/falling_convex.gif -------------------------------------------------------------------------------- /docs/avian/img/falling_direct.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/falling_direct.gif -------------------------------------------------------------------------------- /docs/avian/img/falling_direct_on_static.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/falling_direct_on_static.gif -------------------------------------------------------------------------------- /docs/avian/img/falling_empty.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/falling_empty.gif -------------------------------------------------------------------------------- /docs/avian/img/falling_wireframe.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/falling_wireframe.gif -------------------------------------------------------------------------------- /docs/avian/img/ground collider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/ground collider.png -------------------------------------------------------------------------------- /docs/avian/img/hiding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/hiding.png -------------------------------------------------------------------------------- /docs/avian/img/parenting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/parenting.png -------------------------------------------------------------------------------- /docs/avian/img/select_mesh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/select_mesh.png -------------------------------------------------------------------------------- /docs/avian/img/three_object_collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/three_object_collection.png -------------------------------------------------------------------------------- /docs/avian/img/torus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/torus.png -------------------------------------------------------------------------------- /docs/avian/img/torus_component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/torus_component.png -------------------------------------------------------------------------------- /docs/avian/img/wireframe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/avian/img/wireframe.png -------------------------------------------------------------------------------- /docs/bevy_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/bevy_components.png -------------------------------------------------------------------------------- /docs/blender_bevy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/blender_bevy.png -------------------------------------------------------------------------------- /docs/blender_collections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/blender_collections.png -------------------------------------------------------------------------------- /docs/blender_gltf_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/blender_gltf_components.png -------------------------------------------------------------------------------- /docs/camera_tracking_component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/camera_tracking_component.png -------------------------------------------------------------------------------- /docs/component_registration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/component_registration.png -------------------------------------------------------------------------------- /docs/component_warnings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/component_warnings.png -------------------------------------------------------------------------------- /docs/components_bevy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/components_bevy.png -------------------------------------------------------------------------------- /docs/components_bevy2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/components_bevy2.png -------------------------------------------------------------------------------- /docs/components_bevy3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/components_bevy3.png -------------------------------------------------------------------------------- /docs/components_blender.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/components_blender.png -------------------------------------------------------------------------------- /docs/components_blender_parameters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/components_blender_parameters.png -------------------------------------------------------------------------------- /docs/components_blender_parameters2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/components_blender_parameters2.png -------------------------------------------------------------------------------- /docs/demo_simple_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/demo_simple_components.png -------------------------------------------------------------------------------- /docs/gltf_export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/gltf_export.png -------------------------------------------------------------------------------- /docs/quickstart/img/art_file_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/art_file_structure.png -------------------------------------------------------------------------------- /docs/quickstart/img/blenvy_after_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/blenvy_after_setup.png -------------------------------------------------------------------------------- /docs/quickstart/img/blenvy_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/blenvy_menu.png -------------------------------------------------------------------------------- /docs/quickstart/img/blueprint_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/blueprint_file.png -------------------------------------------------------------------------------- /docs/quickstart/img/camera_transform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/camera_transform.png -------------------------------------------------------------------------------- /docs/quickstart/img/component_manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/component_manager.png -------------------------------------------------------------------------------- /docs/quickstart/img/create_scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/create_scene.png -------------------------------------------------------------------------------- /docs/quickstart/img/default_collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/default_collection.png -------------------------------------------------------------------------------- /docs/quickstart/img/final_bevy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/final_bevy.png -------------------------------------------------------------------------------- /docs/quickstart/img/final_blender.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/final_blender.png -------------------------------------------------------------------------------- /docs/quickstart/img/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/install.png -------------------------------------------------------------------------------- /docs/quickstart/img/level_asset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/level_asset.png -------------------------------------------------------------------------------- /docs/quickstart/img/lots_of_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/lots_of_components.png -------------------------------------------------------------------------------- /docs/quickstart/img/player_collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/player_collection.png -------------------------------------------------------------------------------- /docs/quickstart/img/player_component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/player_component.png -------------------------------------------------------------------------------- /docs/quickstart/img/registry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/registry.png -------------------------------------------------------------------------------- /docs/quickstart/img/registry_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/registry_settings.png -------------------------------------------------------------------------------- /docs/quickstart/img/scene_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/scene_name.png -------------------------------------------------------------------------------- /docs/quickstart/img/scenes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/docs/quickstart/img/scenes.png -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | This folder contains numerous examples showing how to use Blenvy 4 | Each example is its own crate so its dependencies and assets are specific & clear. -------------------------------------------------------------------------------- /examples/animation/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "blenvy_animation_example" 3 | version = "0.0.1" 4 | edition = "2021" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [dependencies] 8 | bevy = { version = "0.14", features = ["dynamic_linking"] } 9 | blenvy = { path = "../../crates/blenvy" } 10 | rand = "0.8.5" -------------------------------------------------------------------------------- /examples/animation/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Animation example/demo 3 | 4 | Example on how to control animations & how to use the provided helpers 5 | Two animated blueprints are provided: Bevy's Fox, and a Robot I created. 6 | 7 | There is almost no boilerplate, other than setting up ```Bevy_gltf_blueprints``` 8 | 9 | If you want to jump straight to controlling the imported animations, jump to : 10 | []('./src/game/in_game.rs#86') 11 | 12 | ## Running this example 13 | 14 | ``` 15 | cargo run --features bevy/dynamic_linking 16 | ``` 17 | -------------------------------------------------------------------------------- /examples/animation/art/animation.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/animation/art/animation.blend -------------------------------------------------------------------------------- /examples/animation/assets/blueprints/Fox.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/animation/assets/blueprints/Fox.glb -------------------------------------------------------------------------------- /examples/animation/assets/blueprints/Player.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/animation/assets/blueprints/Player.glb -------------------------------------------------------------------------------- /examples/animation/assets/blueprints/Wheelbot.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/animation/assets/blueprints/Wheelbot.glb -------------------------------------------------------------------------------- /examples/animation/assets/levels/World.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/animation/assets/levels/World.glb -------------------------------------------------------------------------------- /examples/animation/src/component_examples.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[derive(Component, Reflect, Default, Debug)] 4 | #[reflect(Component)] 5 | struct UnitTest; 6 | 7 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 8 | #[reflect(Component)] 9 | struct TupleTestF32(f32); 10 | 11 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 12 | #[reflect(Component)] 13 | struct TupleTestU64(u64); 14 | 15 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 16 | #[reflect(Component)] 17 | pub struct TupleTestStr(String); 18 | 19 | #[derive(Component, Reflect, Default, Debug)] 20 | #[reflect(Component)] 21 | struct TupleTest2(f32, u64, String); 22 | 23 | #[derive(Component, Reflect, Default, Debug)] 24 | #[reflect(Component)] 25 | struct TupleTestBool(bool); 26 | 27 | #[derive(Component, Reflect, Default, Debug)] 28 | #[reflect(Component)] 29 | struct TupleVec2(Vec2); 30 | 31 | #[derive(Component, Reflect, Default, Debug)] 32 | #[reflect(Component)] 33 | struct TupleVec3(Vec3); 34 | 35 | #[derive(Component, Reflect, Default, Debug)] 36 | #[reflect(Component)] 37 | struct TupleVec(Vec); 38 | 39 | #[derive(Component, Reflect, Default, Debug)] 40 | #[reflect(Component)] 41 | struct TupleTestColor(Color); 42 | 43 | #[derive(Component, Reflect, Default, Debug)] 44 | #[reflect(Component)] 45 | struct BasicTest { 46 | a: f32, 47 | b: u64, 48 | c: String, 49 | } 50 | 51 | #[derive(Component, Reflect, Default, Debug)] 52 | #[reflect(Component)] 53 | pub enum EnumTest { 54 | Metal, 55 | Wood, 56 | Rock, 57 | Cloth, 58 | Squishy, 59 | #[default] 60 | None, 61 | } 62 | 63 | pub struct ComponentsExamplesPlugin; 64 | impl Plugin for ComponentsExamplesPlugin { 65 | fn build(&self, app: &mut App) { 66 | app.register_type::() 67 | .register_type::() 68 | .register_type::() 69 | .register_type::() 70 | .register_type::() 71 | .register_type::() 72 | .register_type::() 73 | .register_type::() 74 | .register_type::() 75 | .register_type::() 76 | .register_type::() 77 | .register_type::() 78 | .register_type::>(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/blueprints/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "blenvy_blueprints_example" 3 | version = "0.0.1" 4 | edition = "2021" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [dependencies] 8 | bevy = { version = "0.14", features = ["dynamic_linking"] } 9 | blenvy = { path = "../../crates/blenvy" } 10 | rand = "0.8.5" -------------------------------------------------------------------------------- /examples/blueprints/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Blueprints example 3 | 4 | Example of blueprints : 5 | - how to use them to spawn levels 6 | - how to use them to spawn dynamic entities 7 | 8 | 9 | 10 | ## Running this example 11 | 12 | ``` 13 | cargo run --features bevy/dynamic_linking 14 | ``` 15 | -------------------------------------------------------------------------------- /examples/blueprints/art/basic.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/art/basic.blend -------------------------------------------------------------------------------- /examples/blueprints/art/materials.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/art/materials.blend -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/Container.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/Container.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/Health_Pickup.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/Health_Pickup.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/Magic Sphere.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/Magic Sphere.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/MagicTeapot.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/MagicTeapot.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/Pillar.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/Pillar.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/Pillar2.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/Pillar2.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/Player.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/Player.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/Watermelon cut.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/Watermelon cut.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/Watermelon.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/Watermelon.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/blueprints/Watermelon2.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/blueprints/Watermelon2.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/levels/Level1.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/levels/Level1.glb -------------------------------------------------------------------------------- /examples/blueprints/assets/textures/juicy-watermelon-5882.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/textures/juicy-watermelon-5882.png -------------------------------------------------------------------------------- /examples/blueprints/assets/textures/watermelon-6441.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/blueprints/assets/textures/watermelon-6441.png -------------------------------------------------------------------------------- /examples/blueprints/src/component_examples.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 4 | #[reflect(Component)] 5 | struct TupleTestF32(f32); 6 | 7 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 8 | #[reflect(Component)] 9 | struct TupleTestU64(u64); 10 | 11 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 12 | #[reflect(Component)] 13 | pub struct TupleTestStr(String); 14 | 15 | #[derive(Component, Reflect, Default, Debug)] 16 | #[reflect(Component)] 17 | struct TupleTest2(f32, u64, String); 18 | 19 | #[derive(Component, Reflect, Default, Debug)] 20 | #[reflect(Component)] 21 | struct TupleTestBool(bool); 22 | 23 | #[derive(Component, Reflect, Default, Debug)] 24 | #[reflect(Component)] 25 | struct TupleVec2(Vec2); 26 | 27 | #[derive(Component, Reflect, Default, Debug)] 28 | #[reflect(Component)] 29 | struct TupleVec3(Vec3); 30 | 31 | #[derive(Component, Reflect, Default, Debug)] 32 | #[reflect(Component)] 33 | struct TupleVec(Vec); 34 | 35 | #[derive(Component, Reflect, Default, Debug)] 36 | #[reflect(Component)] 37 | struct TupleTestColor(Color); 38 | 39 | #[derive(Component, Reflect, Default, Debug)] 40 | #[reflect(Component)] 41 | struct BasicTest { 42 | a: f32, 43 | b: u64, 44 | c: String, 45 | } 46 | 47 | #[derive(Component, Reflect, Default, Debug)] 48 | #[reflect(Component)] 49 | pub enum EnumTest { 50 | Metal, 51 | Wood, 52 | Rock, 53 | Cloth, 54 | Squishy, 55 | #[default] 56 | None, 57 | } 58 | 59 | pub struct ComponentsExamplesPlugin; 60 | impl Plugin for ComponentsExamplesPlugin { 61 | fn build(&self, app: &mut App) { 62 | app.register_type::() 63 | .register_type::() 64 | .register_type::() 65 | .register_type::() 66 | .register_type::() 67 | .register_type::() 68 | .register_type::() 69 | .register_type::() 70 | .register_type::() 71 | .register_type::() 72 | .register_type::() 73 | .register_type::>(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /examples/blueprints/src/main.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use blenvy::{ 3 | AddToGameWorld, BlenvyPlugin, BluePrintBundle, BlueprintInfo, Dynamic, GameWorldTag, 4 | HideUntilReady, SpawnBlueprint, 5 | }; 6 | use rand::Rng; 7 | 8 | mod component_examples; 9 | use component_examples::*; 10 | 11 | fn main() { 12 | App::new() 13 | .add_plugins(( 14 | DefaultPlugins.set(AssetPlugin::default()), 15 | // our custom plugins 16 | ComponentsExamplesPlugin, // Showcases different type of components /structs 17 | BlenvyPlugin::default(), 18 | )) 19 | .add_systems(Startup, setup_game) 20 | .add_systems(Update, spawn_blueprint_instance) 21 | .run(); 22 | } 23 | 24 | // this is how you setup & spawn a level from a blueprint 25 | fn setup_game(mut commands: Commands) { 26 | // here we spawn our game world/level, which is also a blueprint ! 27 | commands.spawn(( 28 | BlueprintInfo::from_path("levels/Level1.glb"), // all we need is a Blueprint info... 29 | SpawnBlueprint, // and spawnblueprint to tell blenvy to spawn the blueprint now 30 | HideUntilReady, // only reveal the level once it is ready 31 | GameWorldTag, 32 | )); 33 | } 34 | 35 | // you can also spawn blueprint instances at runtime 36 | pub fn spawn_blueprint_instance(keycode: Res>, mut commands: Commands) { 37 | if keycode.just_pressed(KeyCode::KeyS) { 38 | let mut rng = rand::thread_rng(); 39 | let range = 5.5; 40 | let x: f32 = rng.gen_range(-range..range); 41 | let y: f32 = rng.gen_range(-range..range); 42 | 43 | let name_index: u64 = rng.gen(); 44 | 45 | let __new_entity = commands 46 | .spawn(( 47 | BluePrintBundle { 48 | blueprint: BlueprintInfo { 49 | name: "spawned".into(), 50 | path: "blueprints/Blueprint 3.gltf".into(), 51 | }, // FIXME 52 | ..Default::default() 53 | }, 54 | Dynamic, 55 | bevy::prelude::Name::from(format!("test{}", name_index)), 56 | HideUntilReady, 57 | AddToGameWorld, 58 | TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)), 59 | )) 60 | .id(); 61 | // commands.entity(world).add_child(new_entity); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /examples/components/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "blenvy_components_example" 3 | version = "0.0.1" 4 | edition = "2021" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [dependencies] 8 | bevy = { version = "0.14", features = ["dynamic_linking"] } 9 | blenvy = { path = "../../crates/blenvy" } 10 | -------------------------------------------------------------------------------- /examples/components/README.md: -------------------------------------------------------------------------------- 1 | # Basic physics example/demo 2 | 3 | This example showcases various Bevy components added to objects/ blueprints/ meshes and materials extracted from the gltf files 4 | 5 | 6 | 7 | ## Running this example 8 | 9 | ``` 10 | cargo run --features bevy/dynamic_linking 11 | 12 | ``` 13 | 14 | ## Wasm instructions 15 | 16 | ### Setup 17 | 18 | as per the bevy documentation: 19 | 20 | ```shell 21 | rustup target add wasm32-unknown-unknown 22 | cargo install wasm-bindgen-cli 23 | ``` 24 | 25 | 26 | ### Building this example 27 | 28 | navigate to the current folder , and then 29 | 30 | ```shell 31 | cargo build --release --target wasm32-unknown-unknown --target-dir ./target 32 | wasm-bindgen --out-name wasm_example \ 33 | --out-dir ./target/wasm \ 34 | --target web target/wasm32-unknown-unknown/release/bevy_gltf_blueprints_basic_wasm_example.wasm 35 | 36 | ``` 37 | 38 | ### Running this example 39 | 40 | run a web server in the current folder, and navigate to the page, you should see the example in your browser 41 | 42 | 43 | ## Additional notes 44 | 45 | * 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. 46 | -------------------------------------------------------------------------------- /examples/components/art/basic.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/art/basic.blend -------------------------------------------------------------------------------- /examples/components/assets/blueprints/Container.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/Container.glb -------------------------------------------------------------------------------- /examples/components/assets/blueprints/Enemy.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/Enemy.glb -------------------------------------------------------------------------------- /examples/components/assets/blueprints/Finger.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/Finger.glb -------------------------------------------------------------------------------- /examples/components/assets/blueprints/Hand.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/Hand.glb -------------------------------------------------------------------------------- /examples/components/assets/blueprints/Health_Pickup.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/Health_Pickup.glb -------------------------------------------------------------------------------- /examples/components/assets/blueprints/Humanoid_cactus.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/Humanoid_cactus.glb -------------------------------------------------------------------------------- /examples/components/assets/blueprints/MagicTeapot.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/MagicTeapot.glb -------------------------------------------------------------------------------- /examples/components/assets/blueprints/Pillar.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/Pillar.glb -------------------------------------------------------------------------------- /examples/components/assets/blueprints/Player.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/Player.glb -------------------------------------------------------------------------------- /examples/components/assets/blueprints/Unused_in_level_test.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/blueprints/Unused_in_level_test.glb -------------------------------------------------------------------------------- /examples/components/assets/levels/World.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/components/assets/levels/World.glb -------------------------------------------------------------------------------- /examples/components/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 27 | 28 | -------------------------------------------------------------------------------- /examples/components/src/component_examples.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[derive(Component, Reflect, Default, Debug)] 4 | #[reflect(Component)] 5 | struct UnitTest; 6 | 7 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 8 | #[reflect(Component)] 9 | struct TupleTestF32(f32); 10 | 11 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 12 | #[reflect(Component)] 13 | struct TupleTestU64(u64); 14 | 15 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 16 | #[reflect(Component)] 17 | pub struct TupleTestStr(String); 18 | 19 | #[derive(Component, Reflect, Default, Debug)] 20 | #[reflect(Component)] 21 | struct TupleTest2(f32, u64, String); 22 | 23 | #[derive(Component, Reflect, Default, Debug)] 24 | #[reflect(Component)] 25 | struct TupleTestBool(bool); 26 | 27 | #[derive(Component, Reflect, Default, Debug)] 28 | #[reflect(Component)] 29 | struct TupleVec2(Vec2); 30 | 31 | #[derive(Component, Reflect, Default, Debug)] 32 | #[reflect(Component)] 33 | struct TupleVec3(Vec3); 34 | 35 | #[derive(Component, Reflect, Default, Debug)] 36 | #[reflect(Component)] 37 | struct TupleVec(Vec); 38 | 39 | #[derive(Component, Reflect, Default, Debug)] 40 | #[reflect(Component)] 41 | struct TupleTestColor(Color); 42 | 43 | #[derive(Component, Reflect, Default, Debug)] 44 | #[reflect(Component)] 45 | struct BasicTest { 46 | a: f32, 47 | b: u64, 48 | c: String, 49 | } 50 | 51 | #[derive(Component, Reflect, Default, Debug)] 52 | #[reflect(Component)] 53 | pub enum EnumTest { 54 | Metal, 55 | Wood, 56 | Rock, 57 | Cloth, 58 | Squishy, 59 | #[default] 60 | None, 61 | } 62 | 63 | pub struct ComponentsExamplesPlugin; 64 | impl Plugin for ComponentsExamplesPlugin { 65 | fn build(&self, app: &mut App) { 66 | app.register_type::() 67 | .register_type::() 68 | .register_type::() 69 | .register_type::() 70 | .register_type::() 71 | .register_type::() 72 | .register_type::() 73 | .register_type::() 74 | .register_type::() 75 | .register_type::() 76 | .register_type::() 77 | .register_type::() 78 | .register_type::>(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/components/src/main.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use blenvy::{BlenvyPlugin, BlueprintInfo, GameWorldTag, HideUntilReady, SpawnBlueprint}; 3 | 4 | mod component_examples; 5 | use component_examples::*; 6 | 7 | fn main() { 8 | App::new() 9 | .add_plugins(( 10 | DefaultPlugins.set(AssetPlugin::default()), 11 | // our custom plugins 12 | ComponentsExamplesPlugin, // Showcases different type of components /structs 13 | BlenvyPlugin::default(), 14 | )) 15 | .add_systems(Startup, setup_game) 16 | .run(); 17 | } 18 | 19 | fn setup_game(mut commands: Commands) { 20 | // here we actually spawn our game world/level 21 | commands.spawn(( 22 | BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info... 23 | SpawnBlueprint, // and spawnblueprint to tell blenvy to spawn the blueprint now 24 | HideUntilReady, // only reveal the level once it is ready 25 | GameWorldTag, 26 | )); 27 | } 28 | -------------------------------------------------------------------------------- /examples/demo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "blenvy_demo" 3 | version = "0.3.0" 4 | edition = "2021" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [dependencies] 8 | bevy = { version = "0.14", features = ["dynamic_linking"] } 9 | blenvy = { path = "../../crates/blenvy" } 10 | rand = "0.8.5" 11 | avian3d = "0.1.2" -------------------------------------------------------------------------------- /examples/demo/README.md: -------------------------------------------------------------------------------- 1 | # Multiple levels from multiple blend files example/demo 2 | 3 | This example showcases multiple levels, each created from a seperate Blend file , with all assets stored in the (common file)[./art/common.blend] 4 | It using triggers to transition to another level. 5 | It currently has NO state persistence between levels. 6 | You can press "D" to toggle the physics debug view. 7 | 8 | 9 | ## Running this example 10 | 11 | ``` 12 | cargo run --features bevy/dynamic_linking 13 | ``` 14 | -------------------------------------------------------------------------------- /examples/demo/art/common.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/art/common.blend -------------------------------------------------------------------------------- /examples/demo/art/level1.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/art/level1.blend -------------------------------------------------------------------------------- /examples/demo/art/level2.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/art/level2.blend -------------------------------------------------------------------------------- /examples/demo/art/start_level.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/art/start_level.blend -------------------------------------------------------------------------------- /examples/demo/assets/materials/common_materials_library.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/materials/common_materials_library.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/Level1.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/Level1.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/Level2.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/Level2.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/StartLevel.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/StartLevel.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Container.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Container.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Crystal.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Crystal.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Health_Pickup.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Health_Pickup.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Interactible.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Interactible.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/LevelTransition.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/LevelTransition.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/MagicTeapot.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/MagicTeapot.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Nest_test.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Nest_test.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Pillar.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Pillar.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Player.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Player.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Portal.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Portal.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Rock Pile.glb: -------------------------------------------------------------------------------- 1 | glTFlXJSON{"asset":{"generator":"Khronos glTF Blender I/O v4.0.44","version":"2.0"},"scene":0,"scenes":[{"name":"__temp_scene_Rock Pile","nodes":[0,1,2,3,4]}],"nodes":[{"extras":{"BlueprintName":"\"Rock\"","SpawnHere":"()"},"name":"Rock"},{"extras":{"BlueprintName":"\"Rock\"","SpawnHere":"()"},"name":"Rock.001","rotation":[0,0.23375636339187622,0,0.9722952842712402],"scale":[0.7496815919876099,0.7496815919876099,0.7496815919876099],"translation":[0,0.5718327760696411,0]},{"extras":{"BlueprintName":"\"Rock\"","SpawnHere":"()"},"name":"Rock.002","rotation":[-0.039098113775253296,0.4883190393447876,0.0876077339053154,0.8673757910728455],"scale":[0.5858102440834045,0.5858102440834045,0.5858102440834045],"translation":[0,1.1614999771118164,0]},{"extras":{"BlueprintName":"\"Rock\"","SpawnHere":"()"},"name":"Rock.003","rotation":[0.015595082193613052,0.5941217541694641,0.0025212683249264956,0.8042200207710266],"scale":[0.32291287183761597,0.32291293144226074,0.32291293144226074],"translation":[0.008193761110305786,1.6521432399749756,0.11666157841682434]},{"extras":{"BlueprintName":"\"Rock\"","SpawnHere":"()"},"name":"Rock.004","rotation":[-0.08937904238700867,0.9130334854125977,0.17200662195682526,0.3588801920413971],"scale":[0.17334319651126862,0.14169900119304657,0.16851022839546204],"translation":[0.01514201145619154,1.8430254459381104,0.11782824993133545]}]} -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Rock.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Rock.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Sub_blueprint.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Sub_blueprint.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Template_Demo.glb: -------------------------------------------------------------------------------- 1 | glTFJSON{"asset":{"generator":"Khronos glTF Blender I/O v4.0.44","version":"2.0"},"scene":0,"scenes":[{"name":"__temp_scene_Template_Demo","nodes":[0,1,2]}],"nodes":[{"extras":{"Bla":1.0},"name":"template_demo_components"},{"extras":{"BlueprintName":"\"Interactible\"","SpawnHere":"()","Template":true},"name":"Template_Interactible"},{"extras":{"BlueprintName":"\"Sub_blueprint\"","SpawnHere":"()","Template":true},"name":"Template_Sub_blueprint","translation":[0.07886017858982086,0.07032553851604462,-0.14496548473834991]}]} -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Unused_in_level_test.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Unused_in_level_test.glb -------------------------------------------------------------------------------- /examples/demo/assets/models/library/Wall.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/demo/assets/models/library/Wall.glb -------------------------------------------------------------------------------- /examples/demo/src/core/audio/mod.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[derive(Component, Reflect, Default, Debug)] 4 | #[reflect(Component)] 5 | pub enum SoundMaterial { 6 | Metal, 7 | Wood, 8 | Rock, 9 | Cloth, 10 | Squishy, 11 | #[default] 12 | None, 13 | } 14 | 15 | 16 | pub struct AudioPlugin; 17 | impl Plugin for AudioPlugin { 18 | fn build(&self, app: &mut App) { 19 | app.register_type::(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/demo/src/core/camera/camera_replace_proxies.rs: -------------------------------------------------------------------------------- 1 | use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings}; 2 | use bevy::core_pipeline::experimental::taa::TemporalAntiAliasBundle; 3 | use bevy::core_pipeline::tonemapping::{DebandDither, Tonemapping}; 4 | use bevy::pbr::ScreenSpaceAmbientOcclusionBundle; 5 | use bevy::prelude::*; 6 | use bevy::render::camera::Exposure; 7 | 8 | use super::CameraTrackingOffset; 9 | 10 | #[derive(Component, Reflect, Default, Debug)] 11 | #[reflect(Component)] 12 | pub struct SSAOSettings; 13 | 14 | #[allow(clippy::type_complexity)] 15 | pub fn camera_replace_proxies( 16 | mut commands: Commands, 17 | mut added_cameras: Query< 18 | ( 19 | Entity, 20 | &mut Camera, 21 | &mut Exposure, 22 | Option<&BloomSettings>, 23 | Option<&SSAOSettings>, 24 | ), 25 | (Added, With), 26 | >, 27 | 28 | added_bloom_settings: Query<&BloomSettings, Added>, 29 | added_ssao_settings: Query<&SSAOSettings, Added>, // Move to camera 30 | ) { 31 | for (entity, mut camera, mut exposure, bloom_settings, ssao_setting) in added_cameras.iter_mut() 32 | { 33 | info!("detected added camera, updating proxy"); 34 | camera.hdr = true; 35 | exposure.ev100 *= 1.0; 36 | commands 37 | .entity(entity) 38 | .insert(DebandDither::Enabled) 39 | .insert(Tonemapping::BlenderFilmic); 40 | 41 | // we only inject the scene_level bloom settings if there are no settings already on the Camera 42 | if bloom_settings.is_none() { 43 | for bloom_settings in added_bloom_settings.iter() { 44 | commands.entity(entity).insert(BloomSettings { 45 | intensity: bloom_settings.intensity, 46 | composite_mode: BloomCompositeMode::Additive, 47 | ..default() 48 | }); 49 | } 50 | } 51 | 52 | if ssao_setting.is_none() { 53 | for _ in added_ssao_settings.iter() { 54 | commands.insert_resource(Msaa::Off); // when using SSAO, you cannot use Msaa 55 | 56 | commands 57 | .entity(entity) 58 | .insert(ScreenSpaceAmbientOcclusionBundle::default()) 59 | .insert(TemporalAntiAliasBundle::default()); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /examples/demo/src/core/camera/camera_tracking.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[derive(Component, Reflect, Debug, Deref, DerefMut)] 4 | #[reflect(Component)] 5 | /// Component for cameras, with an offset from the Trackable target 6 | pub struct CameraTrackingOffset(Vec3); 7 | impl Default for CameraTrackingOffset { 8 | fn default() -> Self { 9 | CameraTrackingOffset(Vec3::new(0.0, 6.0, 8.0)) 10 | } 11 | } 12 | 13 | #[derive(Component, Reflect, Default, Debug)] 14 | #[reflect(Component)] 15 | /// Add this component to an entity if you want it to be tracked by a Camera 16 | pub struct CameraTrackable; 17 | 18 | #[allow(clippy::type_complexity)] 19 | pub fn camera_track( 20 | mut tracking_cameras: Query< 21 | (&mut Transform, &CameraTrackingOffset), 22 | ( 23 | With, 24 | With, 25 | Without, 26 | ), 27 | >, 28 | camera_tracked: Query<&Transform, With>, 29 | ) { 30 | for (mut camera_transform, tracking_offset) in tracking_cameras.iter_mut() { 31 | for tracked_transform in camera_tracked.iter() { 32 | let target_position = tracked_transform.translation + tracking_offset.0; 33 | let eased_position = camera_transform.translation.lerp(target_position, 0.1); 34 | camera_transform.translation = eased_position; // + tracking.offset;// tracked_transform.translation + tracking.offset; 35 | *camera_transform = camera_transform.looking_at(tracked_transform.translation, Vec3::Y); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/demo/src/core/camera/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod camera_tracking; 2 | pub use camera_tracking::*; 3 | 4 | pub mod camera_replace_proxies; 5 | pub use camera_replace_proxies::*; 6 | 7 | use bevy::prelude::*; 8 | use blenvy::GltfBlueprintsSet; 9 | 10 | pub struct CameraPlugin; 11 | impl Plugin for CameraPlugin { 12 | fn build(&self, app: &mut App) { 13 | app.register_type::() 14 | .register_type::() 15 | .register_type::() 16 | .add_systems( 17 | Update, 18 | ( 19 | camera_replace_proxies.after(GltfBlueprintsSet::AfterSpawn), 20 | camera_track, 21 | ), 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/demo/src/core/mod.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use blenvy::*; 3 | 4 | pub struct CorePlugin; 5 | impl Plugin for CorePlugin { 6 | fn build(&self, app: &mut App) { 7 | app.add_plugins((BlenvyPlugin { 8 | ..Default::default() 9 | },)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/demo/src/core/physics_rapier/controls.rs: -------------------------------------------------------------------------------- 1 | use bevy::{ 2 | ecs::system::Res, 3 | input::{keyboard::KeyCode, ButtonInput}, 4 | log::info, 5 | prelude::ResMut, 6 | }; 7 | use bevy_rapier3d::{prelude::RapierConfiguration, render::DebugRenderContext}; 8 | 9 | pub(crate) fn pause_physics(mut physics_config: ResMut) { 10 | info!("pausing physics"); 11 | physics_config.physics_pipeline_active = false; 12 | } 13 | 14 | pub(crate) fn resume_physics(mut physics_config: ResMut) { 15 | info!("unpausing physics"); 16 | physics_config.physics_pipeline_active = true; 17 | } 18 | 19 | pub(crate) fn toggle_physics_debug( 20 | mut debug_config: ResMut, 21 | keycode: Res>, 22 | ) { 23 | if keycode.just_pressed(KeyCode::KeyD) { 24 | debug_config.enabled = !debug_config.enabled; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/demo/src/core/physics_rapier/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod physics_replace_proxies; 2 | pub(crate) use physics_replace_proxies::*; 3 | 4 | pub(crate) mod utils; 5 | 6 | pub(crate) mod controls; 7 | pub(crate) use controls::*; 8 | 9 | use bevy::prelude::*; 10 | use blenvy::GltfBlueprintsSet; 11 | use bevy_gltf_worlflow_examples_common::state::GameState; 12 | use bevy_rapier3d::{ 13 | prelude::{NoUserData, RapierPhysicsPlugin}, 14 | render::RapierDebugRenderPlugin, 15 | }; 16 | 17 | pub(crate) fn plugin(app: &mut App) { 18 | app.add_plugins(( 19 | RapierPhysicsPlugin::::default(), 20 | RapierDebugRenderPlugin::default(), 21 | )) 22 | .register_type::() 23 | .register_type::() 24 | .add_systems( 25 | Update, 26 | physics_replace_proxies.after(GltfBlueprintsSet::AfterSpawn), 27 | ) 28 | .add_systems(Update, toggle_physics_debug) 29 | .add_systems(OnEnter(GameState::InGame), resume_physics) 30 | .add_systems(OnExit(GameState::InGame), pause_physics); 31 | } 32 | -------------------------------------------------------------------------------- /examples/demo/src/core/physics_rapier/utils.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use bevy::render::mesh::PrimitiveTopology; 3 | // TAKEN VERBATIB FROM https://github.com/janhohenheim/foxtrot/blob/src/util/trait_extension.rs 4 | 5 | pub(crate) trait MeshExt { 6 | fn search_in_children<'a>( 7 | parent: Entity, 8 | children: &'a Query<&Children>, 9 | meshes: &'a Assets, 10 | mesh_handles: &'a Query<&Handle>, 11 | ) -> Vec<(Entity, &'a Mesh)>; 12 | } 13 | 14 | impl MeshExt for Mesh { 15 | fn search_in_children<'a>( 16 | parent: Entity, 17 | children_query: &'a Query<&Children>, 18 | meshes: &'a Assets, 19 | mesh_handles: &'a Query<&Handle>, 20 | ) -> Vec<(Entity, &'a Mesh)> { 21 | if let Ok(children) = children_query.get(parent) { 22 | let mut result: Vec<_> = children 23 | .iter() 24 | .filter_map(|entity| mesh_handles.get(*entity).ok().map(|mesh| (*entity, mesh))) 25 | .map(|(entity, mesh_handle)| { 26 | ( 27 | entity, 28 | meshes 29 | .get(mesh_handle) 30 | .expect("Failed to get mesh from handle"), 31 | ) 32 | }) 33 | .map(|(entity, mesh)| { 34 | assert_eq!(mesh.primitive_topology(), PrimitiveTopology::TriangleList); 35 | (entity, mesh) 36 | }) 37 | .collect(); 38 | let mut inner_result = children 39 | .iter() 40 | .flat_map(|entity| { 41 | Self::search_in_children(*entity, children_query, meshes, mesh_handles) 42 | }) 43 | .collect(); 44 | result.append(&mut inner_result); 45 | result 46 | } else { 47 | Vec::new() 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/demo/src/core/physics_xpbd/controls.rs: -------------------------------------------------------------------------------- 1 | use bevy::ecs::system::Res; 2 | use bevy::gizmos::config::GizmoConfigStore; 3 | use bevy::input::keyboard::KeyCode; 4 | use bevy::input::ButtonInput; 5 | use bevy::log::info; 6 | use bevy::{prelude::ResMut, time::Time}; 7 | 8 | use bevy_xpbd_3d::prelude::Physics; 9 | use bevy_xpbd_3d::prelude::*; 10 | 11 | pub(crate) fn pause_physics(mut time: ResMut>) { 12 | info!("pausing physics"); 13 | time.pause(); 14 | } 15 | 16 | pub(crate) fn resume_physics(mut time: ResMut>) { 17 | info!("unpausing physics"); 18 | time.unpause(); 19 | } 20 | 21 | pub(crate) fn toggle_physics_debug( 22 | mut config_store: ResMut, 23 | keycode: Res>, 24 | ) { 25 | if keycode.just_pressed(KeyCode::KeyD) { 26 | let config = config_store.config_mut::().0; 27 | config.enabled = !config.enabled; 28 | // config.aabb_color = Some(Color::WHITE); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/demo/src/core/physics_xpbd/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod physics_replace_proxies; 2 | pub(crate) use physics_replace_proxies::*; 3 | 4 | pub(crate) mod utils; 5 | 6 | pub(crate) mod controls; 7 | pub(crate) use controls::*; 8 | 9 | use bevy::prelude::*; 10 | use bevy_xpbd_3d::prelude::*; 11 | 12 | use blenvy::GltfBlueprintsSet; 13 | use bevy_gltf_worlflow_examples_common::state::GameState; 14 | 15 | pub(crate) fn plugin(app: &mut App) { 16 | app.add_plugins((PhysicsPlugins::default(), PhysicsDebugPlugin::default())) 17 | .register_type::() 18 | .register_type::() 19 | .add_systems( 20 | Update, 21 | physics_replace_proxies.after(GltfBlueprintsSet::AfterSpawn), 22 | ) 23 | .add_systems(Update, toggle_physics_debug) 24 | .add_systems(OnEnter(GameState::InGame), resume_physics) 25 | .add_systems(OnExit(GameState::InGame), pause_physics); 26 | } 27 | -------------------------------------------------------------------------------- /examples/demo/src/core/physics_xpbd/utils.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use bevy::render::mesh::PrimitiveTopology; 3 | // TAKEN VERBATIB FROM https://github.com/janhohenheim/foxtrot/blob/src/util/trait_extension.rs 4 | 5 | pub(crate) trait MeshExt { 6 | fn search_in_children<'a>( 7 | parent: Entity, 8 | children: &'a Query<&Children>, 9 | meshes: &'a Assets, 10 | mesh_handles: &'a Query<&Handle>, 11 | ) -> Vec<(Entity, &'a Mesh)>; 12 | } 13 | 14 | impl MeshExt for Mesh { 15 | fn search_in_children<'a>( 16 | parent: Entity, 17 | children_query: &'a Query<&Children>, 18 | meshes: &'a Assets, 19 | mesh_handles: &'a Query<&Handle>, 20 | ) -> Vec<(Entity, &'a Mesh)> { 21 | if let Ok(children) = children_query.get(parent) { 22 | let mut result: Vec<_> = children 23 | .iter() 24 | .filter_map(|entity| mesh_handles.get(*entity).ok().map(|mesh| (*entity, mesh))) 25 | .map(|(entity, mesh_handle)| { 26 | ( 27 | entity, 28 | meshes 29 | .get(mesh_handle) 30 | .expect("Failed to get mesh from handle"), 31 | ) 32 | }) 33 | .map(|(entity, mesh)| { 34 | assert_eq!(mesh.primitive_topology(), PrimitiveTopology::TriangleList); 35 | (entity, mesh) 36 | }) 37 | .collect(); 38 | let mut inner_result = children 39 | .iter() 40 | .flat_map(|entity| { 41 | Self::search_in_children(*entity, children_query, meshes, mesh_handles) 42 | }) 43 | .collect(); 44 | result.append(&mut inner_result); 45 | result 46 | } else { 47 | Vec::new() 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/demo/src/core/relationships/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod relationships_insert_dependant_components; 2 | pub use relationships_insert_dependant_components::*; 3 | 4 | use bevy::prelude::*; 5 | 6 | pub struct EcsRelationshipsPlugin; 7 | impl Plugin for EcsRelationshipsPlugin { 8 | fn build(&self, app: &mut App) { 9 | app; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/demo/src/core/relationships/relationships_insert_dependant_components.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | pub fn insert_dependant_component< 4 | Dependant: Component, 5 | Dependency: Component + std::default::Default, 6 | >( 7 | mut commands: Commands, 8 | entities_without_depency: Query<(Entity, &Name), (With, Without)>, 9 | ) { 10 | for (entity, name) in entities_without_depency.iter() { 11 | let name = name.clone().to_string(); 12 | commands.entity(entity).insert(Dependency::default()); 13 | warn!("found an entity called {} with a {} component but without an {}, please check your assets", name.clone(), std::any::type_name::(), std::any::type_name::()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/demo/src/game/interactions/mod.rs: -------------------------------------------------------------------------------- 1 | #[derive(Component, Reflect, Default, Debug)] 2 | #[reflect(Component)] 3 | /// Demo marker component 4 | pub struct Interactible; 5 | 6 | pub struct InteractionsPlugin; 7 | impl Plugin for InteractionsPlugin { 8 | fn build(&self, app: &mut App) { 9 | app.register_type::(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/demo/src/game/mod.rs: -------------------------------------------------------------------------------- 1 | // pub mod level_transitions; 2 | // pub use level_transitions::*; 3 | 4 | use bevy::prelude::*; 5 | 6 | pub struct GamePlugin; 7 | impl Plugin for GamePlugin { 8 | fn build(&self, __app: &mut App) { 9 | //app.add_plugins(LevelsPlugin); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/demo/src/game/picking/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::Player; 2 | use bevy::prelude::*; 3 | use blenvy::GltfBlueprintsSet; 4 | 5 | #[derive(Component, Reflect, Default, Debug)] 6 | #[reflect(Component)] 7 | pub struct Pickable; 8 | 9 | // very simple, crude picking (as in picking up objects) implementation 10 | 11 | pub fn picking( 12 | players: Query<&GlobalTransform, With>, 13 | pickables: Query<(Entity, &GlobalTransform), With>, 14 | mut commands: Commands, 15 | ) { 16 | for player_transforms in players.iter() { 17 | for (pickable, pickable_transforms) in pickables.iter() { 18 | let distance = player_transforms 19 | .translation() 20 | .distance(pickable_transforms.translation()); 21 | if distance < 2.5 { 22 | commands.entity(pickable).despawn_recursive(); 23 | } 24 | } 25 | } 26 | } 27 | 28 | pub struct PickingPlugin; 29 | impl Plugin for PickingPlugin { 30 | fn build(&self, app: &mut App) { 31 | app.register_type::() 32 | .add_systems(Update, (picking.after(GltfBlueprintsSet::AfterSpawn),)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/demo/src/game/player/mod.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | use crate::GameState; 4 | 5 | #[derive(Component, Reflect, Default, Debug)] 6 | #[reflect(Component)] 7 | /// Demo marker component 8 | pub struct Player; 9 | 10 | fn player_move_demo( 11 | keycode: Res>, 12 | mut players: Query<&mut Transform, With>, 13 | ) { 14 | let speed = 0.2; 15 | if let Ok(mut player) = players.get_single_mut() { 16 | if keycode.pressed(KeyCode::ArrowLeft) { 17 | player.translation.x += speed; 18 | } 19 | if keycode.pressed(KeyCode::ArrowRight) { 20 | player.translation.x -= speed; 21 | } 22 | 23 | if keycode.pressed(KeyCode::ArrowUp) { 24 | player.translation.z += speed; 25 | } 26 | if keycode.pressed(KeyCode::ArrowDown) { 27 | player.translation.z -= speed; 28 | } 29 | } 30 | } 31 | 32 | pub struct PlayerPlugin; 33 | impl Plugin for PlayerPlugin { 34 | fn build(&self, app: &mut App) { 35 | app.register_type::().add_systems( 36 | Update, 37 | (player_move_demo,).run_if(in_state(GameState::InGame)), 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/demo/src/main.rs: -------------------------------------------------------------------------------- 1 | use avian3d::prelude::*; 2 | use bevy::prelude::*; 3 | use blenvy::{ 4 | AddToGameWorld, BlenvyPlugin, BluePrintBundle, BlueprintInfo, Dynamic, GameWorldTag, 5 | HideUntilReady, SpawnBlueprint, 6 | }; 7 | 8 | mod game; 9 | use game::*; 10 | 11 | mod test_components; 12 | use rand::Rng; 13 | use test_components::*; 14 | 15 | fn main() { 16 | App::new() 17 | .add_plugins(( 18 | DefaultPlugins.set(AssetPlugin::default()), 19 | // our custom plugins 20 | ComponentsExamplesPlugin, // Showcases different type of components /structs 21 | BlenvyPlugin::default(), 22 | GamePlugin, 23 | )) 24 | .add_systems(Startup, setup_game) 25 | .add_systems(Update, spawn_blueprint_instance) 26 | .run(); 27 | } 28 | 29 | // this is how you setup & spawn a level from a blueprint 30 | fn setup_game(mut commands: Commands) { 31 | // here we actually spawn our game world/level 32 | commands.spawn(( 33 | BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info... 34 | SpawnBlueprint, // and spawnblueprint to tell blenvy to spawn the blueprint now 35 | HideUntilReady, // only reveal the level once it is ready 36 | GameWorldTag, 37 | )); 38 | } 39 | 40 | // you can also spawn blueprint instances at runtime 41 | pub fn spawn_blueprint_instance(keycode: Res>, mut commands: Commands) { 42 | if keycode.just_pressed(KeyCode::KeyS) { 43 | let mut rng = rand::thread_rng(); 44 | let range = 5.5; 45 | let x: f32 = rng.gen_range(-range..range); 46 | let y: f32 = rng.gen_range(-range..range); 47 | 48 | let mut rng = rand::thread_rng(); 49 | let range = 0.8; 50 | let vel_x: f32 = rng.gen_range(-range..range); 51 | let vel_y: f32 = rng.gen_range(2.0..2.5); 52 | let vel_z: f32 = rng.gen_range(-range..range); 53 | 54 | let name_index: u64 = rng.gen(); 55 | 56 | let __new_entity = commands 57 | .spawn(( 58 | BluePrintBundle { 59 | blueprint: BlueprintInfo::from_path("blueprints/Health_Pickup.glb"), 60 | ..Default::default() 61 | }, 62 | Dynamic, 63 | bevy::prelude::Name::from(format!("test{}", name_index)), 64 | HideUntilReady, 65 | AddToGameWorld, 66 | TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)), 67 | LinearVelocity(Vec3::new(vel_x, vel_y, vel_z)), 68 | )) 69 | .id(); 70 | // commands.entity(world).add_child(new_entity); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /examples/demo/src/state.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Default, States)] 4 | pub enum AppState { 5 | #[default] 6 | CoreLoading, 7 | MenuRunning, 8 | AppLoading, 9 | AppRunning, 10 | AppEnding, 11 | } 12 | 13 | #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Default, States)] 14 | pub enum GameState { 15 | #[default] 16 | None, 17 | 18 | InMenu, 19 | InGame, 20 | 21 | InGameOver, 22 | 23 | InSaving, 24 | InLoading, 25 | } 26 | 27 | // tag components for all entities within a certain state (for despawning them if needed) , FIXME: seems kinda hack-ish 28 | #[derive(Component)] 29 | pub struct InCoreLoading; 30 | #[derive(Component, Default)] 31 | pub struct InMenuRunning; 32 | #[derive(Component)] 33 | 34 | pub struct InAppRunning; 35 | 36 | // components for tagging in game vs in game menu stuff 37 | #[derive(Component, Default)] 38 | pub struct InMainMenu; 39 | 40 | #[derive(Component, Default)] 41 | pub struct InMenu; 42 | 43 | #[derive(Component, Default)] 44 | pub struct InGame; 45 | 46 | #[derive(Component, Default)] 47 | pub struct InGameSaving; 48 | 49 | #[derive(Component, Default)] 50 | pub struct InGameLoading; 51 | 52 | pub struct StatePlugin; 53 | impl Plugin for StatePlugin { 54 | fn build(&self, app: &mut App) { 55 | app.init_state::().init_state::(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /examples/demo/src/test_components.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[derive(Component, Reflect, Default, Debug)] 4 | #[reflect(Component)] 5 | struct UnitTest; 6 | 7 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 8 | #[reflect(Component)] 9 | struct TupleTestF32(f32); 10 | 11 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 12 | #[reflect(Component)] 13 | struct TupleTestU64(u64); 14 | 15 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 16 | #[reflect(Component)] 17 | pub struct TupleTestStr(String); 18 | 19 | #[derive(Component, Reflect, Default, Debug)] 20 | #[reflect(Component)] 21 | struct TupleTest2(f32, u64, String); 22 | 23 | #[derive(Component, Reflect, Default, Debug)] 24 | #[reflect(Component)] 25 | struct TupleTestBool(bool); 26 | 27 | #[derive(Component, Reflect, Default, Debug)] 28 | #[reflect(Component)] 29 | struct TupleVec2(Vec2); 30 | 31 | #[derive(Component, Reflect, Default, Debug)] 32 | #[reflect(Component)] 33 | struct TupleVec3(Vec3); 34 | 35 | #[derive(Component, Reflect, Default, Debug)] 36 | #[reflect(Component)] 37 | struct TupleVec(Vec); 38 | 39 | #[derive(Component, Reflect, Default, Debug)] 40 | #[reflect(Component)] 41 | struct TupleTestColor(Color); 42 | 43 | #[derive(Component, Reflect, Default, Debug)] 44 | #[reflect(Component)] 45 | struct BasicTest { 46 | a: f32, 47 | b: u64, 48 | c: String, 49 | } 50 | 51 | #[derive(Component, Reflect, Default, Debug)] 52 | #[reflect(Component)] 53 | pub enum EnumTest { 54 | Metal, 55 | Wood, 56 | Rock, 57 | Cloth, 58 | Squishy, 59 | #[default] 60 | None, 61 | } 62 | 63 | pub struct ComponentsExamplesPlugin; 64 | impl Plugin for ComponentsExamplesPlugin { 65 | fn build(&self, app: &mut App) { 66 | app.register_type::() 67 | .register_type::() 68 | .register_type::() 69 | .register_type::() 70 | .register_type::() 71 | .register_type::() 72 | .register_type::() 73 | .register_type::() 74 | .register_type::() 75 | .register_type::() 76 | .register_type::() 77 | .register_type::() 78 | .register_type::>(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/save_load/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bevy_gltf_save_load_basic_example" 3 | version = "0.3.0" 4 | edition = "2021" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [dependencies] 8 | bevy = { version = "0.14", features = ["dynamic_linking"] } 9 | blenvy = { path = "../../crates/blenvy" } 10 | 11 | serde_json = "1.0.108" 12 | serde = "1.0.193" 13 | rand = "0.8.5" 14 | 15 | bevy-inspector-egui = { version = "0.25.1"} 16 | 17 | [dev-dependencies] 18 | bevy-inspector-egui = { version = "0.25.1"} -------------------------------------------------------------------------------- /examples/save_load/README.md: -------------------------------------------------------------------------------- 1 | # Basic save_load example/demo 2 | 3 | This example showcases how to use ```bevy_save_load``` crate to save & load your bevy game 4 | 5 | ## Notes Workflow with blender / demo information 6 | 7 | - the gltf files for this demo where generated using the **Export dynamic and static objects seperatly** feature of the blenvy addon: 8 | so the static & dynamic level files where generated automatically, based on the entities that have a **Dynamic** component/custom property 9 | 10 | 11 | ## Running this example 12 | 13 | ``` 14 | cargo run --features bevy/dynamic_linking 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /examples/save_load/art/save_load.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/save_load/art/save_load.blend -------------------------------------------------------------------------------- /examples/save_load/assets/.save.ron: -------------------------------------------------------------------------------- 1 | (dynamic: assets/, static: levels/world.glb) -------------------------------------------------------------------------------- /examples/save_load/assets/blueprints/Dynamic_hierarchy.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/save_load/assets/blueprints/Dynamic_hierarchy.glb -------------------------------------------------------------------------------- /examples/save_load/assets/blueprints/Dynamic_hierarchy.meta.ron: -------------------------------------------------------------------------------- 1 | ( 2 | assets: 3 | [ 4 | ] 5 | ) -------------------------------------------------------------------------------- /examples/save_load/assets/blueprints/Dynamic_inside_static.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/save_load/assets/blueprints/Dynamic_inside_static.glb -------------------------------------------------------------------------------- /examples/save_load/assets/blueprints/Dynamic_inside_static.meta.ron: -------------------------------------------------------------------------------- 1 | ( 2 | assets: 3 | [ 4 | ("Mover", File ( path: "blueprints/Mover.glb" )), 5 | ("Material.001", File ( path: "materials/Material.001.glb" )), 6 | ] 7 | ) -------------------------------------------------------------------------------- /examples/save_load/assets/blueprints/Mover.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/save_load/assets/blueprints/Mover.glb -------------------------------------------------------------------------------- /examples/save_load/assets/blueprints/Mover.meta.ron: -------------------------------------------------------------------------------- 1 | ( 2 | assets: 3 | [ 4 | ] 5 | ) -------------------------------------------------------------------------------- /examples/save_load/assets/blueprints/Pillar.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/save_load/assets/blueprints/Pillar.glb -------------------------------------------------------------------------------- /examples/save_load/assets/blueprints/Pillar.meta.ron: -------------------------------------------------------------------------------- 1 | ( 2 | assets: 3 | [ 4 | ] 5 | ) -------------------------------------------------------------------------------- /examples/save_load/assets/levels/World.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/save_load/assets/levels/World.glb -------------------------------------------------------------------------------- /examples/save_load/assets/levels/World.meta.ron: -------------------------------------------------------------------------------- 1 | ( 2 | assets: 3 | [ 4 | ("Pillar", File ( path: "blueprints/Pillar.glb" )), 5 | ("Stone", File ( path: "materials/Stone.glb" )), 6 | ("Mover", File ( path: "blueprints/Mover.glb" )), 7 | ("Material.001", File ( path: "materials/Material.001.glb" )), 8 | ("Dynamic_hierarchy", File ( path: "blueprints/Dynamic_hierarchy.glb" )), 9 | ("Dynamic_inside_static", File ( path: "blueprints/Dynamic_inside_static.glb" )), 10 | ("Mover", File ( path: "blueprints/Mover.glb" )), 11 | ("Material.001", File ( path: "materials/Material.001.glb" )), 12 | ] 13 | ) -------------------------------------------------------------------------------- /examples/save_load/assets/levels/World_dynamic.glb: -------------------------------------------------------------------------------- 1 | glTFP<JSON{"asset":{"generator":"Khronos glTF Blender I/O v4.2.57","version":"2.0"},"scene":0,"scenes":[{"extras":{"id_test":"f9ca7d0f-b8c8-4e8f-9dfd-1fc51f97a9b6","BlueprintAssets":"(assets: [(name: \"Pillar\", path: \"blueprints/Pillar.glb\"), (name: \"Stone\", path: \"materials/Stone.glb\"), (name: \"Mover\", path: \"blueprints/Mover.glb\"), (name: \"Material.001\", path: \"materials/Material.001.glb\"), (name: \"Dynamic_hierarchy\", path: \"blueprints/Dynamic_hierarchy.glb\"), (name: \"Dynamic_inside_static\", path: \"blueprints/Dynamic_inside_static.glb\"), (name: \"Mover\", path: \"blueprints/Mover.glb\"), (name: \"Material.001\", path: \"materials/Material.001.glb\")])"},"name":"__temp_scene","nodes":[2]}],"nodes":[{"extras":{"SpawnBlueprint":"()","BlueprintInfo":"(name: \"Dynamic_hierarchy\", path: \"blueprints/Dynamic_hierarchy.glb\")"},"name":"Dynamic_hierarchy","rotation":[0.10570976138114929,0.03834201768040657,0.09289465099573135,0.9893057942390442],"scale":[0.5394739508628845,0.5394739508628845,0.5394738912582397],"translation":[-2.577773332595825,1.2997229099273682,2.397195816040039]},{"extras":{"SpawnBlueprint":"()","BlueprintInfo":"(name: \"Mover\", path: \"blueprints/Mover.glb\")"},"name":"Mover","translation":[-0.07128417491912842,1.19514000415802,-0.790912389755249]},{"children":[0,1],"name":"Collection"}]} -------------------------------------------------------------------------------- /examples/save_load/assets/materials/Dots Stroke.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/save_load/assets/materials/Dots Stroke.glb -------------------------------------------------------------------------------- /examples/save_load/assets/materials/Material.001.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/save_load/assets/materials/Material.001.glb -------------------------------------------------------------------------------- /examples/save_load/assets/materials/Stone.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/examples/save_load/assets/materials/Stone.glb -------------------------------------------------------------------------------- /examples/save_load/assets/scenes/save.scn.ron.save.ron: -------------------------------------------------------------------------------- 1 | (dynamic: assets/scenes/save.scn.ron, static: levels/world.glb) -------------------------------------------------------------------------------- /examples/save_load/src/component_examples.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[derive(Component, Reflect, Default, Debug)] 4 | #[reflect(Component)] 5 | struct UnitTest; 6 | 7 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 8 | #[reflect(Component)] 9 | struct TupleTestF32(f32); 10 | 11 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 12 | #[reflect(Component)] 13 | struct TupleTestU64(u64); 14 | 15 | #[derive(Component, Reflect, Default, Debug, Deref, DerefMut)] 16 | #[reflect(Component)] 17 | pub struct TupleTestStr(String); 18 | 19 | #[derive(Component, Reflect, Default, Debug)] 20 | #[reflect(Component)] 21 | struct TupleTest2(f32, u64, String); 22 | 23 | #[derive(Component, Reflect, Default, Debug)] 24 | #[reflect(Component)] 25 | struct TupleTestBool(bool); 26 | 27 | #[derive(Component, Reflect, Default, Debug)] 28 | #[reflect(Component)] 29 | struct TupleVec2(Vec2); 30 | 31 | #[derive(Component, Reflect, Default, Debug)] 32 | #[reflect(Component)] 33 | struct TupleVec3(Vec3); 34 | 35 | #[derive(Component, Reflect, Default, Debug)] 36 | #[reflect(Component)] 37 | struct TupleVec(Vec); 38 | 39 | #[derive(Component, Reflect, Default, Debug)] 40 | #[reflect(Component)] 41 | struct TupleTestColor(Color); 42 | 43 | #[derive(Component, Reflect, Default, Debug)] 44 | #[reflect(Component)] 45 | struct BasicTest { 46 | a: f32, 47 | b: u64, 48 | c: String, 49 | } 50 | 51 | #[derive(Component, Reflect, Default, Debug)] 52 | #[reflect(Component)] 53 | pub enum EnumTest { 54 | Metal, 55 | Wood, 56 | Rock, 57 | Cloth, 58 | Squishy, 59 | #[default] 60 | None, 61 | } 62 | 63 | pub struct ComponentsExamplesPlugin; 64 | impl Plugin for ComponentsExamplesPlugin { 65 | fn build(&self, app: &mut App) { 66 | app.register_type::() 67 | .register_type::() 68 | .register_type::() 69 | .register_type::() 70 | .register_type::() 71 | .register_type::() 72 | .register_type::() 73 | .register_type::() 74 | .register_type::() 75 | .register_type::() 76 | .register_type::() 77 | .register_type::() 78 | .register_type::>(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/save_load/src/game/in_game_loading.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use bevy_gltf_worlflow_examples_common_rapier::InGameLoading; 3 | 4 | pub fn setup_loading_screen(mut commands: Commands) { 5 | commands.spawn(( 6 | Camera2dBundle { 7 | camera: Camera { 8 | clear_color: ClearColorConfig::Custom(Color::BLACK), 9 | // renders after / on top of the main camera 10 | order: 2, 11 | ..default() 12 | }, 13 | ..Default::default() 14 | }, 15 | InGameLoading, 16 | )); 17 | 18 | commands.spawn(( 19 | TextBundle::from_section( 20 | "Loading...", 21 | TextStyle { 22 | font_size: 28.0, 23 | color: Color::WHITE, 24 | ..Default::default() 25 | }, 26 | ) 27 | .with_style(Style { 28 | position_type: PositionType::Relative, 29 | top: Val::Percent(45.0), 30 | left: Val::Percent(45.0), 31 | ..default() 32 | }), 33 | InGameLoading, 34 | )); 35 | } 36 | 37 | pub fn teardown_loading_screen( 38 | in_main_menu: Query>, 39 | mut commands: Commands, 40 | ) { 41 | for entity in in_main_menu.iter() { 42 | commands.entity(entity).despawn_recursive(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/save_load/src/game/in_game_saving.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use bevy_gltf_worlflow_examples_common_rapier::InGameSaving; 3 | 4 | pub fn setup_saving_screen(mut commands: Commands) { 5 | commands.spawn(( 6 | TextBundle::from_section( 7 | "Saving...", 8 | TextStyle { 9 | font_size: 28.0, 10 | color: Color::WHITE, 11 | ..Default::default() 12 | }, 13 | ) 14 | .with_style(Style { 15 | position_type: PositionType::Relative, 16 | top: Val::Percent(90.0), 17 | left: Val::Percent(80.0), 18 | ..default() 19 | }), 20 | InGameSaving, 21 | )); 22 | } 23 | 24 | pub fn teardown_saving_screen( 25 | in_main_menu: Query>, 26 | mut commands: Commands, 27 | ) { 28 | for entity in in_main_menu.iter() { 29 | commands.entity(entity).despawn_recursive(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = 'stable' 3 | -------------------------------------------------------------------------------- /testing/bevy_example/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bevy_example" 3 | version = "0.3.0" 4 | edition = "2021" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [dependencies] 8 | bevy = { version = "0.14", features = ["dynamic_linking"] } 9 | blenvy = { path = "../../crates/blenvy" } 10 | #bevy_editor_pls = { version = "0.8" } 11 | rand = "0.8.5" 12 | json-writer ="0.3" 13 | 14 | [dev-dependencies] 15 | bevy-inspector-egui = { version = "0.25.1"} -------------------------------------------------------------------------------- /testing/bevy_example/README.md: -------------------------------------------------------------------------------- 1 | # Bevy registry export example/demo 2 | 3 | This example showcases 4 | * the use of the blenvy crate to extract all components & types information into a json file. 5 | * 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, 6 | to be able to add & edit Bevy components easilly in Blender ! 7 | 8 | 9 | ## Running this example 10 | 11 | ``` 12 | cargo run --features bevy/dynamic_linking 13 | ``` 14 | 15 | Running the example also regenerates the registry.json file. 16 | -------------------------------------------------------------------------------- /testing/bevy_example/art/testing.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/testing/bevy_example/art/testing.blend -------------------------------------------------------------------------------- /testing/bevy_example/art/testing_library.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/testing/bevy_example/art/testing_library.blend -------------------------------------------------------------------------------- /testing/bevy_example/art/testing_simple.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/testing/bevy_example/art/testing_simple.blend -------------------------------------------------------------------------------- /testing/bevy_example/assets/assets_core.assets.ron: -------------------------------------------------------------------------------- 1 | ({}) -------------------------------------------------------------------------------- /testing/bevy_example/assets/assets_game.assets.ron: -------------------------------------------------------------------------------- 1 | ({ 2 | /*"world":File (path: "models/World.glb"), 3 | "models": Folder ( 4 | path: "models/library", 5 | ),*/ 6 | }) -------------------------------------------------------------------------------- /testing/bevy_example/assets/audio/assets_sounds_breakout_collision.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/testing/bevy_example/assets/audio/assets_sounds_breakout_collision.ogg -------------------------------------------------------------------------------- /testing/bevy_example/assets/audio/fake.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/testing/bevy_example/assets/audio/fake.mp3 -------------------------------------------------------------------------------- /testing/bevy_example/assets/text/test.txt: -------------------------------------------------------------------------------- 1 | some text -------------------------------------------------------------------------------- /testing/bevy_example/src/core/mod.rs: -------------------------------------------------------------------------------- 1 | use std::any::TypeId; 2 | 3 | use bevy::{prelude::*, utils::HashSet}; 4 | use blenvy::*; 5 | 6 | /*use blenvy::*; 7 | use blenvy::*; */ 8 | 9 | use crate::{ComponentAToFilterOut, ComponentBToFilterOut}; 10 | 11 | pub struct CorePlugin; 12 | impl Plugin for CorePlugin { 13 | fn build(&self, app: &mut App) { 14 | app.add_plugins( 15 | BlenvyPlugin { 16 | registry_component_filter: SceneFilter::Denylist(HashSet::from([ 17 | // this is using Bevy's build in SceneFilter, you can compose what components you want to allow/deny 18 | TypeId::of::(), 19 | TypeId::of::(), 20 | // and any other commponent you want to include/exclude 21 | ])), 22 | ..Default::default() 23 | }, /* ExportRegistryPlugin { 24 | component_filter: SceneFilter::Denylist(HashSet::from([ 25 | // this is using Bevy's build in SceneFilter, you can compose what components you want to allow/deny 26 | TypeId::of::(), 27 | TypeId::of::(), 28 | // and any other commponent you want to include/exclude 29 | ])), 30 | ..Default::default() 31 | }, 32 | BlueprintsPlugin { 33 | material_library: true, 34 | aabbs: true, 35 | ..Default::default() 36 | }, */ 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /testing/bevy_example/src/dupe_components/mod.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[derive(Component, Reflect, Default, Debug)] 4 | #[reflect(Component)] 5 | pub enum EnumTest { 6 | Metal, 7 | Wood, 8 | Rock, 9 | Cloth, 10 | Squishy, 11 | #[default] 12 | None, 13 | } 14 | -------------------------------------------------------------------------------- /testing/bevy_example/src/game/in_game.rs: -------------------------------------------------------------------------------- 1 | use crate::{GameState, InAppRunning}; 2 | use bevy::prelude::*; 3 | use blenvy::{ 4 | AddToGameWorld, BluePrintBundle, BlueprintInfo, Dynamic, GameWorldTag, HideUntilReady, 5 | SpawnBlueprint, 6 | }; 7 | 8 | //use bevy_rapier3d::prelude::Velocity; 9 | use rand::Rng; 10 | 11 | pub fn setup_game(mut commands: Commands, mut next_game_state: ResMut>) { 12 | // here we actually spawn our game world/level 13 | commands.spawn(( 14 | BlueprintInfo::from_path("levels/World.glb"), 15 | HideUntilReady, 16 | SpawnBlueprint, 17 | GameWorldTag, 18 | InAppRunning, 19 | )); 20 | 21 | next_game_state.set(GameState::InGame) 22 | } 23 | 24 | #[derive(Component, Reflect, Default, Debug)] 25 | #[reflect(Component)] 26 | struct UnregisteredComponent; 27 | 28 | pub fn spawn_test(keycode: Res>, mut commands: Commands) { 29 | if keycode.just_pressed(KeyCode::KeyS) { 30 | let mut rng = rand::thread_rng(); 31 | let range = 5.5; 32 | let x: f32 = rng.gen_range(-range..range); 33 | let y: f32 = rng.gen_range(-range..range); 34 | 35 | /*let mut rng = rand::thread_rng(); 36 | let range = 0.8; 37 | let vel_x: f32 = rng.gen_range(-range..range); 38 | let vel_y: f32 = rng.gen_range(2.0..2.5); 39 | let vel_z: f32 = rng.gen_range(-range..range);*/ 40 | 41 | let name_index: u64 = rng.gen(); 42 | 43 | let __new_entity = commands 44 | .spawn(( 45 | BluePrintBundle { 46 | blueprint: BlueprintInfo { 47 | name: "spawned".into(), 48 | path: "blueprints/Blueprint 3.gltf".into(), 49 | }, // FIXME 50 | ..Default::default() 51 | }, 52 | Dynamic, 53 | bevy::prelude::Name::from(format!("test{}", name_index)), 54 | HideUntilReady, 55 | AddToGameWorld, 56 | TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)), 57 | /*Velocity { 58 | linvel: Vec3::new(vel_x, vel_y, vel_z), 59 | angvel: Vec3::new(0.0, 0.0, 0.0), 60 | },*/ 61 | )) 62 | .id(); 63 | //commands.entity(world).add_child(new_entity); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /testing/bevy_example/src/main.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | // use bevy_gltf_worlflow_examples_common::CommonPlugin; 3 | mod state; 4 | use state::*; 5 | 6 | mod core; 7 | use crate::core::*; 8 | 9 | mod game; 10 | use game::*; 11 | 12 | mod dupe_components; 13 | mod test_components; 14 | use test_components::*; 15 | 16 | mod hierarchy_debug; 17 | use hierarchy_debug::*; 18 | 19 | fn main() { 20 | App::new() 21 | .add_plugins(( 22 | DefaultPlugins.set(AssetPlugin::default()), 23 | HiearchyDebugPlugin, 24 | // our custom plugins 25 | // CommonPlugin, 26 | StatePlugin, 27 | CorePlugin, // reusable plugins 28 | GamePlugin, // specific to our game 29 | ComponentsTestPlugin, // Showcases different type of components /structs 30 | )) 31 | .run(); 32 | } 33 | -------------------------------------------------------------------------------- /testing/bevy_example/src/state.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | #[allow(dead_code)] 4 | #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Default, States)] 5 | pub enum AppState { 6 | CoreLoading, 7 | #[default] 8 | MenuRunning, 9 | AppLoading, 10 | AppRunning, 11 | AppEnding, 12 | } 13 | 14 | #[allow(dead_code)] 15 | #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Default, States)] 16 | pub enum GameState { 17 | #[default] 18 | None, 19 | 20 | InMenu, 21 | InGame, 22 | 23 | InGameOver, 24 | 25 | InSaving, 26 | InLoading, 27 | } 28 | 29 | // tag components for all entities within a certain state (for despawning them if needed) , FIXME: seems kinda hack-ish 30 | #[derive(Component, Default)] 31 | pub struct InMenuRunning; 32 | #[derive(Component)] 33 | 34 | pub struct InAppRunning; 35 | 36 | // components for tagging in game vs in game menu stuff 37 | #[derive(Component, Default)] 38 | pub struct InMainMenu; 39 | 40 | #[derive(Component, Default)] 41 | pub struct InMenu; 42 | 43 | #[derive(Component, Default)] 44 | pub struct InGame; 45 | 46 | #[derive(Component, Default)] 47 | pub struct InGameSaving; 48 | 49 | #[derive(Component, Default)] 50 | pub struct InGameLoading; 51 | 52 | pub struct StatePlugin; 53 | impl Plugin for StatePlugin { 54 | fn build(&self, app: &mut App) { 55 | app.init_state::().init_state::(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tools/blenvy/README-levels.md: -------------------------------------------------------------------------------- 1 | # Levels 2 | 3 | ## What are levels ? 4 | 5 | - any Blender scene that has been tagged as a level in the Blenvy settings 6 | 7 | ## How to create levels ? 8 | 9 | - create a Blender scene 10 | - tag it as a level in the Blenvy settings 11 | - place blueprint/collection instances or any normal Blender mesh/object in the scene 12 | - just save your file -------------------------------------------------------------------------------- /tools/blenvy/README-tech.md: -------------------------------------------------------------------------------- 1 | ### Blueprints 2 | 3 | You can enable this option to automatically replace all the **collection instances** inside your level scene with blueprints 4 | - whenever you change your level scene (or your library scene , if that option is enabled), all your collection instances 5 | * will be replaced with empties (this will not be visible to you) 6 | * those empties will have additional custom properties / components : ```BlueprintInfo``` & ```SpawnBlueprint``` 7 | * your level scene/ level will be exported to a much more trimmed down gltf file (see next point) 8 | * all the original collections (that you used to create the instances) will be exported as **seperate gltf files** into the "library" folder 9 | 10 | - this means you will have 11 | * one small main gltf file (your level/world) 12 | * as many gltf files as you have used collections in the level scene , in the library path you specified : 13 | for the included [basic](../../examples/blenvy/basic/) example's [assets](../../examples/blenvy/basic/assets/), it looks something like this: 14 | 15 | ![library](./docs/exported_library_files.png) 16 | 17 | the .blend file that they are generated from can be found [here](../../examples/blenvy/basic/assets/advanced.blend) 18 | 19 | - the above only applies to collections that have **instances** in your level scene! 20 | if you want a specific collection in your library to always get exported regardless of its use, you need to add 21 | a **COLLECTION** (boolean) custom property called ```AutoExport``` set to true 22 | > not at the object level ! the collection level ! 23 | 24 | ![force-export](./docs/force_export.jpg) 25 | 26 | It will get automatically exported like any of the "in-use" collections. 27 | 28 | - you can also get an overview of all the exported collections in the export menu 29 | 30 | ![exported collections](./docs/exported_collections.png) 31 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/animations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/auto_export/animations/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/blueprints/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/auto_export/blueprints/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/auto_export/common/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/common/prepare_and_export.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | 3 | from .project_diff import get_changes_per_scene 4 | from .auto_export import auto_export 5 | from .settings_diff import get_setting_changes 6 | from ....settings import upsert_settings 7 | 8 | # prepare export by gather the changes to the scenes & settings 9 | def prepare_and_export(): 10 | print("prepare and export") 11 | #bpy.context.window_manager.auto_export_tracker.disable_change_detection() 12 | blenvy = bpy.context.window_manager.blenvy 13 | auto_export_settings = blenvy.auto_export 14 | 15 | # if there are no level or blueprint scenes, bail out early 16 | if len(blenvy.level_scenes) == 0 and len(blenvy.library_scenes) == 0: 17 | print("no level or library scenes, skipping auto export") 18 | return 19 | 20 | if auto_export_settings.auto_export: # only do the actual exporting if auto export is actually enabled 21 | # determine changed objects 22 | per_scene_changes, per_collection_changes, per_material_changes, project_hash = get_changes_per_scene(settings=blenvy) 23 | # determine changed parameters 24 | setting_changes, current_common_settings, current_export_settings, current_gltf_settings = get_setting_changes() 25 | print("changes: settings:", setting_changes) 26 | print("changes: scenes:", per_scene_changes) 27 | print("changes: collections:", per_collection_changes) 28 | print("changes: materials:", per_material_changes) 29 | 30 | # do the actual export 31 | # blenvy.auto_export.dry_run = 'NO_EXPORT'#'DISABLED'# 32 | auto_export(per_scene_changes, per_collection_changes, per_material_changes, setting_changes, blenvy) 33 | 34 | # ------------------------------------- 35 | # now that this point is reached, the export should have run correctly, so we can save all the current state to the "previous one" 36 | for scene in bpy.data.scenes: 37 | blenvy.scenes_to_scene_names[scene] = scene.name 38 | print("bla", blenvy.scenes_to_scene_names, "hash", project_hash) 39 | # save the current project hash as previous 40 | upsert_settings(".blenvy.project_serialized_previous", project_hash, overwrite=True) 41 | # write the new settings to the old settings 42 | upsert_settings(".blenvy_common_settings_previous", current_common_settings, overwrite=True) 43 | upsert_settings(".blenvy_export_settings_previous", current_export_settings, overwrite=True) 44 | upsert_settings(".blenvy_gltf_settings_previous", current_gltf_settings, overwrite=True) 45 | 46 | # cleanup 47 | # TODO: these are likely obsolete 48 | # reset the list of changes in the tracker 49 | #bpy.context.window_manager.auto_export_tracker.clear_changes() 50 | print("AUTO EXPORT DONE") 51 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/common/settings_diff.py: -------------------------------------------------------------------------------- 1 | from ....settings import are_settings_identical, load_settings, changed_settings 2 | 3 | # which common settings changes should trigger a re-export 4 | parameter_names_whitelist_common = [ 5 | # blenvy core 6 | 'project_root_path', 7 | 'assets_path', 8 | 'blueprints_path', 9 | 'levels_path', 10 | 'materials_path', 11 | 'level_scene_names', 12 | 'library_scene_names', 13 | ] 14 | 15 | # which auto export settings changes should trigger a re-export 16 | parameter_names_whitelist_auto_export = [ 17 | # auto export 18 | 'match_blender_visuals', 19 | 'export_blueprints', 20 | 'export_separate_dynamic_and_static_objects', 21 | 'split_out_materials', 22 | 'collection_instances_combine_mode', 23 | ] 24 | 25 | def get_setting_changes(): 26 | previous_common_settings = load_settings(".blenvy_common_settings_previous") 27 | current_common_settings = load_settings(".blenvy_common_settings") 28 | changed_common_settings_fields = changed_settings(previous_common_settings, current_common_settings, white_list=parameter_names_whitelist_common) 29 | common_settings_changed = len(changed_common_settings_fields) > 0 30 | 31 | previous_export_settings = load_settings(".blenvy_export_settings_previous") 32 | current_export_settings = load_settings(".blenvy_export_settings") 33 | changed_export_settings_fields = changed_settings(previous_export_settings, current_export_settings, white_list=parameter_names_whitelist_auto_export) 34 | export_settings_changed = len(changed_export_settings_fields) > 0 35 | 36 | previous_gltf_settings = load_settings(".blenvy_gltf_settings_previous") 37 | current_gltf_settings = load_settings(".blenvy_gltf_settings") 38 | gltf_settings_changed = not are_settings_identical(previous_gltf_settings, current_gltf_settings) 39 | 40 | settings_changed = common_settings_changed or gltf_settings_changed or export_settings_changed 41 | 42 | # if there were no setting before, it is new, we need export # TODO: do we even need this ? I guess in the case where both the previous & the new one are both none ? very unlikely, but still 43 | if previous_common_settings is None: 44 | settings_changed = True 45 | if previous_export_settings is None: 46 | settings_changed = True 47 | if previous_gltf_settings is None: 48 | settings_changed = True 49 | 50 | 51 | return settings_changed, current_common_settings, current_export_settings, current_gltf_settings 52 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/constants.py: -------------------------------------------------------------------------------- 1 | TEMPSCENE_PREFIX = "__temp_scene" 2 | 3 | #hard coded custom properties to ignore on export 4 | custom_properties_to_filter_out = [ 5 | 'glTF2ExportSettings', 6 | 'assets', 'user_assets', 'Generated_assets', 'generated_assets', 7 | 'components_meta', 'Components_meta', 8 | '_combine', 'template', 9 | 'Blenvy_scene_type', 'blenvy_scene_type', 10 | 'materials_path', 'export_path', 11 | ] 12 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/levels/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/auto_export/levels/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/levels/bevy_scene_components.py: -------------------------------------------------------------------------------- 1 | def upsert_scene_components(level_scenes): 2 | for scene in level_scenes: 3 | if scene.world is not None: 4 | scene['BlenderBackgroundShader'] = ambient_color_to_component(scene.world) 5 | scene['BlenderShadowSettings'] = scene_shadows_to_component(scene) 6 | 7 | if scene.eevee.use_bloom: 8 | scene['BloomSettings'] = scene_bloom_to_component(scene) 9 | elif 'BloomSettings' in scene: 10 | del scene['BloomSettings'] 11 | 12 | if scene.eevee.use_gtao: 13 | scene['SSAOSettings'] = scene_ao_to_component(scene) 14 | elif 'SSAOSettings' in scene: 15 | del scene['SSAOSettings'] 16 | 17 | scene['BlenderToneMapping'] = scene_tonemapping_to_component(scene) 18 | scene['BlenderColorGrading'] = scene_colorgrading_to_component(scene) 19 | 20 | def remove_scene_components(level_scenes): 21 | pass 22 | 23 | def scene_tonemapping_to_component(scene): 24 | tone_mapping = scene.view_settings.view_transform 25 | blender_to_bevy = { 26 | 'NONE': 'None', 27 | 'AgX': 'AgX', 28 | 'Filmic': 'Filmic', 29 | } 30 | bevy_tone_mapping = blender_to_bevy[tone_mapping] if tone_mapping in blender_to_bevy else 'None' 31 | return bevy_tone_mapping 32 | 33 | def scene_colorgrading_to_component(scene): 34 | return f"(exposure: {scene.view_settings.exposure}, gamma: {scene.view_settings.gamma})" 35 | 36 | 37 | def ambient_color_to_component(world): 38 | color = None 39 | strength = None 40 | try: 41 | color = world.node_tree.nodes['Background'].inputs[0].default_value 42 | strength = world.node_tree.nodes['Background'].inputs[1].default_value 43 | except Exception as ex: 44 | print("failed to parse ambient color: Only background is supported") 45 | 46 | if color is not None and strength is not None: 47 | colorRgba = f"LinearRgba((red: {color[0]}, green: {color[1]}, blue: {color[2]}, alpha: {color[3]}))" 48 | component = f"( color: {colorRgba}, strength: {strength})" 49 | return component 50 | return None 51 | 52 | def scene_shadows_to_component(scene): 53 | cascade_size = scene.eevee.shadow_cascade_size 54 | component = f"(cascade_size: {cascade_size})" 55 | return component 56 | 57 | def scene_bloom_to_component(scene): 58 | component = f"BloomSettings(intensity: {scene.eevee.bloom_intensity})" 59 | return component 60 | 61 | def scene_ao_to_component(scene): 62 | ssao = scene.eevee.use_gtao 63 | component= "SSAOSettings()" 64 | return component 65 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/levels/is_object_dynamic.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | 3 | from ...bevy_components.components.metadata import get_bevy_component_value_by_long_name 4 | 5 | # checks if an object is dynamic 6 | # TODO: we need to recompute these on blueprint changes too 7 | # even better, keep a list of dynamic objects per scene , updated only when needed ? 8 | def is_object_dynamic(object): 9 | is_dynamic = get_bevy_component_value_by_long_name(object, 'blenvy::save_load::Dynamic') is not None 10 | #is_dynamic = object['Dynamic'] if 'Dynamic' in object else False 11 | # only look for data in the original collection if it is not alread marked as dynamic at instance level 12 | if not is_dynamic and object.type == 'EMPTY' and hasattr(object, 'instance_collection') and object.instance_collection is not None : 13 | #print("collection", object.instance_collection, "object", object.name) 14 | # get the name of the collection this is an instance of 15 | collection_name = object.instance_collection.name 16 | original_collection = bpy.data.collections[collection_name] 17 | # scan original collection, look for a 'Dynamic' flag 18 | is_dynamic = get_bevy_component_value_by_long_name(original_collection, 'blenvy::save_load::Dynamic') is not None 19 | 20 | #print("IS OBJECT DYNAMIC", object, is_dynamic) 21 | 22 | return is_dynamic 23 | 24 | def is_object_static(object): 25 | return not is_object_dynamic(object) -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/materials/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/auto_export/materials/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/materials/get_materials_to_export.py: -------------------------------------------------------------------------------- 1 | 2 | import bpy 3 | from ....materials.materials_helpers import find_materials_not_on_disk 4 | 5 | def get_materials_to_export(changes_per_material, changed_export_parameters, blueprints_data, settings): 6 | export_gltf_extension = getattr(settings, "export_gltf_extension", ".glb") 7 | materials_path_full = getattr(settings, "materials_path_full", "") 8 | 9 | change_detection = getattr(settings.auto_export, "change_detection") 10 | split_out_materials = getattr(settings.auto_export, "split_out_materials") 11 | 12 | all_materials = bpy.data.materials 13 | local_materials = [material for material in all_materials if material.library is None] 14 | materials_to_export = [] 15 | 16 | # print("split_out_materials", split_out_materials, "change detection", change_detection, "changed_export_parameters", changed_export_parameters) 17 | if split_out_materials and change_detection: 18 | if changed_export_parameters: 19 | materials_to_export = local_materials 20 | else : 21 | changed_materials = [bpy.data.materials[material_name] for material_name in list(changes_per_material.keys())] 22 | 23 | # first check if all materials have already been exported before (if this is the first time the exporter is run 24 | # in your current Blender session for example) 25 | materials_not_on_disk = find_materials_not_on_disk(local_materials, materials_path_full, export_gltf_extension) 26 | 27 | # also deal with blueprints that are always marked as "always_export" 28 | #materials_always_export = [material for material in internal_materials if is_material_always_export(material)] 29 | materials_always_export = [] 30 | materials_to_export = list(set(changed_materials + materials_not_on_disk + materials_always_export)) 31 | print("materials_to_export", materials_to_export, local_materials) 32 | return materials_to_export 33 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/auto_export/ui.py: -------------------------------------------------------------------------------- 1 | def draw_settings_ui(layout, auto_export_settings): 2 | controls_enabled = auto_export_settings.auto_export 3 | 4 | layout.label(text="Auto exports gltf files every time you save your project") 5 | layout.prop(auto_export_settings, "auto_export") 6 | layout.separator() 7 | 8 | header, panel = layout.panel("General", default_closed=False) 9 | header.label(text="General") 10 | if panel: 11 | section = panel.box() 12 | section.enabled = controls_enabled 13 | 14 | op = section.operator("EXPORT_SCENE_OT_gltf", text="Gltf Settings (KEEP 'REMEMBER EXPORT SETTINGS' TOGGLED)")#'glTF 2.0 (.glb/.gltf)') 15 | #op.export_format = 'GLTF_SEPARATE' 16 | op.use_selection=True 17 | op.will_save_settings=True 18 | op.use_visible=True 19 | op.use_renderable=True 20 | op.use_active_collection = True 21 | op.use_active_collection_with_nested=True 22 | op.use_active_scene = True 23 | op.filepath="____dummy____" 24 | op.gltf_export_id = "blenvy" # we specify that we are in a special case 25 | 26 | section.prop(auto_export_settings, "match_blender_visuals") 27 | 28 | header, panel = layout.panel("Change Detection", default_closed=False) 29 | header.label(text="Change Detection") 30 | if panel: 31 | section = panel.box() 32 | section.enabled = controls_enabled 33 | section.prop(auto_export_settings, "change_detection", text="Use change detection") 34 | 35 | 36 | section = section.box() 37 | section.enabled = controls_enabled and auto_export_settings.change_detection 38 | 39 | section.prop(auto_export_settings, "materials_in_depth_scan", text="Detailed materials scan") 40 | section.prop(auto_export_settings, "modifiers_in_depth_scan", text="Detailed modifiers scan") 41 | 42 | header, panel = layout.panel("Blueprints", default_closed=False) 43 | header.label(text="Blueprints") 44 | if panel: 45 | section = layout.box() 46 | section.enabled = controls_enabled 47 | section.prop(auto_export_settings, "export_blueprints") 48 | 49 | section = section.box() 50 | section.enabled = controls_enabled and auto_export_settings.export_blueprints 51 | 52 | # collections/blueprints 53 | section.prop(auto_export_settings, "collection_instances_combine_mode") 54 | section.separator() 55 | 56 | section.prop(auto_export_settings, "export_separate_dynamic_and_static_objects") 57 | section.separator() 58 | 59 | # materials 60 | section.prop(auto_export_settings, "split_out_materials") 61 | 62 | # animations 63 | section.prop(auto_export_settings, "split_out_animations") 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/bevy_components/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/components/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/bevy_components/components/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/constants.py: -------------------------------------------------------------------------------- 1 | # FIXME: not sure, hard coded exclude list ? 2 | HIDDEN_COMPONENTS = ['Parent', 'Children'] -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/propGroups/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/bevy_components/propGroups/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/propGroups/operators.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/bevy_components/propGroups/operators.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/propGroups/process_list.py: -------------------------------------------------------------------------------- 1 | from bpy.props import (StringProperty, IntProperty, CollectionProperty) 2 | from .utils import generate_wrapper_propertyGroup 3 | from . import process_component 4 | 5 | def process_list(registry, definition, update, nesting_long_names=[]): 6 | value_types_defaults = registry.value_types_defaults 7 | type_infos = registry.type_infos 8 | 9 | long_name = definition["long_name"] 10 | ref_name = definition["items"]["type"]["$ref"].replace("#/$defs/", "") 11 | 12 | nesting_long_names = nesting_long_names + [long_name] 13 | 14 | item_definition = type_infos[ref_name] 15 | item_long_name = item_definition["long_name"] 16 | is_item_value_type = item_long_name in value_types_defaults 17 | 18 | property_group_class = None 19 | #if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName ! 20 | if is_item_value_type: 21 | property_group_class = generate_wrapper_propertyGroup(long_name, item_long_name, definition["items"]["type"]["$ref"], registry, update, nesting_long_names=nesting_long_names) 22 | else: 23 | (_, list_content_group_class) = process_component.process_component(registry, item_definition, update, {"nested": True, "long_name": item_long_name}, nesting_long_names=nesting_long_names) 24 | property_group_class = list_content_group_class 25 | 26 | item_collection = CollectionProperty(type=property_group_class) 27 | 28 | item_long_name = item_long_name if not is_item_value_type else "wrapper_" + item_long_name 29 | __annotations__ = { 30 | "list": item_collection, 31 | "list_index": IntProperty(name = "Index for list", default = 0, update=update), 32 | "long_name": StringProperty(default=item_long_name) 33 | } 34 | 35 | return __annotations__ -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/propGroups/process_structs.py: -------------------------------------------------------------------------------- 1 | from bpy.props import (StringProperty) 2 | from . import process_component 3 | 4 | def process_structs(registry, definition, properties, update, nesting_long_names): 5 | value_types_defaults = registry.value_types_defaults 6 | blender_property_mapping = registry.blender_property_mapping 7 | type_infos = registry.type_infos 8 | long_name = definition["long_name"] 9 | 10 | __annotations__ = {} 11 | default_values = {} 12 | nesting_long_names = nesting_long_names + [long_name] 13 | 14 | for property_name in properties.keys(): 15 | ref_name = properties[property_name]["type"]["$ref"].replace("#/$defs/", "") 16 | 17 | if ref_name in type_infos: 18 | original = type_infos[ref_name] 19 | original_long_name = original["long_name"] 20 | is_value_type = original_long_name in value_types_defaults 21 | value = value_types_defaults[original_long_name] if is_value_type else None 22 | default_values[property_name] = value 23 | 24 | if is_value_type: 25 | if original_long_name in blender_property_mapping: 26 | blender_property_def = blender_property_mapping[original_long_name] 27 | blender_property = blender_property_def["type"]( 28 | **blender_property_def["presets"],# we inject presets first 29 | name = property_name, 30 | default = value, 31 | update = update 32 | ) 33 | __annotations__[property_name] = blender_property 34 | else: 35 | original_long_name = original["long_name"] 36 | (sub_component_group, _) = process_component.process_component(registry, original, update, {"nested": True, "long_name": original_long_name}, nesting_long_names+[property_name]) 37 | __annotations__[property_name] = sub_component_group 38 | # if there are sub fields, add an attribute "sub_fields" possibly a pointer property ? or add a standard field to the type , that is stored under "attributes" and not __annotations (better) 39 | else: 40 | # component not found in type_infos, generating placeholder 41 | __annotations__[property_name] = StringProperty(default="Struct N/A") # Not sure about the usefullness of this, as we do not show a propgroup in the UI if it is invalid 42 | registry.add_missing_typeInfo(ref_name) 43 | # the root component also becomes invalid (in practice it is not always a component, but good enough) 44 | registry.add_invalid_component(nesting_long_names[0]) 45 | 46 | return __annotations__ 47 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/propGroups/process_tupples.py: -------------------------------------------------------------------------------- 1 | from bpy.props import (StringProperty) 2 | from . import process_component 3 | 4 | def process_tupples(registry, definition, prefixItems, update, nesting_long_names=[]): 5 | value_types_defaults = registry.value_types_defaults 6 | blender_property_mapping = registry.blender_property_mapping 7 | type_infos = registry.type_infos 8 | long_name = definition["long_name"] 9 | 10 | nesting_long_names = nesting_long_names + [long_name] 11 | __annotations__ = {} 12 | 13 | default_values = [] 14 | prefix_infos = [] 15 | for index, item in enumerate(prefixItems): 16 | ref_name = item["type"]["$ref"].replace("#/$defs/", "") 17 | 18 | property_name = str(index)# we cheat a bit, property names are numbers here, as we do not have a real property name 19 | 20 | if ref_name in type_infos: 21 | original = type_infos[ref_name] 22 | original_long_name = original["long_name"] 23 | is_value_type = original_long_name in value_types_defaults 24 | 25 | value = value_types_defaults[original_long_name] if is_value_type else None 26 | default_values.append(value) 27 | prefix_infos.append(original) 28 | 29 | if is_value_type: 30 | if original_long_name in blender_property_mapping: 31 | blender_property_def = blender_property_mapping[original_long_name] 32 | blender_property = blender_property_def["type"]( 33 | **blender_property_def["presets"],# we inject presets first 34 | name = property_name, 35 | default=value, 36 | update= update 37 | ) 38 | 39 | __annotations__[property_name] = blender_property 40 | else: 41 | original_long_name = original["long_name"] 42 | (sub_component_group, _) = process_component.process_component(registry, original, update, {"nested": True, "long_name": original_long_name}, nesting_long_names=nesting_long_names) 43 | __annotations__[property_name] = sub_component_group 44 | else: 45 | # component not found in type_infos, generating placeholder 46 | __annotations__[property_name] = StringProperty(default="N/A") 47 | registry.add_missing_typeInfo(ref_name) 48 | # the root component also becomes invalid (in practice it is not always a component, but good enough) 49 | registry.add_invalid_component(nesting_long_names[0]) 50 | 51 | 52 | return __annotations__ 53 | 54 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/propGroups/prop_groups.py: -------------------------------------------------------------------------------- 1 | import json 2 | import bpy 3 | 4 | from .conversions_from_prop_group import property_group_value_to_custom_property_value 5 | from .process_component import process_component 6 | from .utils import update_calback_helper 7 | from ..utils import get_selected_item 8 | 9 | ## main callback function, fired whenever any property changes, no matter the nesting level 10 | def update_component(self, context, definition, component_name): 11 | registry = bpy.context.window_manager.components_registry 12 | 13 | current_object_or_collection = get_selected_item(context) 14 | update_disabled = current_object_or_collection["__disable__update"] if "__disable__update" in current_object_or_collection else False 15 | update_disabled = registry.disable_all_object_updates or update_disabled # global settings 16 | if update_disabled: 17 | return 18 | components_in_object = current_object_or_collection.components_meta.components 19 | component_meta = next(filter(lambda component: component["long_name"] == component_name, components_in_object), None) 20 | 21 | if component_meta is not None: 22 | property_group_name = registry.get_propertyGroupName_from_longName(component_name) 23 | property_group = getattr(component_meta, property_group_name) 24 | # we use our helper to set the values 25 | previous = json.loads(current_object_or_collection['bevy_components']) 26 | previous[component_name] = property_group_value_to_custom_property_value(property_group, definition, registry, None) 27 | current_object_or_collection['bevy_components'] = json.dumps(previous) 28 | 29 | 30 | def generate_propertyGroups_for_components(): 31 | registry = bpy.context.window_manager.components_registry 32 | if not registry.has_type_infos(): 33 | registry.load_type_infos() 34 | 35 | type_infos = registry.type_infos 36 | 37 | for root_type_name in type_infos: 38 | definition = type_infos[root_type_name] 39 | #print("root property", component_name,f"({is_component})") 40 | process_component(registry, definition, update_calback_helper(definition, update_component, root_type_name), extras=None, nesting_long_names=[]) 41 | 42 | # if we had to add any wrapper types on the fly, process them now 43 | registry.process_custom_types() -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/registry/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/bevy_components/registry/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/registry/hashing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/add_ons/bevy_components/registry/hashing/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/registry/operators.py: -------------------------------------------------------------------------------- 1 | import os 2 | import bpy 3 | from bpy_types import (Operator) 4 | from bpy.props import (StringProperty) 5 | from bpy_extras.io_utils import ImportHelper 6 | from ....settings import upsert_settings 7 | from ..components.metadata import ensure_metadata_for_all_items 8 | from ..propGroups.prop_groups import generate_propertyGroups_for_components 9 | 10 | class BLENVY_OT_components_registry_reload(Operator): 11 | """Reloads registry (schema file) from disk, generates propertyGroups for components & ensures all objects have metadata """ 12 | bl_idname = "blenvy.components_registry_reload" 13 | bl_label = "Reload Registry" 14 | bl_options = {"UNDO"} 15 | 16 | component_type: StringProperty( 17 | name="component_type", 18 | description="component type to add", 19 | ) # type: ignore 20 | 21 | def execute(self, context): 22 | print("reload registry") 23 | context.window_manager.components_registry.load_schema() 24 | generate_propertyGroups_for_components() 25 | print("") 26 | print("") 27 | print("") 28 | ensure_metadata_for_all_items() 29 | 30 | # now force refresh the ui 31 | for area in context.screen.areas: 32 | for region in area.regions: 33 | if region.type == "UI": 34 | region.tag_redraw() 35 | 36 | return {'FINISHED'} 37 | 38 | class BLENVY_OT_components_registry_browse_schema(Operator, ImportHelper): 39 | """Browse for registry json file""" 40 | bl_idname = "blenvy.components_registry_browse_schema" 41 | bl_label = "Open the file browser" 42 | 43 | filter_glob: StringProperty( 44 | default='*.json', 45 | options={'HIDDEN'} 46 | ) # type: ignore 47 | 48 | def execute(self, context): 49 | """Do something with the selected file(s).""" 50 | #filename, extension = os.path.splitext(self.filepath) 51 | file_path = bpy.data.filepath 52 | # Get the folder 53 | folder_path = os.path.dirname(file_path) 54 | relative_path = os.path.relpath(self.filepath, folder_path) 55 | 56 | blenvy = context.window_manager.blenvy 57 | blenvy.components.schema_path = relative_path 58 | upsert_settings(blenvy.components.settings_save_path, {"schema_path": relative_path}) 59 | 60 | return {'FINISHED'} 61 | 62 | -------------------------------------------------------------------------------- /tools/blenvy/add_ons/bevy_components/ui.py: -------------------------------------------------------------------------------- 1 | def draw_settings_ui(layout, component_settings): 2 | 3 | row = layout.row() 4 | col = row.column() 5 | col.label(text="Registry Schema path") 6 | 7 | col = row.column() 8 | col.enabled = False 9 | col.prop(component_settings, "schema_path", text="") 10 | 11 | col = row.column() 12 | col.operator(operator="blenvy.components_registry_browse_schema", text="", icon="FILE_FOLDER") 13 | 14 | layout.separator() 15 | layout.operator(operator="blenvy.components_registry_reload", text="reload registry" , icon="FILE_REFRESH") 16 | 17 | layout.separator() 18 | row = layout.row() 19 | 20 | row.prop(component_settings, "watcher_enabled", text="enable registry file polling") 21 | row.prop(component_settings, "watcher_poll_frequency", text="registry file poll frequency (s)") 22 | 23 | layout.separator() 24 | layout.separator() -------------------------------------------------------------------------------- /tools/blenvy/assets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/assets/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/assets/asset_helpers.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | def get_user_assets(scene_or_collection): 4 | user_assets = getattr(scene_or_collection, 'user_assets', []) 5 | return user_assets 6 | 7 | def get_generated_assets(scene_or_collection): 8 | generated_assets = getattr(scene_or_collection, 'generated_assets', []) 9 | return generated_assets 10 | 11 | def get_user_assets_as_list(scene_or_collection): 12 | raw = get_user_assets(scene_or_collection) 13 | result = [] 14 | for asset in raw: 15 | result.append({"name": asset.name, "path": asset.path, "type": "MODEL", "internal": False, "parent": None}) 16 | return result 17 | 18 | def upsert_asset(scene_or_collection, asset): 19 | new_asset = scene_or_collection.user_assets.add() 20 | new_asset.name = asset["name"] 21 | new_asset.path = asset["path"] 22 | 23 | def remove_asset(scene_or_collection, ref_asset): 24 | print("to remove", ref_asset["path"], scene_or_collection.user_assets.find(ref_asset["path"]), scene_or_collection.user_assets) 25 | removal_index = -1 26 | for index, asset in enumerate(scene_or_collection.user_assets): 27 | print("asset in list", asset.name, asset.path) 28 | if asset.path == ref_asset["path"]: 29 | print("FOUND", index) 30 | removal_index = index 31 | break 32 | #scene_or_collection.user_assets.find(lambda x,y : print(x)) 33 | if removal_index != -1 : 34 | print("REMOVE") 35 | scene_or_collection.user_assets.remove(removal_index) 36 | #scene_or_collection.user_assets.remove(scene_or_collection.user_assets.find(ref_asset["path"])) 37 | 38 | def does_asset_exist(scene_or_collection, ref_asset): 39 | user_assets = getattr(scene_or_collection, 'user_assets', []) 40 | in_list = [asset for asset in user_assets if (asset.path == ref_asset["path"])] 41 | in_list = len(in_list) > 0 42 | return in_list -------------------------------------------------------------------------------- /tools/blenvy/assets/assets_registry.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | from pathlib import Path 3 | from bpy_types import (PropertyGroup) 4 | from bpy.props import (StringProperty, BoolProperty, FloatProperty, FloatVectorProperty, IntProperty, IntVectorProperty, EnumProperty, PointerProperty, CollectionProperty) 5 | 6 | # Asset property group 7 | class Asset(PropertyGroup): 8 | name: StringProperty(name="asset name") # type: ignore 9 | path: StringProperty(name="asset path") # type: ignore 10 | 11 | # this is where we store the information for all available assets 12 | # 13 | class AssetsRegistry(PropertyGroup): 14 | assets_list = [] 15 | 16 | asset_name_selector: StringProperty( 17 | name="asset name", 18 | description="name of asset to add", 19 | ) # type: ignore 20 | 21 | asset_type_selector: EnumProperty( 22 | name="asset type", 23 | description="type of asset to add", 24 | items=( 25 | ('MODEL', "Model", ""), 26 | ('AUDIO', "Audio", ""), 27 | ('IMAGE', "Image", ""), 28 | ('TEXT', "Text", ""), 29 | ) 30 | ) # type: ignore 31 | 32 | asset_path_selector: StringProperty( 33 | name="asset path", 34 | description="path of asset to add", 35 | #subtype='FILE_PATH' 36 | ) # type: ignore 37 | 38 | 39 | @classmethod 40 | def register(cls): 41 | bpy.types.Scene.user_assets = CollectionProperty(name="user assets", type=Asset) 42 | bpy.types.Collection.user_assets = CollectionProperty(name="user assets", type=Asset) 43 | 44 | bpy.types.Scene.generated_assets = CollectionProperty(name="generated assets", type=Asset) 45 | bpy.types.Collection.generated_assets = CollectionProperty(name="generated assets", type=Asset) 46 | 47 | bpy.types.WindowManager.assets_registry = PointerProperty(type=AssetsRegistry) 48 | 49 | 50 | @classmethod 51 | def unregister(cls): 52 | del bpy.types.WindowManager.assets_registry 53 | del bpy.types.Scene.user_assets 54 | del bpy.types.Collection.user_assets 55 | 56 | del bpy.types.Scene.generated_assets 57 | del bpy.types.Collection.generated_assets 58 | 59 | def add_asset(self, name, type, path, internal): # internal means it cannot be edited by the user, aka auto generated 60 | in_list = [asset for asset in self.assets_list if (asset["path"] == path)] 61 | in_list = len(in_list) > 0 62 | if not in_list: 63 | self.assets_list.append({"name": name, "type": type, "path": path, "internal": internal}) 64 | 65 | def remove_asset(self, path): 66 | self.assets_list[:] = [asset for asset in self.assets_list if (asset["path"] != path)] 67 | 68 | -------------------------------------------------------------------------------- /tools/blenvy/assets/generate_asset_file.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def write_ron_assets_file(name, assets_hierarchy, internal_only=False, output_path_full="."): 4 | # just for testing, this uses the format of bevy_asset_loader's asset files 5 | ''' 6 | ({ 7 | "world":File (path: "models/StartLevel.glb"), 8 | "level1":File (path: "models/Level1.glb"), 9 | "level2":File (path: "models/Level2.glb"), 10 | 11 | "models": Folder ( 12 | path: "models/library", 13 | ), 14 | "materials": Folder ( 15 | path: "materials", 16 | ), 17 | }) 18 | ''' 19 | formated_assets = [] 20 | for asset in assets_hierarchy: 21 | if asset["internal"] or not internal_only: 22 | formated_asset = f'\n "{asset["name"]}": File ( path: "{asset["path"]}" ),' 23 | formated_assets.append(formated_asset) 24 | 25 | with open(f"{output_path_full}/{name}.assets.ron", "w") as assets_file: 26 | assets_file.write("({") 27 | assets_file.writelines(formated_assets) 28 | assets_file.write("\n})") -------------------------------------------------------------------------------- /tools/blenvy/blueprints/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/blueprints/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/blueprints/blueprint.py: -------------------------------------------------------------------------------- 1 | class Blueprint: 2 | def __init__(self, name): 3 | self.name = name 4 | self.local = True 5 | self.marked = False # If marked as asset or with auto_export flag, always export if changed 6 | self.scene = None # Not sure, could be usefull for tracking 7 | 8 | self.instances = [] 9 | self.objects = [] 10 | self.nested_blueprints = [] 11 | 12 | self.collection = None # should we just sublclass ? 13 | 14 | def __repr__(self): 15 | return f'Name: {self.name} Local: {self.local}, Scene: {self.scene}, Instances: {self.instances}, Objects: {self.objects}, nested_blueprints: {self.nested_blueprints}' 16 | 17 | def __str__(self): 18 | return f'Name: "{self.name}", Local: {self.local}, Scene: {self.scene}, Instances: {self.instances}, Objects: {self.objects}, nested_blueprints: {self.nested_blueprints}' 19 | -------------------------------------------------------------------------------- /tools/blenvy/blueprints/blueprint_helpers.py: -------------------------------------------------------------------------------- 1 | 2 | import os 3 | import json 4 | import bpy 5 | from pathlib import Path 6 | import posixpath 7 | 8 | def find_blueprints_not_on_disk(blueprints, folder_path, extension): 9 | not_found_blueprints = [] 10 | for blueprint in blueprints: 11 | gltf_output_path = os.path.join(folder_path, blueprint.name + extension) 12 | # print("gltf_output_path", gltf_output_path) 13 | found = os.path.exists(gltf_output_path) and os.path.isfile(gltf_output_path) 14 | if not found: 15 | not_found_blueprints.append(blueprint) 16 | return not_found_blueprints 17 | 18 | def check_if_blueprint_on_disk(scene_name, folder_path, extension): 19 | gltf_output_path = os.path.join(folder_path, scene_name + extension) 20 | found = os.path.exists(gltf_output_path) and os.path.isfile(gltf_output_path) 21 | return found 22 | 23 | def inject_export_path_into_internal_blueprints(internal_blueprints, blueprints_path, gltf_extension, settings): 24 | for blueprint in internal_blueprints: 25 | blueprint_exported_path = posixpath.join(blueprints_path, f"{blueprint.name}{gltf_extension}") 26 | # print("injecting blueprint path", blueprint_exported_path, "for", blueprint.name) 27 | blueprint.collection["export_path"] = blueprint_exported_path 28 | """if split_out_materials: 29 | blueprint.collection["materials_path"] = materials_exported_path""" 30 | -------------------------------------------------------------------------------- /tools/blenvy/blueprints/blueprints_registry.py: -------------------------------------------------------------------------------- 1 | from types import SimpleNamespace 2 | import bpy 3 | import json 4 | import os 5 | import uuid 6 | from pathlib import Path 7 | from bpy_types import (PropertyGroup) 8 | from bpy.props import (StringProperty, BoolProperty, FloatProperty, FloatVectorProperty, IntProperty, IntVectorProperty, EnumProperty, PointerProperty, CollectionProperty) 9 | 10 | from ..settings import load_settings 11 | from .blueprints_scan import blueprints_scan 12 | 13 | 14 | 15 | def refresh_blueprints(): 16 | try: 17 | blueprints_registry = bpy.context.window_manager.blueprints_registry 18 | blueprints_registry.refresh_blueprints() 19 | except:pass 20 | 21 | return 3 22 | 23 | # this is where we store the information for all available Blueprints 24 | class BlueprintsRegistry(PropertyGroup): 25 | blueprints_data = None 26 | blueprints_list = [] 27 | 28 | asset_name_selector: StringProperty( 29 | name="asset name", 30 | description="name of asset to add", 31 | ) # type: ignore 32 | 33 | asset_type_selector: EnumProperty( 34 | name="asset type", 35 | description="type of asset to add", 36 | items=( 37 | ('MODEL', "Model", ""), 38 | ('AUDIO', "Audio", ""), 39 | ('IMAGE', "Image", ""), 40 | ) 41 | ) # type: ignore 42 | 43 | asset_path_selector: StringProperty( 44 | name="asset path", 45 | description="path of asset to add", 46 | subtype='FILE_PATH' 47 | ) # type: ignore 48 | 49 | @classmethod 50 | def register(cls): 51 | bpy.types.WindowManager.blueprints_registry = PointerProperty(type=BlueprintsRegistry) 52 | bpy.app.timers.register(refresh_blueprints) 53 | 54 | @classmethod 55 | def unregister(cls): 56 | try: 57 | bpy.app.timers.unregister(refresh_blueprints) 58 | except: pass 59 | 60 | del bpy.types.WindowManager.blueprints_registry 61 | 62 | 63 | def add_blueprint(self, blueprint): 64 | self.blueprints_list.append(blueprint) 65 | 66 | def refresh_blueprints(self): 67 | #print("titi", self) 68 | blenvy = bpy.context.window_manager.blenvy 69 | settings = blenvy 70 | blueprints_data = blueprints_scan(settings.level_scenes, settings.library_scenes, settings) 71 | self.blueprints_data = blueprints_data 72 | return blueprints_data 73 | -------------------------------------------------------------------------------- /tools/blenvy/blueprints/operators.py: -------------------------------------------------------------------------------- 1 | import os 2 | import bpy 3 | from bpy_types import (Operator) 4 | from bpy.props import (StringProperty) 5 | from ..core.helpers_collections import set_active_collection 6 | 7 | class BLENVY_OT_blueprint_select(Operator): 8 | """Select blueprint """ 9 | bl_idname = "blenvy.blueprint_select" 10 | bl_label = "Select blueprint" 11 | bl_options = {"UNDO"} 12 | 13 | blueprint_collection_name: StringProperty( 14 | name="blueprint collection name", 15 | description="blueprints to select's collection name ", 16 | ) # type: ignore 17 | 18 | blueprint_scene_name: StringProperty( 19 | name="blueprint scene name", 20 | description="blueprints to select's collection name ", 21 | ) # type: ignore 22 | 23 | def execute(self, context): 24 | if self.blueprint_collection_name: 25 | scene = bpy.data.scenes[self.blueprint_scene_name] 26 | if scene: 27 | bpy.ops.object.select_all(action='DESELECT') 28 | bpy.context.window.scene = scene 29 | bpy.context.view_layer.objects.active = None 30 | set_active_collection(scene, self.blueprint_collection_name) 31 | 32 | return {'FINISHED'} 33 | -------------------------------------------------------------------------------- /tools/blenvy/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/core/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/core/helpers_collections.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | 3 | # traverse all collections 4 | def traverse_tree(t): 5 | yield t 6 | for child in t.children: 7 | yield from traverse_tree(child) 8 | 9 | #Recursivly transverse layer_collection for a particular name 10 | def recurLayerCollection(layerColl, collName): 11 | found = None 12 | if (layerColl.name == collName): 13 | return layerColl 14 | for layer in layerColl.children: 15 | found = recurLayerCollection(layer, collName) 16 | if found: 17 | return found 18 | 19 | def set_active_collection(scene, collection_name): 20 | layer_collection = scene.view_layers['ViewLayer'].layer_collection 21 | layerColl = recurLayerCollection(layer_collection, collection_name) 22 | # set active collection to the collection 23 | bpy.context.view_layer.active_layer_collection = layerColl 24 | -------------------------------------------------------------------------------- /tools/blenvy/core/object_makers.py: -------------------------------------------------------------------------------- 1 | import bmesh 2 | import bpy 3 | import mathutils 4 | 5 | # Makes an empty, at the specified location, rotation, scale stores it in existing collection, from https://blender.stackexchange.com/questions/51290/how-to-add-empty-object-not-using-bpy-ops 6 | def make_empty(name, location, rotation, scale, collection): 7 | object_data = None 8 | empty_obj = bpy.data.objects.new( name, object_data ) 9 | 10 | empty_obj.empty_display_size = 2 11 | empty_obj.empty_display_type = 'PLAIN_AXES' 12 | 13 | empty_obj.name = name 14 | empty_obj.location = location 15 | empty_obj.scale = scale 16 | empty_obj.rotation_euler = rotation 17 | 18 | collection.objects.link( empty_obj ) 19 | #bpy.context.view_layer.update() 20 | return empty_obj 21 | 22 | def make_cube(name, location=[0,0,0], rotation=[0,0,0], scale=[1,1,1], collection=None): 23 | new_mesh = bpy.data.meshes.new(name+"_Mesh") #None 24 | """verts = [( 1.0, 1.0, 0.0), 25 | ( 1.0, -1.0, 0.0), 26 | (-1.0, -1.0, 0.0), 27 | (-1.0, 1.0, 0.0), 28 | ] # 4 verts made with XYZ coords 29 | edges = [] 30 | faces = [[0, 1, 2, 3]] 31 | new_mesh.from_pydata(verts, edges, faces)""" 32 | 33 | 34 | bm = bmesh.new() 35 | bmesh.ops.create_cube(bm, size=0.1, matrix=mathutils.Matrix.Translation(location)) # FIXME: other ways to set position seems to fail ? 36 | bm.to_mesh(new_mesh) 37 | bm.free() 38 | 39 | new_object = bpy.data.objects.new(name, new_mesh) 40 | new_object.name = name 41 | new_object.location = location 42 | new_object.scale = scale 43 | new_object.rotation_euler = rotation 44 | 45 | if collection is not None: 46 | collection.objects.link( new_object ) 47 | return new_object 48 | 49 | 50 | 51 | """import bpy 52 | import json 53 | 54 | # Makes an empty, at the specified location, rotation, scale stores it in existing collection, from https://blender.stackexchange.com/questions/51290/how-to-add-empty-object-not-using-bpy-ops 55 | def make_empty(name, location, rotation, scale, collection): 56 | object_data = None 57 | empty_obj = bpy.data.objects.new( name, object_data ) 58 | 59 | empty_obj.empty_display_size = 2 60 | empty_obj.empty_display_type = 'PLAIN_AXES' 61 | 62 | empty_obj.name = name 63 | empty_obj.location = location 64 | empty_obj.scale = scale 65 | empty_obj.rotation_euler = rotation 66 | 67 | collection.objects.link( empty_obj ) 68 | #bpy.context.view_layer.update() 69 | return empty_obj 70 | """ -------------------------------------------------------------------------------- /tools/blenvy/core/operators.py: -------------------------------------------------------------------------------- 1 | from bpy_types import (Operator) 2 | from bpy.props import (EnumProperty) 3 | 4 | from ..settings import clear_settings 5 | 6 | class BLENVY_OT_tooling_switch(Operator): 7 | """Switch blenvy tooling""" 8 | bl_idname = "bevy.tooling_switch" 9 | bl_label = "Switch bevy tooling" 10 | #bl_options = {} 11 | 12 | tool: EnumProperty( 13 | items=( 14 | ('COMPONENTS', "Components", "Switch to components"), 15 | ('BLUEPRINTS', "Blueprints", ""), 16 | ('LEVELS', "Levels", ""), 17 | ('ASSETS', "Assets", ""), 18 | ('SETTINGS', "Settings", ""), 19 | ('TOOLS', "Tools", ""), 20 | ) 21 | ) # type: ignore 22 | 23 | @classmethod 24 | def description(cls, context, properties): 25 | return properties.tool 26 | 27 | def execute(self, context): 28 | context.window_manager.blenvy.mode = self.tool 29 | return {'FINISHED'} 30 | 31 | class BLENVY_OT_configuration_switch(Operator): 32 | """Switch tooling configuration""" 33 | bl_idname = "bevy.config_switch" 34 | bl_label = "Switch blenvy configuration" 35 | #bl_options = {} 36 | 37 | tool: EnumProperty( 38 | items=( 39 | ('COMMON', "Common", "Switch to common configuration"), 40 | ('COMPONENTS', "Components", "Switch to components configuration"), 41 | ('EXPORT', "Export", "Switch to export configuration"), 42 | ) 43 | ) # type: ignore 44 | 45 | @classmethod 46 | def description(cls, context, properties): 47 | return properties.tool 48 | 49 | def execute(self, context): 50 | context.window_manager.blenvy.config_mode = self.tool 51 | return {'FINISHED'} 52 | 53 | 54 | class BLENVY_OT_configuration_reset(Operator): 55 | """Reset all blenvy settings to default""" 56 | bl_idname = "bevy.config_reset" 57 | bl_label = "Clear stored setting & reset configuration to default" 58 | #bl_options = {} 59 | 60 | def execute(self, context): 61 | print("reset configuration") 62 | blenvy = context.window_manager.blenvy 63 | try: 64 | blenvy.reset_settings() 65 | except Exception as error: 66 | self.report({"ERROR"}, f"Failed to reset settings: {error}") 67 | return {"CANCELLED"} 68 | return {'FINISHED'} 69 | -------------------------------------------------------------------------------- /tools/blenvy/core/path_helpers.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import os 3 | 4 | def absolute_path_from_blend_file(path): 5 | # path to the current blend file 6 | blend_file_path = bpy.data.filepath 7 | # Get the folder 8 | blend_file_folder_path = os.path.dirname(blend_file_path) 9 | 10 | # absolute path 11 | return os.path.abspath(os.path.join(blend_file_folder_path, path)) 12 | -------------------------------------------------------------------------------- /tools/blenvy/core/scene_helpers.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | from bpy.props import (PointerProperty) 3 | from .object_makers import make_empty 4 | 5 | def add_scene_property(scene, scene_component_name, property_data, limit_to=None): 6 | root_collection = scene.collection 7 | scene_property = None 8 | for object in scene.objects: 9 | if object.name == scene_component_name: 10 | scene_property = object 11 | break 12 | 13 | if scene_property is None: 14 | scene_property = make_empty(scene_component_name, [0,0,0], [0,0,0], [0,0,0], root_collection) 15 | 16 | for key in property_data.keys(): 17 | if limit_to is not None: 18 | if key in limit_to: 19 | scene_property[key] = property_data[key] 20 | else: 21 | scene_property[key] = property_data[key] 22 | 23 | 24 | # compatibility helper until we land gltf_extras at the scene level for Bevy 25 | # it copies a custom property into an __components object's properties 26 | def copy_scene_or_collection_property_to_object_component(scene, property_name, target_object_name): 27 | property_value = scene.get(property_name, None) 28 | if property_value is not None: 29 | property_data = {} 30 | property_data[property_name] = property_value 31 | add_scene_property(scene=scene, scene_component_name=target_object_name, property_data=property_data) -------------------------------------------------------------------------------- /tools/blenvy/core/ui/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/core/ui/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/core/utils.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import inspect 3 | import bpy 4 | 5 | def full_stack_lines(tb=None): 6 | text = [] 7 | try: 8 | if tb is None: 9 | tb = sys.exc_info()[2] 10 | 11 | text.append('Traceback (most recent call last):') 12 | for item in reversed(inspect.getouterframes(tb.tb_frame)[1:]): 13 | text.append(' File "{1}", line {2}, in {3}\n'.format(*item)) 14 | for line in item[4]: 15 | text.append(' ' + line.lstrip()) 16 | for item in inspect.getinnerframes(tb): 17 | text.append(' File "{1}", line {2}, in {3}\n'.format(*item)) 18 | for line in item[4]: 19 | text.append(' ' + line.lstrip()) 20 | except: pass 21 | return text 22 | 23 | def exception_traceback(error): 24 | traceback_formated = [str(error)] 25 | traceback_formated += full_stack_lines() 26 | return traceback_formated 27 | 28 | def show_message_box(title = "Message Box", icon = 'INFO', lines=""): 29 | myLines=lines 30 | def draw(self, context): 31 | for n in myLines: 32 | self.layout.label(text=n) 33 | bpy.context.window_manager.popup_menu(draw, title = title, icon = icon) 34 | -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/blender_addon_add_scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/blender_addon_add_scene.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/blender_addon_add_scene2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/blender_addon_add_scene2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/blender_addon_add_scene3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/blender_addon_add_scene3.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/blender_addon_install2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/blender_addon_install2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/blender_addon_install_zip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/blender_addon_install_zip.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/blender_addon_use.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/blender_addon_use.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/blender_addon_use2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/blender_addon_use2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/blender_addon_use3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/blender_addon_use3.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/blender_addon_use4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/blender_addon_use4.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/exported_collections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/exported_collections.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/exported_library_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/exported_library_files.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/force_export.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/force_export.jpg -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/nested_blueprints.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/nested_blueprints.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/nested_blueprints2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/nested_blueprints2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/nested_blueprints3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/nested_blueprints3.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/purge_orphan1_data1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/purge_orphan1_data1.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/purge_orphan1_data2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/purge_orphan1_data2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/purge_orphan1_data3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/purge_orphan1_data3.png -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/workflow_empties.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/workflow_empties.jpg -------------------------------------------------------------------------------- /tools/blenvy/docs/auto_export/workflow_original.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/auto_export/workflow_original.jpg -------------------------------------------------------------------------------- /tools/blenvy/docs/blender_addon_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blender_addon_install.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blender_addon_materials.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blender_addon_materials.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blender_addon_materials2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blender_addon_materials2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blenvy_configuration_common.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blenvy_configuration_common.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blenvy_configuration_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blenvy_configuration_components.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blenvy_configuration_export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blenvy_configuration_export.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blenvy_recommended_folder_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blenvy_recommended_folder_structure.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blenvy_recommended_folder_structure_art.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blenvy_recommended_folder_structure_art.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blenvy_recommended_folder_structure_assets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blenvy_recommended_folder_structure_assets.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blenvy_ui_location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blenvy_ui_location.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blueprints_always_export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blueprints_always_export.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blueprints_create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blueprints_create.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blueprints_create2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blueprints_create2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blueprints_create3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blueprints_create3.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blueprints_mark_asset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blueprints_mark_asset.png -------------------------------------------------------------------------------- /tools/blenvy/docs/blueprints_tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/blueprints_tab.png -------------------------------------------------------------------------------- /tools/blenvy/docs/combine_override.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/combine_override.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/add_component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/add_component.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/blender_addon_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/blender_addon_install.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/blender_addon_install2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/blender_addon_install2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/blender_addon_install_zip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/blender_addon_install_zip.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/complex_components2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/complex_components2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/component_remove_single.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/component_remove_single.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/component_rename_object_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/component_rename_object_select.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/component_rename_overview2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/component_rename_overview2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/component_rename_remove_bulk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/component_rename_remove_bulk.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/component_rename_remove_bulk2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/component_rename_remove_bulk2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/component_rename_single.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/component_rename_single.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/components_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/components_list.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/components_list2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/components_list2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/configuration.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/configuration2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/configuration2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/configuration3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/configuration3.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/copy_component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/copy_component.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/edit_component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/edit_component.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/edit_component2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/edit_component2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/enums.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/enums.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/enums2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/enums2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/filter_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/filter_components.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/generate_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/generate_components.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/generate_components2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/generate_components2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/generate_components3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/generate_components3.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/other_options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/other_options.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/other_options2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/other_options2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/paste_component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/paste_component.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/registry_polling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/registry_polling.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/toggle_details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/toggle_details.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/unregistered_types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/unregistered_types.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/update_ui_from_custom_properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/update_ui_from_custom_properties.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components/vecs_lists.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components/vecs_lists.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_add.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_add2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_add2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_blueprints.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_blueprints.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_blueprints_blueprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_blueprints_blueprint.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_blueprints_instance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_blueprints_instance.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_copy.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_details.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_edit.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_invalid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_invalid.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_list.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_missing_registry_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_missing_registry_data.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_object.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_paste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_paste.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_rename_fix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_rename_fix.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_rename_fix2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_rename_fix2.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_rename_fix3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_rename_fix3.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_rename_fix4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_rename_fix4.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_search.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_suported_types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_suported_types.png -------------------------------------------------------------------------------- /tools/blenvy/docs/components_unregistered_types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/docs/components_unregistered_types.png -------------------------------------------------------------------------------- /tools/blenvy/levels/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/levels/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/levels/operators.py: -------------------------------------------------------------------------------- 1 | import os 2 | import bpy 3 | from bpy_types import (Operator) 4 | from bpy.props import (StringProperty) 5 | 6 | class BLENVY_OT_level_select(Operator): 7 | """Select level """ 8 | bl_idname = "blenvy.level_select" 9 | bl_label = "Select level" 10 | bl_options = {"UNDO"} 11 | 12 | level_name: StringProperty( 13 | name="level name", 14 | description="level to select", 15 | ) # type: ignore 16 | 17 | def execute(self, context): 18 | if self.level_name: 19 | scene = bpy.data.scenes[self.level_name] 20 | if scene: 21 | # bpy.ops.object.select_all(action='DESELECT') 22 | bpy.context.window.scene = scene 23 | 24 | return {'FINISHED'} 25 | -------------------------------------------------------------------------------- /tools/blenvy/materials/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/materials/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | blender-template = ../../testing/bevy_example/art/testing.blend 3 | addopts = -svv 4 | testpaths = 5 | tests 6 | 7 | # dependencies: 8 | # pytest_blender 9 | # pixelmatch -------------------------------------------------------------------------------- /tools/blenvy/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/tests/__init__.py -------------------------------------------------------------------------------- /tools/blenvy/tests/expected_bevy_hierarchy.json: -------------------------------------------------------------------------------- 1 | {"Blueprint7_hierarchy.001":["Blueprint4_nested.001","Cube.001"],"Cylinder":["Cylinder.001","Cylinder.001"],"Blueprint8_animated_no_bones":["Cylinder.002"],"Blueprint7_hierarchy":["Cube.001"],"Collection 2":["Blueprint8_animated_no_bones","Collection 2 1","Empty_in_collection","Spot"],"Fox_mesh":["fox1","fox1"],"_rootJoint":["b_Root_00","b_Root_00"],"b_Root_00":["b_Hip_01","b_Hip_01"],"Blueprint1":["Blueprint1_mesh"],"Fox":["Fox_mesh","_rootJoint","Fox_mesh","_rootJoint"],"Light":["Light","DirectionalLight Gizmo"],"b_Spine01_02":["b_Spine02_03","b_Spine02_03"],"b_RightLeg01_019":["b_RightLeg02_020","b_RightLeg02_020"],"b_LeftFoot01_017":["b_LeftFoot02_018","b_LeftFoot02_018"],"b_LeftForeArm_010":["b_LeftHand_011","b_LeftHand_011"],"Collection":["Blueprint1.001","Blueprint4_nested","Blueprint6_animated","Blueprint7_hierarchy","Camera","Cube","Empty","External_blueprint","External_blueprint2","Light","Plane"],"Cylinder.001":["Cylinder.002","Blueprint7_hierarchy.001","Empty_as_child"],"b_Hip_01":["b_Spine01_02","b_Tail01_012","b_LeftLeg01_015","b_RightLeg01_019","b_Spine01_02","b_Tail01_012","b_LeftLeg01_015","b_RightLeg01_019"],"world":["no_name"],"Parent_Object":["Cube.003","Blueprint1","Cylinder.001"],"Blueprint6_animated.001":["Fox"],"Blueprint4_nested":["Blueprint3"],"Blueprint6_animated":["Fox"],"Cube.001":["Cube.002","Cylinder","Cube.002","Cylinder"],"b_Spine02_03":["b_Neck_04","b_RightUpperArm_06","b_LeftUpperArm_09","b_Neck_04","b_RightUpperArm_06","b_LeftUpperArm_09"],"b_LeftLeg01_015":["b_LeftLeg02_016","b_LeftLeg02_016"],"Blueprint4_nested.001":["Blueprint3"],"b_Tail02_013":["b_Tail03_014","b_Tail03_014"],"b_RightForeArm_07":["b_RightHand_08","b_RightHand_08"],"External_blueprint2_Cylinder":["Cylinder"],"Blueprint3":["Blueprint3_mesh","Blueprint3_mesh"],"External_blueprint2":["External_blueprint2_Cylinder","External_blueprint3"],"b_LeftUpperArm_09":["b_LeftForeArm_010","b_LeftForeArm_010"],"Cube":["Cube"],"Plane":["Plane"],"no_name":["Parent_Object","Blueprint6_animated.001","lighting_components_World","assets_list_World_components","Collection","Collection 2"],"Collection 2 1":["Empty_in_sub_collection"],"External_blueprint_mesh":["Cube.001"],"b_LeftLeg02_016":["b_LeftFoot01_017","b_LeftFoot01_017"],"Cylinder.002":["Cylinder.003"],"b_RightLeg02_020":["b_RightFoot01_021","b_RightFoot01_021"],"b_Neck_04":["b_Head_05","b_Head_05"],"b_RightUpperArm_06":["b_RightForeArm_07","b_RightForeArm_07"],"Spot":["Spot"],"External_blueprint3_Cone":["Cone"],"External_blueprint":["External_blueprint_mesh"],"Blueprint3_mesh":["Cylinder","Cylinder"],"External_blueprint3":["External_blueprint3_Cone"],"Camera":["Camera Gizmo"],"Blueprint1_mesh":["Cube.001","Cube.001"],"Blueprint1.001":["Blueprint1_mesh"],"b_Tail01_012":["b_Tail02_013","b_Tail02_013"],"b_RightFoot01_021":["b_RightFoot02_022","b_RightFoot02_022"]} -------------------------------------------------------------------------------- /tools/blenvy/tests/expected_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaosat-dev/Blenvy/03cc100caca642b9386630e203e86500208fecf6/tools/blenvy/tests/expected_screenshot.png -------------------------------------------------------------------------------- /tools/blenvy/tests/setup_data.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import pytest 3 | 4 | @pytest.fixture 5 | def setup_data(request): 6 | print("\nSetting up resources...") 7 | 8 | schema_path = "../../testing/bevy_example/assets/registry.json" 9 | 10 | yield {"schema_path": schema_path} 11 | 12 | def finalizer(): 13 | print("\nPerforming teardown...") 14 | registry = bpy.context.window_manager.components_registry 15 | 16 | type_infos = registry.type_infos 17 | object = bpy.context.object 18 | remove_component_operator = bpy.ops.blenvy.component_remove 19 | 20 | for long_name in type_infos: 21 | definition = type_infos[long_name] 22 | component_name = definition["short_name"] 23 | if component_name in object: 24 | try: 25 | remove_component_operator(component_name=component_name) 26 | except Exception as error: 27 | pass 28 | 29 | request.addfinalizer(finalizer) 30 | 31 | return None -------------------------------------------------------------------------------- /tools/blenvy/tests/test_registry.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | from .setup_data import setup_data 3 | 4 | def test_blend(setup_data): 5 | registry = bpy.context.window_manager.components_registry 6 | registry.schema_path = setup_data["components_schemaPath"] 7 | bpy.ops.object.reload_registry() 8 | 9 | long_name = "bevy_example::test_components::BasicTest" 10 | 11 | add_component_operator = bpy.ops.object.add_bevy_component 12 | add_component_operator(component_type=long_name) 13 | 14 | property_group_name = registry.get_propertyGroupName_from_longName(long_name) 15 | object = bpy.context.object 16 | 17 | target_components_metadata = object.components_meta.components 18 | component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None) 19 | propertyGroup = getattr(component_meta, property_group_name, None) 20 | 21 | 22 | assert propertyGroup.field_names == ['a', 'b', 'c'] -------------------------------------------------------------------------------- /tools/internal_generate_example_gltf_files.py: -------------------------------------------------------------------------------- 1 | import os 2 | import bpy 3 | import subprocess 4 | 5 | def test_generate_example_gltf_files(): 6 | auto_export_operator = bpy.ops.export_scenes.auto_gltf 7 | stored_settings = bpy.data.texts[".gltf_auto_export_settings"] 8 | print("export settings", stored_settings.as_string()) 9 | auto_export_operator( 10 | direct_mode = True, 11 | export_change_detection=False 12 | ) 13 | 14 | if __name__ == "__main__": 15 | examples = [ 16 | '../examples/blenvy/basic', 17 | """'../examples/blenvy/animation', 18 | '../examples/blenvy/basic_xpbd_physics', 19 | '../examples/blenvy/materials', 20 | '../examples/blenvy/multiple_levels_multiple_blendfiles',""" 21 | ] 22 | 23 | for example_path in examples: 24 | print("generating gltf files for ", example_path) 25 | assets_path = os.path.join(example_path, "assets") 26 | art_path = os.path.join(example_path, "art") 27 | blend_files = [] 28 | 29 | if os.path.exists(assets_path): 30 | for file in os.listdir(assets_path): 31 | if file.endswith(".blend"): 32 | print("file found !", file) 33 | blend_files.append(os.path.join("assets", file)) 34 | if os.path.exists(art_path): 35 | for file in os.listdir(art_path): 36 | if file.endswith(".blend"): 37 | print("file found !", file) 38 | blend_files.append(os.path.join("art", file)) 39 | 40 | 41 | print("blend files", blend_files) 42 | for blend_file in blend_files: 43 | fake_test_path = os.path.abspath("./internal_generate_example_gltf_files.py") 44 | command = "pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.0.2-linux-x64/blender --blender-template "+blend_file + " "+fake_test_path 45 | return_code = subprocess.call(command.split(" "), cwd=example_path) 46 | -------------------------------------------------------------------------------- /tools/internal_generate_release_zips.py: -------------------------------------------------------------------------------- 1 | import os 2 | import zipfile 3 | 4 | ignore_list = ['.pytest_cache', '__pycache__'] 5 | 6 | def zipdir(path, ziph): 7 | # ziph is zipfile handle 8 | for root, dirs, files in os.walk(path): 9 | # filter out invalid paths 10 | root_path = os.path.normpath(root) 11 | root_path = root_path.split(os.sep) 12 | add_file = True 13 | for sub_path in root_path: 14 | if sub_path in ignore_list: 15 | add_file = False 16 | break 17 | 18 | if add_file: 19 | for file in files: 20 | ziph.write(os.path.join(root, file), 21 | os.path.relpath(os.path.join(root, file), 22 | os.path.join(path, '..'))) 23 | 24 | with zipfile.ZipFile("blenvy.zip", mode="w", compression=zipfile.ZIP_DEFLATED) as archive: 25 | zipdir('./blenvy', archive) 26 | 27 | --------------------------------------------------------------------------------