Added gltf asset load, plugin call for bevy_blender and GlftAssetType

This commit is contained in:
Franklin Blanco 2023-11-16 09:27:15 -08:00
parent 50539f2ac9
commit bb681decf5
6 changed files with 23 additions and 2 deletions

12
Cargo.lock generated
View File

@ -759,6 +759,17 @@ dependencies = [
"thiserror",
]
[[package]]
name = "bevy_gltf_components"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd745a2988c631286404e12d184d4a30a634fbbba1deceaaa1ca7fcbc607cc7a"
dependencies = [
"bevy",
"ron",
"serde",
]
[[package]]
name = "bevy_hanabi"
version = "0.8.0"
@ -1914,6 +1925,7 @@ dependencies = [
"bevy-inspector-egui",
"bevy-trait-query",
"bevy_editor_pls",
"bevy_gltf_components",
"bevy_hanabi",
"bevy_rapier3d",
]

View File

@ -20,4 +20,5 @@ bevy-inspector-egui = "0.21.0"
bevy_editor_pls = "0.6"
bevy_rapier3d = { version = "0.23", features = ["debug-render-3d"] }
bevy_hanabi = { version = "0.8", default-features = false, features = [ "3d" ] }
bevy-trait-query = "0.4.0"
bevy-trait-query = "0.4.0"
bevy_gltf_components = "0.2.0"

View File

@ -7,3 +7,4 @@ pub mod inventory_screen;
pub mod muzzle_flash;
pub mod player;
pub mod settings_screen;
pub mod proxy;

View File

View File

@ -2,6 +2,7 @@
#![feature(trivial_bounds)]
#![feature(return_position_impl_trait_in_trait)]
use bevy::prelude::*;
use bevy_gltf_components::ComponentsFromGltfPlugin;
use bevy_rapier3d::prelude::*;
use scenes::scene1;
use ui::{editor::plugin::MainEditorUiPlugin, game::plugin::MainGameUIPlugin};
@ -27,6 +28,7 @@ fn main() {
fn setup_plugins(application: &mut App) {
application
.add_plugins(DefaultPlugins)
.add_plugins(ComponentsFromGltfPlugin)
//.add_plugins(DefaultInspectorConfigPlugin)
.add_plugins(RapierPhysicsPlugin::<NoUserData>::default())
//.add_plugins(bevy_egui::EguiPlugin)

View File

@ -10,6 +10,7 @@ use super::load_state::GameLoadState;
#[derive(PartialEq, Eq, PartialOrd, Ord, Reflect)]
pub enum GltfAssetType {
Firearm(Firearm),
Character,
#[allow(unused)]
Enemy,
}
@ -44,8 +45,12 @@ pub fn load_all_assets(
asset_type: GltfAssetType::Firearm(Firearm::Glock17),
asset: asset_server.load(Firearm::Glock17.firearm_data().asset_path),
};
let main_character_asset = GltfAsset {
asset_type: GltfAssetType::Character,
asset: asset_server.load("character/main_character.glb"),
};
commands.insert_resource(GltfAssets {
assets: Vec::from([m4a1_gltf_asset, glock17_gltf_asset]),
assets: Vec::from([m4a1_gltf_asset, glock17_gltf_asset, main_character_asset]),
});
game_load_state.assets_loaded = true;
// This works becaue this system is called on startup, so commands will finish running when game starts the update phase.