diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index 1130e2be308..2211167dbb4 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -88,8 +88,8 @@ struct ColladaImport { Error _create_mesh_surfaces(bool p_optimize,Ref& p_mesh,const Map& p_material_map,const Collada::MeshData &meshdata,const Transform& p_local_xform,const Vector &bone_remap, const Collada::SkinControllerData *p_skin_data, const Collada::MorphControllerData *p_morph_data,Vector > p_morph_meshes=Vector >()); Error load(const String& p_path, int p_flags, bool p_force_make_tangents=false); void _fix_param_animation_tracks(); - void create_animation(int p_clip,bool p_make_tracks_in_all_bones); - void create_animations(bool p_make_tracks_in_all_bones); + void create_animation(int p_clip,bool p_make_tracks_in_all_bones, bool p_import_value_tracks); + void create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks); Set tracks_in_clips; Vector missing_textures; @@ -1898,7 +1898,7 @@ void ColladaImport::_fix_param_animation_tracks() { } -void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) { +void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks) { _fix_param_animation_tracks(); @@ -1943,14 +1943,14 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) { } - create_animation(-1,p_make_tracks_in_all_bones); + create_animation(-1,p_make_tracks_in_all_bones, p_import_value_tracks); //print_line("clipcount: "+itos(collada.state.animation_clips.size())); for(int i=0;i animation = Ref( memnew( Animation )); @@ -2251,64 +2251,68 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones - - for(int i=0;iget_path_to(nm.node); - - animation->add_track(Animation::TYPE_VALUE); - int track = animation->get_track_count() -1; - - path = path +":"+at.param; - animation->track_set_path( track , path ); - animation->track_set_imported( track , true ); //helps merging later - - - for(int i=0;i data = at.keys[i].data; - if (data.size()==1) { - //push a float - value=data[0]; - - } else if (data.size()==16) { - //matrix - print_line("value keys for matrices not supported"); - } else { - - print_line("don't know what to do with this amount of value keys: "+itos(data.size())); } - animation->track_insert_key(track,time,value); + + Collada::AnimationTrack &at = collada.state.animation_tracks[ti]; + + // take snapshots + if (!collada.state.scene_map.has(at.target)) + continue; + + NodeMap &nm = node_map[at.target]; + String path = scene->get_path_to(nm.node); + + animation->add_track(Animation::TYPE_VALUE); + int track = animation->get_track_count() - 1; + + path = path + ":" + at.param; + animation->track_set_path(track, path); + animation->track_set_imported(track, true); //helps merging later + + + for (int i = 0; i < at.keys.size(); i++) { + + float time = at.keys[i].time; + Variant value; + Vector data = at.keys[i].data; + if (data.size() == 1) { + //push a float + value = data[0]; + + } + else if (data.size() == 16) { + //matrix + print_line("value keys for matrices not supported"); + } + else { + + print_line("don't know what to do with this amount of value keys: " + itos(data.size())); + } + + animation->track_insert_key(track, time, value); + } + + + tracks_found = true; + } - - - tracks_found=true; - } @@ -2373,7 +2377,7 @@ Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_ if (p_flags&IMPORT_ANIMATION) { - state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS); + state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS,p_flags&EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS); AnimationPlayer *ap = memnew( AnimationPlayer ); for(int i=0;i EditorSceneImporterCollada::import_animation(const String& p_path ERR_FAIL_COND_V(err!=OK,RES()); - state.create_animations(p_flags&EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS); + state.create_animations(p_flags&EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS,p_flags&EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS); if (state.scene) memdelete(state.scene); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 56af35c6db3..cb8ec6d0bc2 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -2164,6 +2164,8 @@ Error EditorSceneImportPlugin::import1(const Ref& p_from uint32_t import_flags=0; if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_DETECT_LOOP) import_flags|=EditorSceneImporter::IMPORT_ANIMATION_DETECT_LOOP; + if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_KEEP_VALUE_TRACKS) + import_flags |= EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS; if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_OPTIMIZE) import_flags|=EditorSceneImporter::IMPORT_ANIMATION_OPTIMIZE; if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS) diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.h b/tools/editor/io_plugins/editor_scene_import_plugin.h index c31d3a33d32..2c27f06960a 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.h +++ b/tools/editor/io_plugins/editor_scene_import_plugin.h @@ -60,6 +60,7 @@ public: IMPORT_ANIMATION_DETECT_LOOP=4, IMPORT_ANIMATION_OPTIMIZE=8, IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS=16, + IMPORT_ANIMATION_KEEP_VALUE_TRACKS=32, IMPORT_GENERATE_TANGENT_ARRAYS=256, IMPORT_FAIL_ON_MISSING_DEPENDENCIES=512