virtualx-engine/modules/assimp/editor_scene_importer_assimp.h

150 lines
6.1 KiB
C++
Raw Normal View History

/*************************************************************************/
/* editor_scene_importer_assimp.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef EDITOR_SCENE_IMPORTER_ASSIMP_H
#define EDITOR_SCENE_IMPORTER_ASSIMP_H
#ifdef TOOLS_ENABLED
#include "core/bind/core_bind.h"
#include "core/io/resource_importer.h"
#include "core/vector.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/project_settings_editor.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/skeleton.h"
#include "scene/3d/spatial.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
#include "scene/resources/surface_tool.h"
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
#include <assimp/matrix4x4.h>
#include <assimp/scene.h>
#include <assimp/types.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/LogStream.hpp>
#include <assimp/Logger.hpp>
FBX Importer Generation 3 Basic skin support Various fixes - Fixes bind mount id and mesh index - Fixed duplicate nodes being created - Prevented leak when instances being freed during re-import. - Improved camera and light transform import - skeleton handling and technical debt removal - ASSIMP: bone nodes were unlinked from bones by this code - bone_add working can distinguish between armatutes - Updated transform to be the correct offset - Added safety for state.root node errors - Fixed memory leak with leaf bones - Implemented children re-parenting for mesh template - import_animation fixes to basic skeleton data - Adds some more debug messages - Fixed Godot import segfault - Fix build failing on mono - Clear resources we use which are no longer required after import - Fixed bone duplication issue - Working skeleton_bone_map which can lookup armatures properly now. - Fixed stack being used up when mesh swapped & Fixed bone ID Additional notes: We use a mesh template which is a fake node to instance the initial mesh nodes . This is to ensure the entire tree can be built. We replace mesh node templates with the real mesh after the skeleton is available, since this makes it ensure that the fully built skeleton exists with all bones, all nodes, etc. The bone stack is a stack which pops when it finds bones, this overcomes duplicate bones with the same names. FBX has lots of these because animation armature has bone names like bone001 and another armature will also have bone001 Fixed errors in node path assignment Simple explanation: - Every mesh uses a node from the stack - Node stack was empties before completed - Every time node not found, stack must be rebuilt to maintain correct armature order :) Additional fixes: - Fixes destructor in assimp - Implements aiNode* mArmature in bone data - Implements aiNode* mParent in bone data - Fixes parent ID on bones. Implemented skeleton assignment in generate_mesh_indicies This is the only place we can safely do a lookup for the skeleton for the mesh.h I used a pointer reference so we can pass this back out, since the skeleton assignment happens inside the function. Added mesh re-parenting to the armature node this is a permanent feature and must be enforced, just like GLTF2 specification. Fixed import_animation spawning tracks per skin
2019-11-05 18:54:34 +01:00
#include <map>
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
#include "import_state.h"
#include "import_utils.h"
using namespace AssimpImporter;
class AssimpStream : public Assimp::LogStream {
public:
// Constructor
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
AssimpStream() {}
// Destructor
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
~AssimpStream() {}
// Write something using your own functionality
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
void write(const char *message) {
print_verbose(String("Open Asset Import: ") + String(message).strip_edges());
}
};
class EditorSceneImporterAssimp : public EditorSceneImporter {
private:
GDCLASS(EditorSceneImporterAssimp, EditorSceneImporter);
struct AssetImportAnimation {
enum Interpolation {
INTERP_LINEAR,
INTERP_STEP,
INTERP_CATMULLROMSPLINE,
INTERP_CUBIC_SPLINE
};
};
2019-04-13 20:19:26 +02:00
struct BoneInfo {
uint32_t bone;
float weight;
};
FBX Importer Generation 3 Basic skin support Various fixes - Fixes bind mount id and mesh index - Fixed duplicate nodes being created - Prevented leak when instances being freed during re-import. - Improved camera and light transform import - skeleton handling and technical debt removal - ASSIMP: bone nodes were unlinked from bones by this code - bone_add working can distinguish between armatutes - Updated transform to be the correct offset - Added safety for state.root node errors - Fixed memory leak with leaf bones - Implemented children re-parenting for mesh template - import_animation fixes to basic skeleton data - Adds some more debug messages - Fixed Godot import segfault - Fix build failing on mono - Clear resources we use which are no longer required after import - Fixed bone duplication issue - Working skeleton_bone_map which can lookup armatures properly now. - Fixed stack being used up when mesh swapped & Fixed bone ID Additional notes: We use a mesh template which is a fake node to instance the initial mesh nodes . This is to ensure the entire tree can be built. We replace mesh node templates with the real mesh after the skeleton is available, since this makes it ensure that the fully built skeleton exists with all bones, all nodes, etc. The bone stack is a stack which pops when it finds bones, this overcomes duplicate bones with the same names. FBX has lots of these because animation armature has bone names like bone001 and another armature will also have bone001 Fixed errors in node path assignment Simple explanation: - Every mesh uses a node from the stack - Node stack was empties before completed - Every time node not found, stack must be rebuilt to maintain correct armature order :) Additional fixes: - Fixes destructor in assimp - Implements aiNode* mArmature in bone data - Implements aiNode* mParent in bone data - Fixes parent ID on bones. Implemented skeleton assignment in generate_mesh_indicies This is the only place we can safely do a lookup for the skeleton for the mesh.h I used a pointer reference so we can pass this back out, since the skeleton assignment happens inside the function. Added mesh re-parenting to the armature node this is a permanent feature and must be enforced, just like GLTF2 specification. Fixed import_animation spawning tracks per skin
2019-11-05 18:54:34 +01:00
Ref<Mesh> _generate_mesh_from_surface_indices(ImportState &state, const Vector<int> &p_surface_indices,
const aiNode *assimp_node, Ref<Skin> &skin,
Skeleton *&skeleton_assigned);
2019-04-13 20:19:26 +02:00
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
// simple object creation functions
FBX Importer Generation 3 Basic skin support Various fixes - Fixes bind mount id and mesh index - Fixed duplicate nodes being created - Prevented leak when instances being freed during re-import. - Improved camera and light transform import - skeleton handling and technical debt removal - ASSIMP: bone nodes were unlinked from bones by this code - bone_add working can distinguish between armatutes - Updated transform to be the correct offset - Added safety for state.root node errors - Fixed memory leak with leaf bones - Implemented children re-parenting for mesh template - import_animation fixes to basic skeleton data - Adds some more debug messages - Fixed Godot import segfault - Fix build failing on mono - Clear resources we use which are no longer required after import - Fixed bone duplication issue - Working skeleton_bone_map which can lookup armatures properly now. - Fixed stack being used up when mesh swapped & Fixed bone ID Additional notes: We use a mesh template which is a fake node to instance the initial mesh nodes . This is to ensure the entire tree can be built. We replace mesh node templates with the real mesh after the skeleton is available, since this makes it ensure that the fully built skeleton exists with all bones, all nodes, etc. The bone stack is a stack which pops when it finds bones, this overcomes duplicate bones with the same names. FBX has lots of these because animation armature has bone names like bone001 and another armature will also have bone001 Fixed errors in node path assignment Simple explanation: - Every mesh uses a node from the stack - Node stack was empties before completed - Every time node not found, stack must be rebuilt to maintain correct armature order :) Additional fixes: - Fixes destructor in assimp - Implements aiNode* mArmature in bone data - Implements aiNode* mParent in bone data - Fixes parent ID on bones. Implemented skeleton assignment in generate_mesh_indicies This is the only place we can safely do a lookup for the skeleton for the mesh.h I used a pointer reference so we can pass this back out, since the skeleton assignment happens inside the function. Added mesh re-parenting to the armature node this is a permanent feature and must be enforced, just like GLTF2 specification. Fixed import_animation spawning tracks per skin
2019-11-05 18:54:34 +01:00
Spatial *create_light(ImportState &state,
const String &node_name,
Transform &look_at_transform);
Spatial *create_camera(
ImportState &state,
const String &node_name,
Transform &look_at_transform);
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
// non recursive - linear so must not use recursive arguments
FBX Importer Generation 3 Basic skin support Various fixes - Fixes bind mount id and mesh index - Fixed duplicate nodes being created - Prevented leak when instances being freed during re-import. - Improved camera and light transform import - skeleton handling and technical debt removal - ASSIMP: bone nodes were unlinked from bones by this code - bone_add working can distinguish between armatutes - Updated transform to be the correct offset - Added safety for state.root node errors - Fixed memory leak with leaf bones - Implemented children re-parenting for mesh template - import_animation fixes to basic skeleton data - Adds some more debug messages - Fixed Godot import segfault - Fix build failing on mono - Clear resources we use which are no longer required after import - Fixed bone duplication issue - Working skeleton_bone_map which can lookup armatures properly now. - Fixed stack being used up when mesh swapped & Fixed bone ID Additional notes: We use a mesh template which is a fake node to instance the initial mesh nodes . This is to ensure the entire tree can be built. We replace mesh node templates with the real mesh after the skeleton is available, since this makes it ensure that the fully built skeleton exists with all bones, all nodes, etc. The bone stack is a stack which pops when it finds bones, this overcomes duplicate bones with the same names. FBX has lots of these because animation armature has bone names like bone001 and another armature will also have bone001 Fixed errors in node path assignment Simple explanation: - Every mesh uses a node from the stack - Node stack was empties before completed - Every time node not found, stack must be rebuilt to maintain correct armature order :) Additional fixes: - Fixes destructor in assimp - Implements aiNode* mArmature in bone data - Implements aiNode* mParent in bone data - Fixes parent ID on bones. Implemented skeleton assignment in generate_mesh_indicies This is the only place we can safely do a lookup for the skeleton for the mesh.h I used a pointer reference so we can pass this back out, since the skeleton assignment happens inside the function. Added mesh re-parenting to the armature node this is a permanent feature and must be enforced, just like GLTF2 specification. Fixed import_animation spawning tracks per skin
2019-11-05 18:54:34 +01:00
MeshInstance *create_mesh(ImportState &state, const aiNode *assimp_node, const String &node_name, Node *active_node, Transform node_transform);
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
// recursive node generator
FBX Importer Generation 3 Basic skin support Various fixes - Fixes bind mount id and mesh index - Fixed duplicate nodes being created - Prevented leak when instances being freed during re-import. - Improved camera and light transform import - skeleton handling and technical debt removal - ASSIMP: bone nodes were unlinked from bones by this code - bone_add working can distinguish between armatutes - Updated transform to be the correct offset - Added safety for state.root node errors - Fixed memory leak with leaf bones - Implemented children re-parenting for mesh template - import_animation fixes to basic skeleton data - Adds some more debug messages - Fixed Godot import segfault - Fix build failing on mono - Clear resources we use which are no longer required after import - Fixed bone duplication issue - Working skeleton_bone_map which can lookup armatures properly now. - Fixed stack being used up when mesh swapped & Fixed bone ID Additional notes: We use a mesh template which is a fake node to instance the initial mesh nodes . This is to ensure the entire tree can be built. We replace mesh node templates with the real mesh after the skeleton is available, since this makes it ensure that the fully built skeleton exists with all bones, all nodes, etc. The bone stack is a stack which pops when it finds bones, this overcomes duplicate bones with the same names. FBX has lots of these because animation armature has bone names like bone001 and another armature will also have bone001 Fixed errors in node path assignment Simple explanation: - Every mesh uses a node from the stack - Node stack was empties before completed - Every time node not found, stack must be rebuilt to maintain correct armature order :) Additional fixes: - Fixes destructor in assimp - Implements aiNode* mArmature in bone data - Implements aiNode* mParent in bone data - Fixes parent ID on bones. Implemented skeleton assignment in generate_mesh_indicies This is the only place we can safely do a lookup for the skeleton for the mesh.h I used a pointer reference so we can pass this back out, since the skeleton assignment happens inside the function. Added mesh re-parenting to the armature node this is a permanent feature and must be enforced, just like GLTF2 specification. Fixed import_animation spawning tracks per skin
2019-11-05 18:54:34 +01:00
void _generate_node(ImportState &state, const aiNode *assimp_node);
void _insert_animation_track(ImportState &scene, const aiAnimation *assimp_anim, int track_id,
int anim_fps, Ref<Animation> animation, float ticks_per_second,
Skeleton *skeleton, const NodePath &node_path,
const String &node_name, aiBone *track_bone);
2019-04-13 20:19:26 +02:00
void _import_animation(ImportState &state, int p_animation_index, int p_bake_fps);
FBX Importer Generation 3 Basic skin support Various fixes - Fixes bind mount id and mesh index - Fixed duplicate nodes being created - Prevented leak when instances being freed during re-import. - Improved camera and light transform import - skeleton handling and technical debt removal - ASSIMP: bone nodes were unlinked from bones by this code - bone_add working can distinguish between armatutes - Updated transform to be the correct offset - Added safety for state.root node errors - Fixed memory leak with leaf bones - Implemented children re-parenting for mesh template - import_animation fixes to basic skeleton data - Adds some more debug messages - Fixed Godot import segfault - Fix build failing on mono - Clear resources we use which are no longer required after import - Fixed bone duplication issue - Working skeleton_bone_map which can lookup armatures properly now. - Fixed stack being used up when mesh swapped & Fixed bone ID Additional notes: We use a mesh template which is a fake node to instance the initial mesh nodes . This is to ensure the entire tree can be built. We replace mesh node templates with the real mesh after the skeleton is available, since this makes it ensure that the fully built skeleton exists with all bones, all nodes, etc. The bone stack is a stack which pops when it finds bones, this overcomes duplicate bones with the same names. FBX has lots of these because animation armature has bone names like bone001 and another armature will also have bone001 Fixed errors in node path assignment Simple explanation: - Every mesh uses a node from the stack - Node stack was empties before completed - Every time node not found, stack must be rebuilt to maintain correct armature order :) Additional fixes: - Fixes destructor in assimp - Implements aiNode* mArmature in bone data - Implements aiNode* mParent in bone data - Fixes parent ID on bones. Implemented skeleton assignment in generate_mesh_indicies This is the only place we can safely do a lookup for the skeleton for the mesh.h I used a pointer reference so we can pass this back out, since the skeleton assignment happens inside the function. Added mesh re-parenting to the armature node this is a permanent feature and must be enforced, just like GLTF2 specification. Fixed import_animation spawning tracks per skin
2019-11-05 18:54:34 +01:00
Node *get_node_by_name(ImportState &state, String name);
aiBone *get_bone_from_stack(ImportState &state, aiString name);
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
Spatial *_generate_scene(const String &p_path, aiScene *scene, const uint32_t p_flags, int p_bake_fps, const int32_t p_max_bone_weights);
2019-04-13 20:19:26 +02:00
template <class T>
T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, AssetImportAnimation::Interpolation p_interp);
void _register_project_setting_import(const String generic, const String import_setting_string, const Vector<String> &exts, List<String> *r_extensions, const bool p_enabled) const;
struct ImportFormat {
Vector<String> extensions;
bool is_default;
};
protected:
static void _bind_methods();
public:
EditorSceneImporterAssimp() {
Assimp::DefaultLogger::create("", Assimp::Logger::VERBOSE);
unsigned int severity = Assimp::Logger::Info | Assimp::Logger::Err | Assimp::Logger::Warn;
Assimp::DefaultLogger::get()->attachStream(new AssimpStream(), severity);
}
~EditorSceneImporterAssimp() {
Assimp::DefaultLogger::kill();
}
virtual void get_extensions(List<String> *r_extensions) const;
virtual uint32_t get_import_flags() const;
virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL);
Assimp FBX Import support Issues fixed: - Updated assimp to latest and backported fixes into godot. - Fixed file scale being ignored from FBX file. - Fixed bone removal - Implemented proper armature binding - Fixed recursion not always going through the entire path - Implemented assimp global scaling system - Fixed assimp global scale process to support unit conversion - Implemented proper fbx scaling - Fixed asserts caused by missing faces in some models which could crash - Fixed valid bone removal - Fixed root node being overwriten by assimp which caused data loss - Fixed armature construction so that it works with multiple roots - Implemented basic support for FBX standard materials - Refactoring to improve code quality and improve function reuse. - Simplified node creation from assimp scene into subsections: create_light, create_mesh, create_bone. - Creating meshes is now done after hierarchy is created so that the skeleton is always available. - Added support to assimp to support file scale in all formats which call SetFileScale. - Many other fixes provided into assimp. Known issues: - FBX pivots from Maya do not currently work. (workaround: for now use blender import and export to remove pivot tracks) - Hierarchy creates an extra node for each mesh - this was done intentionally but we intended to do a pass to remove these as they're a required node. - When an animated mesh has not executed any animation the rest pose is wrong. Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2019-08-30 03:21:40 +02:00
Ref<Image> load_image(ImportState &state, const aiScene *p_scene, String p_path);
FBX Importer Generation 3 Basic skin support Various fixes - Fixes bind mount id and mesh index - Fixed duplicate nodes being created - Prevented leak when instances being freed during re-import. - Improved camera and light transform import - skeleton handling and technical debt removal - ASSIMP: bone nodes were unlinked from bones by this code - bone_add working can distinguish between armatutes - Updated transform to be the correct offset - Added safety for state.root node errors - Fixed memory leak with leaf bones - Implemented children re-parenting for mesh template - import_animation fixes to basic skeleton data - Adds some more debug messages - Fixed Godot import segfault - Fix build failing on mono - Clear resources we use which are no longer required after import - Fixed bone duplication issue - Working skeleton_bone_map which can lookup armatures properly now. - Fixed stack being used up when mesh swapped & Fixed bone ID Additional notes: We use a mesh template which is a fake node to instance the initial mesh nodes . This is to ensure the entire tree can be built. We replace mesh node templates with the real mesh after the skeleton is available, since this makes it ensure that the fully built skeleton exists with all bones, all nodes, etc. The bone stack is a stack which pops when it finds bones, this overcomes duplicate bones with the same names. FBX has lots of these because animation armature has bone names like bone001 and another armature will also have bone001 Fixed errors in node path assignment Simple explanation: - Every mesh uses a node from the stack - Node stack was empties before completed - Every time node not found, stack must be rebuilt to maintain correct armature order :) Additional fixes: - Fixes destructor in assimp - Implements aiNode* mArmature in bone data - Implements aiNode* mParent in bone data - Fixes parent ID on bones. Implemented skeleton assignment in generate_mesh_indicies This is the only place we can safely do a lookup for the skeleton for the mesh.h I used a pointer reference so we can pass this back out, since the skeleton assignment happens inside the function. Added mesh re-parenting to the armature node this is a permanent feature and must be enforced, just like GLTF2 specification. Fixed import_animation spawning tracks per skin
2019-11-05 18:54:34 +01:00
static void RegenerateBoneStack(ImportState &state);
void RegenerateBoneStack(ImportState &state, aiMesh *mesh);
};
#endif
#endif