mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-26 21:37:01 +00:00
Compare commits
No commits in common. "0b64de79da443c9d8e6d4155b8aeea4e0f10d04f" and "4f50c4f6d25a8c2e8902fddce0a440d13e666aba" have entirely different histories.
0b64de79da
...
4f50c4f6d2
@ -3373,17 +3373,6 @@
|
||||
"type": "object",
|
||||
"typeInfo": "Struct"
|
||||
},
|
||||
"bevy_gltf_blueprints::animation::Animated": {
|
||||
"additionalProperties": false,
|
||||
"isComponent": true,
|
||||
"isResource": false,
|
||||
"properties": {},
|
||||
"required": [],
|
||||
"short_name": "Animated",
|
||||
"title": "bevy_gltf_blueprints::animation::Animated",
|
||||
"type": "object",
|
||||
"typeInfo": "Struct"
|
||||
},
|
||||
"bevy_gltf_blueprints::animation::Animations": {
|
||||
"additionalProperties": false,
|
||||
"isComponent": true,
|
||||
@ -3444,22 +3433,6 @@
|
||||
"type": "array",
|
||||
"typeInfo": "TupleStruct"
|
||||
},
|
||||
"bevy_gltf_blueprints::spawn_from_blueprints::BlueprintsList": {
|
||||
"isComponent": true,
|
||||
"isResource": false,
|
||||
"items": false,
|
||||
"prefixItems": [
|
||||
{
|
||||
"type": {
|
||||
"$ref": "#/$defs/bevy_utils::hashbrown::HashMap<alloc::string::String, alloc::vec::Vec<alloc::string::String>, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>"
|
||||
}
|
||||
}
|
||||
],
|
||||
"short_name": "BlueprintsList",
|
||||
"title": "bevy_gltf_blueprints::spawn_from_blueprints::BlueprintsList",
|
||||
"type": "array",
|
||||
"typeInfo": "TupleStruct"
|
||||
},
|
||||
"bevy_gltf_blueprints::spawn_from_blueprints::SpawnHere": {
|
||||
"additionalProperties": false,
|
||||
"isComponent": true,
|
||||
@ -10718,19 +10691,6 @@
|
||||
"type": "object",
|
||||
"typeInfo": "Value"
|
||||
},
|
||||
"bevy_utils::hashbrown::HashMap<alloc::string::String, alloc::vec::Vec<alloc::string::String>, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>": {
|
||||
"additionalProperties": {
|
||||
"type": {
|
||||
"$ref": "#/$defs/alloc::vec::Vec<alloc::string::String>"
|
||||
}
|
||||
},
|
||||
"isComponent": false,
|
||||
"isResource": false,
|
||||
"short_name": "HashMap<String, Vec<String>, DefaultHashBuilder>",
|
||||
"title": "bevy_utils::hashbrown::HashMap<alloc::string::String, alloc::vec::Vec<alloc::string::String>, bevy_utils::hashbrown::hash_map::DefaultHashBuilder>",
|
||||
"type": "object",
|
||||
"typeInfo": "Map"
|
||||
},
|
||||
"bevy_utils::smallvec::SmallVec<[bevy_ecs::entity::Entity; 8]>": {
|
||||
"isComponent": false,
|
||||
"isResource": false,
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 644 KiB After Width: | Height: | Size: 626 KiB |
@ -3,11 +3,11 @@ use std::{
|
||||
collections::HashMap, fs, time::Duration
|
||||
};
|
||||
|
||||
use bevy_gltf_blueprints::{Animated, AnimationPlayerLink, Animations, BlueprintName, BlueprintsList};
|
||||
use bevy_gltf_blueprints::{AnimationPlayerLink, Animations, BlueprintName, BlueprintsList};
|
||||
pub use in_game::*;
|
||||
|
||||
use bevy::{
|
||||
ecs::query, gltf::Gltf, prelude::*, render::view::screenshot::ScreenshotManager, time::common_conditions::on_timer, window::PrimaryWindow
|
||||
ecs::query, prelude::*, render::view::screenshot::ScreenshotManager, time::common_conditions::on_timer, window::PrimaryWindow
|
||||
};
|
||||
use bevy_gltf_worlflow_examples_common_rapier::{AppState, GameState};
|
||||
|
||||
@ -19,10 +19,16 @@ fn start_game(mut next_app_state: ResMut<NextState<AppState>>) {
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Node {
|
||||
value: String,
|
||||
children: Vec<String>,
|
||||
}
|
||||
|
||||
// if the export from Blender worked correctly, we should have animations (simplified here by using AnimationPlayerLink)
|
||||
// if the export from Blender worked correctly, we should have an Entity called "Cylinder" that has two components: UnitTest, TupleTestF32
|
||||
// if the export from Blender worked correctly, we should have an Entity called "Blueprint4_nested" that has a child called "Blueprint3" that has a "BlueprintName" component with value Blueprint3
|
||||
// if the export from Blender worked correctly, we should have a blueprints_list
|
||||
// if the export from Blender worked correctly, we should have the correct tree of entities
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn validate_export(
|
||||
parents: Query<&Parent>,
|
||||
@ -30,6 +36,7 @@ fn validate_export(
|
||||
names: Query<&Name>,
|
||||
blueprints: Query<(Entity, &Name, &BlueprintName)>,
|
||||
animation_player_links: Query<(Entity, &AnimationPlayerLink)>,
|
||||
exported_cylinder: Query<(Entity, &Name, &UnitTest, &TupleTestF32)>,
|
||||
empties_candidates: Query<(Entity, &Name, &GlobalTransform)>,
|
||||
|
||||
blueprints_list: Query<(Entity, &BlueprintsList)>,
|
||||
@ -73,10 +80,11 @@ fn validate_export(
|
||||
}
|
||||
}
|
||||
|
||||
// generate parent/child "tree"
|
||||
// generate parent/child tree
|
||||
if !root.is_empty() {
|
||||
let root = root.single();
|
||||
let mut tree: HashMap<String, Vec<String>> = HashMap::new();
|
||||
// println!("root {}", root.1);
|
||||
|
||||
for child in children.iter_descendants(root.0) {
|
||||
let child_name:String = names.get(child).map_or(String::from("no_name"), |e| e.to_string() ); //|e| e.to_string(), || "no_name".to_string());
|
||||
@ -118,64 +126,17 @@ fn exit_game(mut app_exit_events: ResMut<Events<bevy::app::AppExit>>) {
|
||||
app_exit_events.send(bevy::app::AppExit);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
#[derive(Resource)]
|
||||
struct MainAnimations(Vec<Handle<AnimationClip>>);
|
||||
struct Animations(Vec<Handle<AnimationClip>>);
|
||||
*/
|
||||
|
||||
#[derive(Resource)]
|
||||
struct AnimTest(Handle<Gltf>);
|
||||
fn setup_main_scene_animations(
|
||||
asset_server: Res<AssetServer>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
/*commands.insert_resource(MainAnimations(vec![
|
||||
asset_server.load("models/World.glb#Blueprint1_jump"),
|
||||
asset_server.load("models/World.glb#Blueprint1_move"),
|
||||
|
||||
// asset_server.load("models/library/Blueprint6_animated.glb#Run"),
|
||||
|
||||
]));*/
|
||||
|
||||
commands.insert_resource(AnimTest(asset_server.load("models/World.glb")));
|
||||
}
|
||||
fn animations(
|
||||
foo:Query<(Entity, &Name, &AnimationPlayer),(Added<AnimationPlayer>)>,
|
||||
bla:Query<(Entity, &Name, &Animated),(Added<Animated>, Without<AnimationPlayerLink>)>,
|
||||
blurp: Res<AnimTest>,
|
||||
|
||||
asset_server: Res<AssetServer>,
|
||||
mut commands: Commands,
|
||||
assets_gltf: Res<Assets<Gltf>>,
|
||||
|
||||
) {
|
||||
|
||||
|
||||
for (entity, name, animated) in bla.iter() {
|
||||
// println!("animated stuf {:?} on entity {}", animated, name);
|
||||
|
||||
let gltf = assets_gltf.get(&blurp.0).unwrap();
|
||||
|
||||
let animations_list = animated;
|
||||
let mut matching_data = true;
|
||||
for animation_name in &animations_list.animations {
|
||||
if !gltf.named_animations.contains_key(animation_name){
|
||||
matching_data = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if matching_data {
|
||||
println!("inserting Animations components into {} ({:?})", name, entity);
|
||||
println!("Found match {:?}", gltf.named_animations);
|
||||
commands.entity(entity).remove::<Animations>();
|
||||
commands.entity(entity).insert((
|
||||
Animations {
|
||||
named_animations: gltf.named_animations.clone()
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/*for bla in foo.iter() {
|
||||
for bla in foo.iter() {
|
||||
let mut counter = 0;
|
||||
counter +=1;
|
||||
println!("found some animations {} {}", counter, bla.1);
|
||||
@ -189,7 +150,9 @@ fn animations(
|
||||
named_animations:
|
||||
})*/
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GamePlugin;
|
||||
@ -199,15 +162,12 @@ impl Plugin for GamePlugin {
|
||||
.add_systems(Update, validate_export)
|
||||
.add_systems(OnEnter(AppState::MenuRunning), start_game)
|
||||
.add_systems(OnEnter(AppState::AppRunning), setup_game)
|
||||
|
||||
.add_systems(OnEnter(AppState::MenuRunning), setup_main_scene_animations)
|
||||
|
||||
.add_systems(Update, animations.run_if(in_state(AppState::AppRunning)))
|
||||
/* .add_systems(Update, generate_screenshot.run_if(on_timer(Duration::from_secs_f32(0.2)))) // TODO: run once
|
||||
.add_systems(Update, animations)
|
||||
.add_systems(Update, generate_screenshot.run_if(on_timer(Duration::from_secs_f32(0.2)))) // TODO: run once
|
||||
.add_systems(
|
||||
Update,
|
||||
exit_game.run_if(on_timer(Duration::from_secs_f32(0.5))),
|
||||
) // shut down the app after this time*/
|
||||
) // shut down the app after this time
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ def copy_animation_data(source, target):
|
||||
bpy.ops.object.make_links_data(type='ANIMATION')
|
||||
# we add an "animated" flag component
|
||||
target['Animated'] = f'(animations: {animations})'.replace("'", '"') #'(animations: [])' #
|
||||
|
||||
"""print("copying animation data for", source.name, target.animation_data)
|
||||
properties = [p.identifier for p in source.animation_data.bl_rna.properties if not p.is_readonly]
|
||||
for prop in properties:
|
||||
|
@ -30,10 +30,6 @@ def setup_data(request):
|
||||
diagnostics_file_path = os.path.join(root_path, "bevy_diagnostics.json")
|
||||
if os.path.exists(diagnostics_file_path):
|
||||
os.remove(diagnostics_file_path)
|
||||
|
||||
hierarchy_file_path = os.path.join(root_path, "bevy_hierarchy.json")
|
||||
if os.path.exists(hierarchy_file_path):
|
||||
os.remove(hierarchy_file_path)
|
||||
|
||||
screenshot_observed_path = os.path.join(root_path, "screenshot.png")
|
||||
if os.path.exists(screenshot_observed_path):
|
||||
|
Loading…
Reference in New Issue
Block a user