diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index f7a58ebdc..9b39c2883 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -66,7 +66,6 @@ namespace FBX { using namespace Util; - #define MAGIC_NODE_TAG "_$AssimpFbx$" #define CONVERT_FBX_TIME(time) static_cast(time) / 46186158000L @@ -74,373 +73,6 @@ using namespace Util; // XXX vc9's debugger won't step into anonymous namespaces //namespace { -/** Dummy class to encapsulate the conversion process */ -class Converter -{ -public: - /** - * The different parts that make up the final local transformation of a fbx-node - */ - enum TransformationComp - { - TransformationComp_Translation = 0, - TransformationComp_RotationOffset, - TransformationComp_RotationPivot, - TransformationComp_PreRotation, - TransformationComp_Rotation, - TransformationComp_PostRotation, - TransformationComp_RotationPivotInverse, - TransformationComp_ScalingOffset, - TransformationComp_ScalingPivot, - TransformationComp_Scaling, - TransformationComp_ScalingPivotInverse, - TransformationComp_GeometricTranslation, - TransformationComp_GeometricRotation, - TransformationComp_GeometricScaling, - - TransformationComp_MAXIMUM - }; - -public: - Converter( aiScene* out, const Document& doc ); - ~Converter(); - -private: - // ------------------------------------------------------------------------------------------------ - // find scene root and trigger recursive scene conversion - void ConvertRootNode(); - - // ------------------------------------------------------------------------------------------------ - // collect and assign child nodes - void ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform = aiMatrix4x4() ); - - // ------------------------------------------------------------------------------------------------ - void ConvertLights( const Model& model ); - - // ------------------------------------------------------------------------------------------------ - void ConvertCameras( const Model& model ); - - // ------------------------------------------------------------------------------------------------ - void ConvertLight( const Model& model, const Light& light ); - - // ------------------------------------------------------------------------------------------------ - void ConvertCamera( const Model& model, const Camera& cam ); - - // ------------------------------------------------------------------------------------------------ - // this returns unified names usable within assimp identifiers (i.e. no space characters - - // while these would be allowed, they are a potential trouble spot so better not use them). - const char* NameTransformationComp( TransformationComp comp ); - - // ------------------------------------------------------------------------------------------------ - // note: this returns the REAL fbx property names - const char* NameTransformationCompProperty( TransformationComp comp ); - - // ------------------------------------------------------------------------------------------------ - aiVector3D TransformationCompDefaultValue( TransformationComp comp ); - - // ------------------------------------------------------------------------------------------------ - void GetRotationMatrix( Model::RotOrder mode, const aiVector3D& rotation, aiMatrix4x4& out ); - // ------------------------------------------------------------------------------------------------ - /** - * checks if a node has more than just scaling, rotation and translation components - */ - bool NeedsComplexTransformationChain( const Model& model ); - - // ------------------------------------------------------------------------------------------------ - // note: name must be a FixNodeName() result - std::string NameTransformationChainNode( const std::string& name, TransformationComp comp ); - - // ------------------------------------------------------------------------------------------------ - /** - * note: memory for output_nodes will be managed by the caller - */ - void GenerateTransformationNodeChain( const Model& model, std::vector& output_nodes ); - - // ------------------------------------------------------------------------------------------------ - void SetupNodeMetadata( const Model& model, aiNode& nd ); - - // ------------------------------------------------------------------------------------------------ - void ConvertModel( const Model& model, aiNode& nd, const aiMatrix4x4& node_global_transform ); - - // ------------------------------------------------------------------------------------------------ - // MeshGeometry -> aiMesh, return mesh index + 1 or 0 if the conversion failed - std::vector ConvertMesh( const MeshGeometry& mesh, const Model& model, - const aiMatrix4x4& node_global_transform ); - - // ------------------------------------------------------------------------------------------------ - aiMesh* SetupEmptyMesh( const MeshGeometry& mesh ); - - // ------------------------------------------------------------------------------------------------ - unsigned int ConvertMeshSingleMaterial( const MeshGeometry& mesh, const Model& model, - const aiMatrix4x4& node_global_transform ); - - // ------------------------------------------------------------------------------------------------ - std::vector ConvertMeshMultiMaterial( const MeshGeometry& mesh, const Model& model, - const aiMatrix4x4& node_global_transform ); - - // ------------------------------------------------------------------------------------------------ - unsigned int ConvertMeshMultiMaterial( const MeshGeometry& mesh, const Model& model, - MatIndexArray::value_type index, - const aiMatrix4x4& node_global_transform ); - - // ------------------------------------------------------------------------------------------------ - static const unsigned int NO_MATERIAL_SEPARATION = /* std::numeric_limits::max() */ - static_cast(-1); - - // ------------------------------------------------------------------------------------------------ - /** - * - if materialIndex == NO_MATERIAL_SEPARATION, materials are not taken into - * account when determining which weights to include. - * - outputVertStartIndices is only used when a material index is specified, it gives for - * each output vertex the DOM index it maps to. - */ - void ConvertWeights( aiMesh* out, const Model& model, const MeshGeometry& geo, - const aiMatrix4x4& node_global_transform = aiMatrix4x4(), - unsigned int materialIndex = NO_MATERIAL_SEPARATION, - std::vector* outputVertStartIndices = NULL ); - - // ------------------------------------------------------------------------------------------------ - void ConvertCluster( std::vector& bones, const Model& /*model*/, const Cluster& cl, - std::vector& out_indices, - std::vector& index_out_indices, - std::vector& count_out_indices, - const aiMatrix4x4& node_global_transform ); - - // ------------------------------------------------------------------------------------------------ - void ConvertMaterialForMesh( aiMesh* out, const Model& model, const MeshGeometry& geo, - MatIndexArray::value_type materialIndex ); - - // ------------------------------------------------------------------------------------------------ - unsigned int GetDefaultMaterial(); - - - // ------------------------------------------------------------------------------------------------ - // Material -> aiMaterial - unsigned int ConvertMaterial( const Material& material, const MeshGeometry* const mesh ); - - // ------------------------------------------------------------------------------------------------ - // Video -> aiTexture - unsigned int ConvertVideo( const Video& video ); - - // ------------------------------------------------------------------------------------------------ - void TrySetTextureProperties( aiMaterial* out_mat, const TextureMap& textures, - const std::string& propName, - aiTextureType target, const MeshGeometry* const mesh ); - - // ------------------------------------------------------------------------------------------------ - void TrySetTextureProperties( aiMaterial* out_mat, const LayeredTextureMap& layeredTextures, - const std::string& propName, - aiTextureType target, const MeshGeometry* const mesh ); - - // ------------------------------------------------------------------------------------------------ - void SetTextureProperties( aiMaterial* out_mat, const TextureMap& textures, const MeshGeometry* const mesh ); - - // ------------------------------------------------------------------------------------------------ - void SetTextureProperties( aiMaterial* out_mat, const LayeredTextureMap& layeredTextures, const MeshGeometry* const mesh ); - - // ------------------------------------------------------------------------------------------------ - aiColor3D GetColorPropertyFromMaterial( const PropertyTable& props, const std::string& baseName, - bool& result ); - aiColor3D GetColorPropertyFactored( const PropertyTable& props, const std::string& colorName, - const std::string& factorName, bool& result, bool useTemplate=true ); - aiColor3D GetColorProperty( const PropertyTable& props, const std::string& colorName, - bool& result, bool useTemplate=true ); - - // ------------------------------------------------------------------------------------------------ - void SetShadingPropertiesCommon( aiMaterial* out_mat, const PropertyTable& props ); - - // ------------------------------------------------------------------------------------------------ - // get the number of fps for a FrameRate enumerated value - static double FrameRateToDouble( FileGlobalSettings::FrameRate fp, double customFPSVal = -1.0 ); - - // ------------------------------------------------------------------------------------------------ - // convert animation data to aiAnimation et al - void ConvertAnimations(); - - // ------------------------------------------------------------------------------------------------ - // rename a node already partially converted. fixed_name is a string previously returned by - // FixNodeName, new_name specifies the string FixNodeName should return on all further invocations - // which would previously have returned the old value. - // - // this also updates names in node animations, cameras and light sources and is thus slow. - // - // NOTE: the caller is responsible for ensuring that the new name is unique and does - // not collide with any other identifiers. The best way to ensure this is to only - // append to the old name, which is guaranteed to match these requirements. - void RenameNode( const std::string& fixed_name, const std::string& new_name ); - - // ------------------------------------------------------------------------------------------------ - // takes a fbx node name and returns the identifier to be used in the assimp output scene. - // the function is guaranteed to provide consistent results over multiple invocations - // UNLESS RenameNode() is called for a particular node name. - std::string FixNodeName( const std::string& name ); - - typedef std::map LayerMap; - - // XXX: better use multi_map .. - typedef std::map > NodeMap; - - - // ------------------------------------------------------------------------------------------------ - void ConvertAnimationStack( const AnimationStack& st ); - - // ------------------------------------------------------------------------------------------------ - void GenerateNodeAnimations( std::vector& node_anims, - const std::string& fixed_name, - const std::vector& curves, - const LayerMap& layer_map, - int64_t start, int64_t stop, - double& max_time, - double& min_time ); - - // ------------------------------------------------------------------------------------------------ - bool IsRedundantAnimationData( const Model& target, - TransformationComp comp, - const std::vector& curves ); - - // ------------------------------------------------------------------------------------------------ - aiNodeAnim* GenerateRotationNodeAnim( const std::string& name, - const Model& target, - const std::vector& curves, - const LayerMap& layer_map, - int64_t start, int64_t stop, - double& max_time, - double& min_time ); - - // ------------------------------------------------------------------------------------------------ - aiNodeAnim* GenerateScalingNodeAnim( const std::string& name, - const Model& /*target*/, - const std::vector& curves, - const LayerMap& layer_map, - int64_t start, int64_t stop, - double& max_time, - double& min_time ); - - // ------------------------------------------------------------------------------------------------ - aiNodeAnim* GenerateTranslationNodeAnim( const std::string& name, - const Model& /*target*/, - const std::vector& curves, - const LayerMap& layer_map, - int64_t start, int64_t stop, - double& max_time, - double& min_time, - bool inverse = false ); - - // ------------------------------------------------------------------------------------------------ - // generate node anim, extracting only Rotation, Scaling and Translation from the given chain - aiNodeAnim* GenerateSimpleNodeAnim( const std::string& name, - const Model& target, - NodeMap::const_iterator chain[ TransformationComp_MAXIMUM ], - NodeMap::const_iterator iter_end, - const LayerMap& layer_map, - int64_t start, int64_t stop, - double& max_time, - double& min_time, - bool reverse_order = false ); - - // key (time), value, mapto (component index) - typedef std::tuple, std::shared_ptr, unsigned int > KeyFrameList; - typedef std::vector KeyFrameListList; - - // ------------------------------------------------------------------------------------------------ - KeyFrameListList GetKeyframeList( const std::vector& nodes, int64_t start, int64_t stop ); - - // ------------------------------------------------------------------------------------------------ - KeyTimeList GetKeyTimeList( const KeyFrameListList& inputs ); - - // ------------------------------------------------------------------------------------------------ - void InterpolateKeys( aiVectorKey* valOut, const KeyTimeList& keys, const KeyFrameListList& inputs, - const aiVector3D& def_value, - double& max_time, - double& min_time ); - - // ------------------------------------------------------------------------------------------------ - void InterpolateKeys( aiQuatKey* valOut, const KeyTimeList& keys, const KeyFrameListList& inputs, - const aiVector3D& def_value, - double& maxTime, - double& minTime, - Model::RotOrder order ); - - // ------------------------------------------------------------------------------------------------ - void ConvertTransformOrder_TRStoSRT( aiQuatKey* out_quat, aiVectorKey* out_scale, - aiVectorKey* out_translation, - const KeyFrameListList& scaling, - const KeyFrameListList& translation, - const KeyFrameListList& rotation, - const KeyTimeList& times, - double& maxTime, - double& minTime, - Model::RotOrder order, - const aiVector3D& def_scale, - const aiVector3D& def_translate, - const aiVector3D& def_rotation ); - - // ------------------------------------------------------------------------------------------------ - // euler xyz -> quat - aiQuaternion EulerToQuaternion( const aiVector3D& rot, Model::RotOrder order ); - - // ------------------------------------------------------------------------------------------------ - void ConvertScaleKeys( aiNodeAnim* na, const std::vector& nodes, const LayerMap& /*layers*/, - int64_t start, int64_t stop, - double& maxTime, - double& minTime ); - - // ------------------------------------------------------------------------------------------------ - void ConvertTranslationKeys( aiNodeAnim* na, const std::vector& nodes, - const LayerMap& /*layers*/, - int64_t start, int64_t stop, - double& maxTime, - double& minTime ); - - // ------------------------------------------------------------------------------------------------ - void ConvertRotationKeys( aiNodeAnim* na, const std::vector& nodes, - const LayerMap& /*layers*/, - int64_t start, int64_t stop, - double& maxTime, - double& minTime, - Model::RotOrder order ); - - // ------------------------------------------------------------------------------------------------ - // copy generated meshes, animations, lights, cameras and textures to the output scene - void TransferDataToScene(); - -private: - - // 0: not assigned yet, others: index is value - 1 - unsigned int defaultMaterialIndex; - - std::vector meshes; - std::vector materials; - std::vector animations; - std::vector lights; - std::vector cameras; - std::vector textures; - - typedef std::map MaterialMap; - MaterialMap materials_converted; - - typedef std::map VideoMap; - VideoMap textures_converted; - - typedef std::map > MeshMap; - MeshMap meshes_converted; - - // fixed node name -> which trafo chain components have animations? - typedef std::map NodeAnimBitMap; - NodeAnimBitMap node_anim_chain_bits; - - // name -> has had its prefix_stripped? - typedef std::map NodeNameMap; - NodeNameMap node_names; - - typedef std::map NameNameMap; - NameNameMap renamed_nodes; - - double anim_fps; - - aiScene* const out; - const FBX::Document& doc; -}; Converter::Converter( aiScene* out, const Document& doc ) : defaultMaterialIndex() @@ -472,6 +104,7 @@ Converter::Converter( aiScene* out, const Document& doc ) } } + ConvertGlobalSettings(); TransferDataToScene(); // if we didn't read any meshes set the AI_SCENE_FLAGS_INCOMPLETE @@ -3341,8 +2974,20 @@ void Converter::ConvertRotationKeys( aiNodeAnim* na, const std::vectormNumRotationKeys = static_cast( keys.size() ); na->mRotationKeys = new aiQuatKey[ keys.size() ]; - if ( keys.size() > 0 ) - InterpolateKeys( na->mRotationKeys, keys, inputs, aiVector3D( 0.0f, 0.0f, 0.0f ), maxTime, minTime, order ); + if (!keys.empty()) { + InterpolateKeys(na->mRotationKeys, keys, inputs, aiVector3D(0.0f, 0.0f, 0.0f), maxTime, minTime, order); + } +} + +void Converter::ConvertGlobalSettings() { + if (nullptr == out) { + return; + } + + out->mMetaData = aiMetadata::Alloc(1); + unsigned int index(0); + const double unitScalFactor(doc.GlobalSettings().UnitScaleFactor()); + out->mMetaData->Set(index, "UnitScaleFactor", unitScalFactor); } void Converter::TransferDataToScene() diff --git a/code/FBXConverter.h b/code/FBXConverter.h index 8a62d8811..c6c413052 100644 --- a/code/FBXConverter.h +++ b/code/FBXConverter.h @@ -45,7 +45,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef INCLUDED_AI_FBX_CONVERTER_H #define INCLUDED_AI_FBX_CONVERTER_H +#include "FBXParser.h" +#include "FBXMeshGeometry.h" +#include "FBXDocument.h" +#include "FBXUtil.h" +#include "FBXProperties.h" +#include "FBXImporter.h" +#include +#include +#include +#include +#include +#include + struct aiScene; +struct aiNode; +struct aiMaterial; namespace Assimp { namespace FBX { @@ -59,6 +74,373 @@ class Document; */ void ConvertToAssimpScene(aiScene* out, const Document& doc); +/** Dummy class to encapsulate the conversion process */ +class Converter { +public: + /** + * The different parts that make up the final local transformation of a fbx-node + */ + enum TransformationComp { + TransformationComp_Translation = 0, + TransformationComp_RotationOffset, + TransformationComp_RotationPivot, + TransformationComp_PreRotation, + TransformationComp_Rotation, + TransformationComp_PostRotation, + TransformationComp_RotationPivotInverse, + TransformationComp_ScalingOffset, + TransformationComp_ScalingPivot, + TransformationComp_Scaling, + TransformationComp_ScalingPivotInverse, + TransformationComp_GeometricTranslation, + TransformationComp_GeometricRotation, + TransformationComp_GeometricScaling, + + TransformationComp_MAXIMUM + }; + +public: + Converter(aiScene* out, const Document& doc); + ~Converter(); + +private: + // ------------------------------------------------------------------------------------------------ + // find scene root and trigger recursive scene conversion + void ConvertRootNode(); + + // ------------------------------------------------------------------------------------------------ + // collect and assign child nodes + void ConvertNodes(uint64_t id, aiNode& parent, const aiMatrix4x4& parent_transform = aiMatrix4x4()); + + // ------------------------------------------------------------------------------------------------ + void ConvertLights(const Model& model); + + // ------------------------------------------------------------------------------------------------ + void ConvertCameras(const Model& model); + + // ------------------------------------------------------------------------------------------------ + void ConvertLight(const Model& model, const Light& light); + + // ------------------------------------------------------------------------------------------------ + void ConvertCamera(const Model& model, const Camera& cam); + + // ------------------------------------------------------------------------------------------------ + // this returns unified names usable within assimp identifiers (i.e. no space characters - + // while these would be allowed, they are a potential trouble spot so better not use them). + const char* NameTransformationComp(TransformationComp comp); + + // ------------------------------------------------------------------------------------------------ + // note: this returns the REAL fbx property names + const char* NameTransformationCompProperty(TransformationComp comp); + + // ------------------------------------------------------------------------------------------------ + aiVector3D TransformationCompDefaultValue(TransformationComp comp); + + // ------------------------------------------------------------------------------------------------ + void GetRotationMatrix(Model::RotOrder mode, const aiVector3D& rotation, aiMatrix4x4& out); + // ------------------------------------------------------------------------------------------------ + /** + * checks if a node has more than just scaling, rotation and translation components + */ + bool NeedsComplexTransformationChain(const Model& model); + + // ------------------------------------------------------------------------------------------------ + // note: name must be a FixNodeName() result + std::string NameTransformationChainNode(const std::string& name, TransformationComp comp); + + // ------------------------------------------------------------------------------------------------ + /** + * note: memory for output_nodes will be managed by the caller + */ + void GenerateTransformationNodeChain(const Model& model, std::vector& output_nodes); + + // ------------------------------------------------------------------------------------------------ + void SetupNodeMetadata(const Model& model, aiNode& nd); + + // ------------------------------------------------------------------------------------------------ + void ConvertModel(const Model& model, aiNode& nd, const aiMatrix4x4& node_global_transform); + + // ------------------------------------------------------------------------------------------------ + // MeshGeometry -> aiMesh, return mesh index + 1 or 0 if the conversion failed + std::vector ConvertMesh(const MeshGeometry& mesh, const Model& model, + const aiMatrix4x4& node_global_transform); + + // ------------------------------------------------------------------------------------------------ + aiMesh* SetupEmptyMesh(const MeshGeometry& mesh); + + // ------------------------------------------------------------------------------------------------ + unsigned int ConvertMeshSingleMaterial(const MeshGeometry& mesh, const Model& model, + const aiMatrix4x4& node_global_transform); + + // ------------------------------------------------------------------------------------------------ + std::vector ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model, + const aiMatrix4x4& node_global_transform); + + // ------------------------------------------------------------------------------------------------ + unsigned int ConvertMeshMultiMaterial(const MeshGeometry& mesh, const Model& model, + MatIndexArray::value_type index, + const aiMatrix4x4& node_global_transform); + + // ------------------------------------------------------------------------------------------------ + static const unsigned int NO_MATERIAL_SEPARATION = /* std::numeric_limits::max() */ + static_cast(-1); + + // ------------------------------------------------------------------------------------------------ + /** + * - if materialIndex == NO_MATERIAL_SEPARATION, materials are not taken into + * account when determining which weights to include. + * - outputVertStartIndices is only used when a material index is specified, it gives for + * each output vertex the DOM index it maps to. + */ + void ConvertWeights(aiMesh* out, const Model& model, const MeshGeometry& geo, + const aiMatrix4x4& node_global_transform = aiMatrix4x4(), + unsigned int materialIndex = NO_MATERIAL_SEPARATION, + std::vector* outputVertStartIndices = NULL); + + // ------------------------------------------------------------------------------------------------ + void ConvertCluster(std::vector& bones, const Model& /*model*/, const Cluster& cl, + std::vector& out_indices, + std::vector& index_out_indices, + std::vector& count_out_indices, + const aiMatrix4x4& node_global_transform); + + // ------------------------------------------------------------------------------------------------ + void ConvertMaterialForMesh(aiMesh* out, const Model& model, const MeshGeometry& geo, + MatIndexArray::value_type materialIndex); + + // ------------------------------------------------------------------------------------------------ + unsigned int GetDefaultMaterial(); + + // ------------------------------------------------------------------------------------------------ + // Material -> aiMaterial + unsigned int ConvertMaterial(const Material& material, const MeshGeometry* const mesh); + + // ------------------------------------------------------------------------------------------------ + // Video -> aiTexture + unsigned int ConvertVideo(const Video& video); + + // ------------------------------------------------------------------------------------------------ + void TrySetTextureProperties(aiMaterial* out_mat, const TextureMap& textures, + const std::string& propName, + aiTextureType target, const MeshGeometry* const mesh); + + // ------------------------------------------------------------------------------------------------ + void TrySetTextureProperties(aiMaterial* out_mat, const LayeredTextureMap& layeredTextures, + const std::string& propName, + aiTextureType target, const MeshGeometry* const mesh); + + // ------------------------------------------------------------------------------------------------ + void SetTextureProperties(aiMaterial* out_mat, const TextureMap& textures, const MeshGeometry* const mesh); + + // ------------------------------------------------------------------------------------------------ + void SetTextureProperties(aiMaterial* out_mat, const LayeredTextureMap& layeredTextures, const MeshGeometry* const mesh); + + // ------------------------------------------------------------------------------------------------ + aiColor3D GetColorPropertyFromMaterial(const PropertyTable& props, const std::string& baseName, + bool& result); + aiColor3D GetColorPropertyFactored(const PropertyTable& props, const std::string& colorName, + const std::string& factorName, bool& result, bool useTemplate = true); + aiColor3D GetColorProperty(const PropertyTable& props, const std::string& colorName, + bool& result, bool useTemplate = true); + + // ------------------------------------------------------------------------------------------------ + void SetShadingPropertiesCommon(aiMaterial* out_mat, const PropertyTable& props); + + // ------------------------------------------------------------------------------------------------ + // get the number of fps for a FrameRate enumerated value + static double FrameRateToDouble(FileGlobalSettings::FrameRate fp, double customFPSVal = -1.0); + + // ------------------------------------------------------------------------------------------------ + // convert animation data to aiAnimation et al + void ConvertAnimations(); + + // ------------------------------------------------------------------------------------------------ + // rename a node already partially converted. fixed_name is a string previously returned by + // FixNodeName, new_name specifies the string FixNodeName should return on all further invocations + // which would previously have returned the old value. + // + // this also updates names in node animations, cameras and light sources and is thus slow. + // + // NOTE: the caller is responsible for ensuring that the new name is unique and does + // not collide with any other identifiers. The best way to ensure this is to only + // append to the old name, which is guaranteed to match these requirements. + void RenameNode(const std::string& fixed_name, const std::string& new_name); + + // ------------------------------------------------------------------------------------------------ + // takes a fbx node name and returns the identifier to be used in the assimp output scene. + // the function is guaranteed to provide consistent results over multiple invocations + // UNLESS RenameNode() is called for a particular node name. + std::string FixNodeName(const std::string& name); + + typedef std::map LayerMap; + + // XXX: better use multi_map .. + typedef std::map > NodeMap; + + + // ------------------------------------------------------------------------------------------------ + void ConvertAnimationStack(const AnimationStack& st); + + // ------------------------------------------------------------------------------------------------ + void GenerateNodeAnimations(std::vector& node_anims, + const std::string& fixed_name, + const std::vector& curves, + const LayerMap& layer_map, + int64_t start, int64_t stop, + double& max_time, + double& min_time); + + // ------------------------------------------------------------------------------------------------ + bool IsRedundantAnimationData(const Model& target, + TransformationComp comp, + const std::vector& curves); + + // ------------------------------------------------------------------------------------------------ + aiNodeAnim* GenerateRotationNodeAnim(const std::string& name, + const Model& target, + const std::vector& curves, + const LayerMap& layer_map, + int64_t start, int64_t stop, + double& max_time, + double& min_time); + + // ------------------------------------------------------------------------------------------------ + aiNodeAnim* GenerateScalingNodeAnim(const std::string& name, + const Model& /*target*/, + const std::vector& curves, + const LayerMap& layer_map, + int64_t start, int64_t stop, + double& max_time, + double& min_time); + + // ------------------------------------------------------------------------------------------------ + aiNodeAnim* GenerateTranslationNodeAnim(const std::string& name, + const Model& /*target*/, + const std::vector& curves, + const LayerMap& layer_map, + int64_t start, int64_t stop, + double& max_time, + double& min_time, + bool inverse = false); + + // ------------------------------------------------------------------------------------------------ + // generate node anim, extracting only Rotation, Scaling and Translation from the given chain + aiNodeAnim* GenerateSimpleNodeAnim(const std::string& name, + const Model& target, + NodeMap::const_iterator chain[TransformationComp_MAXIMUM], + NodeMap::const_iterator iter_end, + const LayerMap& layer_map, + int64_t start, int64_t stop, + double& max_time, + double& min_time, + bool reverse_order = false); + + // key (time), value, mapto (component index) + typedef std::tuple, std::shared_ptr, unsigned int > KeyFrameList; + typedef std::vector KeyFrameListList; + + // ------------------------------------------------------------------------------------------------ + KeyFrameListList GetKeyframeList(const std::vector& nodes, int64_t start, int64_t stop); + + // ------------------------------------------------------------------------------------------------ + KeyTimeList GetKeyTimeList(const KeyFrameListList& inputs); + + // ------------------------------------------------------------------------------------------------ + void InterpolateKeys(aiVectorKey* valOut, const KeyTimeList& keys, const KeyFrameListList& inputs, + const aiVector3D& def_value, + double& max_time, + double& min_time); + + // ------------------------------------------------------------------------------------------------ + void InterpolateKeys(aiQuatKey* valOut, const KeyTimeList& keys, const KeyFrameListList& inputs, + const aiVector3D& def_value, + double& maxTime, + double& minTime, + Model::RotOrder order); + + // ------------------------------------------------------------------------------------------------ + void ConvertTransformOrder_TRStoSRT(aiQuatKey* out_quat, aiVectorKey* out_scale, + aiVectorKey* out_translation, + const KeyFrameListList& scaling, + const KeyFrameListList& translation, + const KeyFrameListList& rotation, + const KeyTimeList& times, + double& maxTime, + double& minTime, + Model::RotOrder order, + const aiVector3D& def_scale, + const aiVector3D& def_translate, + const aiVector3D& def_rotation); + + // ------------------------------------------------------------------------------------------------ + // euler xyz -> quat + aiQuaternion EulerToQuaternion(const aiVector3D& rot, Model::RotOrder order); + + // ------------------------------------------------------------------------------------------------ + void ConvertScaleKeys(aiNodeAnim* na, const std::vector& nodes, const LayerMap& /*layers*/, + int64_t start, int64_t stop, + double& maxTime, + double& minTime); + + // ------------------------------------------------------------------------------------------------ + void ConvertTranslationKeys(aiNodeAnim* na, const std::vector& nodes, + const LayerMap& /*layers*/, + int64_t start, int64_t stop, + double& maxTime, + double& minTime); + + // ------------------------------------------------------------------------------------------------ + void ConvertRotationKeys(aiNodeAnim* na, const std::vector& nodes, + const LayerMap& /*layers*/, + int64_t start, int64_t stop, + double& maxTime, + double& minTime, + Model::RotOrder order); + + void ConvertGlobalSettings(); + + // ------------------------------------------------------------------------------------------------ + // copy generated meshes, animations, lights, cameras and textures to the output scene + void TransferDataToScene(); + +private: + + // 0: not assigned yet, others: index is value - 1 + unsigned int defaultMaterialIndex; + + std::vector meshes; + std::vector materials; + std::vector animations; + std::vector lights; + std::vector cameras; + std::vector textures; + + typedef std::map MaterialMap; + MaterialMap materials_converted; + + typedef std::map VideoMap; + VideoMap textures_converted; + + typedef std::map > MeshMap; + MeshMap meshes_converted; + + // fixed node name -> which trafo chain components have animations? + typedef std::map NodeAnimBitMap; + NodeAnimBitMap node_anim_chain_bits; + + // name -> has had its prefix_stripped? + typedef std::map NodeNameMap; + NodeNameMap node_names; + + typedef std::map NameNameMap; + NameNameMap renamed_nodes; + + double anim_fps; + + aiScene* const out; + const FBX::Document& doc; +}; + } } diff --git a/code/FBXDocument.cpp b/code/FBXDocument.cpp index 54f18b191..20c875ca1 100644 --- a/code/FBXDocument.cpp +++ b/code/FBXDocument.cpp @@ -344,9 +344,8 @@ void Document::ReadGlobalSettings() { const Scope& sc = parser.GetRootScope(); const Element* const ehead = sc["GlobalSettings"]; - if(!ehead || !ehead->Compound()) { - DOMWarning("no GlobalSettings dictionary found"); - + if ( nullptr == ehead || !ehead->Compound() ) { + DOMWarning( "no GlobalSettings dictionary found" ); globals.reset(new FileGlobalSettings(*this, std::make_shared())); return; } diff --git a/code/FBXDocument.h b/code/FBXDocument.h index a4e28b2aa..2b8157249 100644 --- a/code/FBXDocument.h +++ b/code/FBXDocument.h @@ -999,8 +999,7 @@ typedef std::multimap ConnectionMap; /** DOM class for global document settings, a single instance per document can * be accessed via Document.Globals(). */ -class FileGlobalSettings -{ +class FileGlobalSettings { public: FileGlobalSettings(const Document& doc, std::shared_ptr props); ~FileGlobalSettings(); diff --git a/code/FBXImporter.cpp b/code/FBXImporter.cpp index 566bc992f..f2231b805 100644 --- a/code/FBXImporter.cpp +++ b/code/FBXImporter.cpp @@ -140,8 +140,7 @@ void FBXImporter::SetupProperties(const Importer* pImp) // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void FBXImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) +void FBXImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { std::unique_ptr stream(pIOHandler->Open(pFile,"rb")); if (!stream) { diff --git a/code/FBXParser.h b/code/FBXParser.h index c7cf5a458..996c86fcf 100644 --- a/code/FBXParser.h +++ b/code/FBXParser.h @@ -174,11 +174,9 @@ private: friend class Element; TokenPtr AdvanceToNextToken(); - TokenPtr LastToken() const; TokenPtr CurrentToken() const; - private: const TokenList& tokens; @@ -199,7 +197,6 @@ int ParseTokenAsInt(const Token& t, const char*& err_out); int64_t ParseTokenAsInt64(const Token& t, const char*& err_out); std::string ParseTokenAsString(const Token& t, const char*& err_out); - /* wrapper around ParseTokenAsXXX() with DOMError handling */ uint64_t ParseTokenAsID(const Token& t); size_t ParseTokenAsDim(const Token& t); diff --git a/test/models/OBJ/spider_nomtl_test.obj b/test/models/OBJ/spider_nomtl_test.obj index 44e8ea591..8129fff29 100644 --- a/test/models/OBJ/spider_nomtl_test.obj +++ b/test/models/OBJ/spider_nomtl_test.obj @@ -1,5 +1,5 @@ # File produced by Open Asset Import Library (http://www.assimp.sf.net) -# (assimp v4.1.1712791017) +# (assimp v4.1.3023643559) # 722 vertex positions v 1.160378932952881 4.512683868408203 6.449167251586914 @@ -12,7 +12,7 @@ v -6.442715167999268 10.77740478515625 -0.5375289916992188 v -8.120363235473633 15.6844596862793 -10.5 v -0.8867700099945068 23.4237174987793 -4.342854022979736 v -0.8867700099945068 23.4237174987793 -16.65714454650879 -v 14.40229797363281 32.89186859130859 -26.41482543945312 +v 14.40229797363281 32.89186859130859 -26.41482543945313 v 12.95316505432129 36.87333679199219 -11.5 v 30.52731704711914 37.50395202636719 -2.733282089233398 v 30.52731704711914 37.50395202636719 -20.26671600341797 @@ -21,15 +21,15 @@ v 45.09496688842773 27.71094512939453 2.684845924377441 v 57.93621826171875 30.27653312683105 -11.5 v 54.50359344482422 5.934020042419434 -11.5 v 51.09176254272461 11.23489952087402 2.684845924377441 -v 45.09496688842773 27.71094512939453 -25.68484497070312 +v 45.09496688842773 27.71094512939453 -25.68484497070313 v 39.18625640869141 16.23099708557129 -35.63270568847656 -v 51.09176254272461 11.23489952087402 -25.68484497070312 +v 51.09176254272461 11.23489952087402 -25.68484497070313 v 27.52080917358398 27.08032608032227 -34.45156478881836 v 4.568314075469971 16.85711288452148 -26.6196174621582 v 1.160378932952881 4.512683868408203 -27.44916915893555 v 22.65617179870605 10.21453857421875 -39.86968994140625 v 7.838881015777588 -6.414187908172607 -26.6196174621582 -v 30.91004180908203 -12.4627857208252 -26.41482543945312 +v 30.91004180908203 -12.4627857208252 -26.41482543945313 v 37.22381591796875 0.4215309917926788 -34.45156478881836 v 46.22711181640625 -5.630886077880859 -20.26671600341797 v 32.35918426513672 -16.44425201416016 -11.5 @@ -70,11 +70,11 @@ v -18.8264045715332 5.435883045196533 -20.58309173583984 v -32.62586212158203 10.86018753051758 -28.47975921630859 v -41.85661315917969 -0.7548459768295288 -29.43077087402344 v -27.9502124786377 1.303017020225525 -23.0814208984375 -v -39.19473266601562 -9.356718063354492 -28.47975921630859 +v -39.19473266601563 -9.356718063354492 -28.47975921630859 v -31.49889755249023 -9.618716239929199 -16.87730979919434 v -22.99813652038574 -7.403382778167725 -20.58309173583984 v -49.71383666992188 -2.983590126037598 1.421121001243591 -v -39.19473266601562 -9.356718063354492 8.47976016998291 +v -39.19473266601563 -9.356718063354492 8.47976016998291 v -22.99813652038574 -7.403382778167725 0.5830910205841064 v -31.49889755249023 -9.618716239929199 -3.122689962387085 v -50.63702392578125 8.975393295288086 -10 @@ -93,15 +93,15 @@ v -55.4437255859375 28.01696014404297 -51.02064895629883 v -55.80507659912109 29.50034332275391 -50.36057662963867 v -56.41304779052734 27.51875305175781 -54.60213470458984 v -57.93299102783203 29.20790100097656 -55.03944778442383 -v -67.98501586914062 13.43557167053223 -79.02035522460938 +v -67.98501586914063 13.43557167053223 -79.02035522460938 v -69.89360046386719 14.10584259033203 -80.14413452148438 -v -81.67832183837891 -31.37918090820312 -101.2915573120117 +v -81.67832183837891 -31.37918090820313 -101.2915573120117 v -82.77850341796875 -29.84352111816406 -101.2665863037109 v -45.27461242675781 -1.921316027641296 -17.56256103515625 v -88.2349853515625 -39.3502311706543 -103.8660430908203 v -48.86238861083984 8.964324951171875 -36.15071487426758 v -56.92498016357422 29.82746124267578 -49.55580902099609 -v -60.01216888427734 29.56021118164062 -54.08668899536133 +v -60.01216888427734 29.56021118164063 -54.08668899536133 v -72.06874084472656 14.20652008056641 -79.36090087890625 v -83.47474670410156 -29.51860809326172 -100.4707794189453 v -48.11187744140625 -2.742969989776611 -19.29600143432617 @@ -110,12 +110,12 @@ v -50.95351028442383 7.973351955413818 -36.14510726928711 v -57.96013641357422 28.75201416015625 -49.21238708496094 v -61.08487701416016 28.31040191650391 -52.46125793457031 v -72.87251281738281 13.66179847717285 -77.26039123535156 -v -83.24275207519531 -30.64902877807617 -99.50344848632812 +v -83.24275207519531 -30.64902877807617 -99.50344848632813 v -48.33858871459961 -4.09240198135376 -22.38015365600586 v -87.97438049316406 -40.34838485717773 -103.3615341186523 v -51.84541320800781 6.477696895599365 -37.66901397705078 v -58.13103866577148 27.08382415771484 -49.58887100219727 -v -60.34334564208984 26.39956665039062 -51.38712310791016 +v -60.34334564208984 26.39956665039063 -51.38712310791016 v -71.69966125488281 12.8818302154541 -75.42439270019531 v -82.25722503662109 -32.38360595703125 -99.09293365478516 v -45.78402709960938 -4.953472137451172 -24.49265670776367 @@ -125,7 +125,7 @@ v -57.30899810791016 26.07907104492188 -50.40177917480469 v -58.34596252441406 25.26664733886719 -51.67315673828125 v -69.433349609375 12.45395088195801 -75.23539733886719 v -81.26026153564453 -33.41617965698242 -99.54843139648438 -v -42.37185668945312 -4.677759170532227 -24.04270935058594 +v -42.37185668945313 -4.677759170532227 -24.04270935058594 v -87.46121978759766 -40.53748321533203 -104.0717544555664 v -48.75384521484375 6.009276866912842 -40.42763137817383 v -56.11302947998047 26.49437713623047 -51.03896713256836 @@ -137,27 +137,27 @@ v -42.83802795410156 -1.822747945785522 -1.17337703704834 v -41.96012115478516 -3.15467095375061 1.817621946334839 v -92.29042816162109 -39.21158981323242 57.38248825073242 v -92.26210784912109 -39.83740234375 57.07994079589844 -v -91.95950317382812 -39.73274230957031 57.5407600402832 +v -91.95950317382813 -39.73274230957031 57.5407600402832 v -49.36812591552734 8.476757049560547 19.08589744567871 -v -49.19630432128906 7.804555892944336 21.29348754882812 +v -49.19630432128906 7.804555892944336 21.29348754882813 v -54.25469207763672 27.27288055419922 30.44888496398926 v -54.92575836181641 28.34239959716797 29.36605453491211 v -57.45500946044922 28.70623016357422 33.83551406860352 v -55.48647308349609 27.49809265136719 33.97690582275391 v -67.46834564208984 9.109057426452637 43.49641799926758 -v -69.61196136474609 9.454971313476562 44.29645156860352 +v -69.61196136474609 9.454971313476563 44.29645156860352 v -87.01417541503906 -30.51413726806641 52.42203521728516 v -85.97149658203125 -32.07468414306641 52.63847351074219 -v -45.98867797851562 -1.450130939483643 -2.535742998123169 -v -92.60006713867188 -39.16170501708984 56.99636840820312 +v -45.98867797851563 -1.450130939483643 -2.535742998123169 +v -92.60006713867188 -39.16170501708984 56.99636840820313 v -50.88497161865234 7.785149097442627 17.48099899291992 v -55.98342132568359 28.08773803710938 28.45757293701172 v -59.41564178466797 28.14698791503906 32.74097061157227 v -71.61580657958984 8.682785987854004 43.43437957763672 v -87.75607299804688 -30.29622077941895 51.63100051879883 -v -49.03958129882812 -2.317409992218018 -1.243530988693237 +v -49.03958129882813 -2.317409992218018 -1.243530988693237 v -92.65523529052734 -39.6205940246582 56.67316055297852 -v -52.60464477539062 6.250553131103516 17.68733215332031 +v -52.60464477539063 6.250553131103516 17.68733215332031 v -56.63124847412109 26.70069122314453 28.40756416320801 v -59.89194488525391 26.24149322509766 31.51743125915527 v -71.97093963623047 7.37397575378418 41.55935287475586 @@ -182,11 +182,11 @@ v -50.4989013671875 6.274747848510742 22.44142532348633 v -54.47554779052734 25.68461608886719 30.89064788818359 v -54.99231719970703 25.43232727050781 33.05861282348633 v -66.79914093017578 7.905498027801514 41.6367301940918 -v -85.4132080078125 -33.80271530151367 52.11734008789062 +v -85.4132080078125 -33.80271530151367 52.11734008789063 v -32.53578186035156 -3.15467095375061 -19.16253662109375 v -34.38373184204102 -1.822747945785522 -16.65216445922852 v -36.48015213012695 -3.096683979034424 -19.71685028076172 -v -43.38578033447266 -41.58316040039062 -95.21874237060547 +v -43.38578033447266 -41.58316040039063 -95.21874237060547 v -43.91326141357422 -41.58873748779297 -95.02735137939453 v -43.69423675537109 -41.06890106201172 -95.43450164794922 v -35.0989875793457 7.804555892944336 -38.97930526733398 @@ -199,7 +199,7 @@ v -39.32158660888672 4.109056949615479 -79.20964813232422 v -40.77798843383789 4.454970836639404 -80.97431182861328 v -40.8770866394043 -32.42660522460938 -89.88973236083984 v -41.6864128112793 -30.95858383178711 -90.76108551025391 -v -37.81033325195312 -1.450130939483643 -16.44955062866211 +v -37.81033325195313 -1.450130939483643 -16.44955062866211 v -44.16765594482422 -40.94609069824219 -95.34366607666016 v -38.46767044067383 7.785149097442627 -36.52191925048828 v -40.04683303833008 28.08773803710938 -50.77265167236328 @@ -209,7 +209,7 @@ v -42.73056793212891 -30.60493469238281 -90.66996002197266 v -40.23527908325195 -2.317409992218018 -18.70730972290039 v -44.44951629638672 -41.30718231201172 -95.01465606689453 v -39.85378265380859 6.250553131103516 -37.56044387817383 -v -40.63287734985352 26.70069122314453 -51.05325317382812 +v -40.63287734985352 26.70069122314453 -51.05325317382813 v -41.90177536010742 26.24149322509766 -55.37683486938477 v -44.18946838378906 2.373975992202759 -79.78339385986328 v -43.2232666015625 -31.63191223144531 -89.68506622314453 @@ -229,7 +229,7 @@ v -41.56508255004883 1.750601053237915 -76.60358428955078 v -41.76493453979492 -34.27718353271484 -88.11498260498047 v -33.65802383422852 -4.442947864532471 -22.09029006958008 v -43.47456359863281 -42.10161590576172 -94.85892486572266 -v -35.65310668945312 6.274747848510742 -40.62473678588867 +v -35.65310668945313 6.274747848510742 -40.62473678588867 v -37.52444076538086 25.68461608886719 -52.12581634521484 v -36.88800048828125 25.43232727050781 -54.26172637939453 v -39.6718864440918 2.905498027801514 -77.26450347900391 @@ -249,7 +249,7 @@ v -38.03726577758789 27.49446105957031 33.66647720336914 v -34.5403938293457 17.31492233276367 46.75900650024414 v -35.8452262878418 17.43609428405762 48.66624069213867 v -28.96659469604492 -31.87043952941895 66.61157989501953 -v -28.00870513916016 -33.48403930664062 66.39229583740234 +v -28.00870513916016 -33.48403930664063 66.39229583740234 v -37.94406127929688 -1.883904933929443 -4.875525951385498 v -29.19070816040039 -38.59844589233398 75.64435577392578 v -38.12530136108398 7.461886882781982 15.15559387207031 @@ -283,8 +283,8 @@ v -28.36112785339355 -39.7656364440918 75.63690948486328 v -34.68405532836914 6.534968852996826 18.94173622131348 v -38.70342254638672 25.53554534912109 30.5754222869873 v -37.81640243530273 25.43576812744141 32.63310623168945 -v -34.87471389770508 16.03384399414062 44.86114120483398 -v -27.90771293640137 -35.34060668945312 66.05712127685547 +v -34.87471389770508 16.03384399414063 44.86114120483398 +v -27.90771293640137 -35.34060668945313 66.05712127685547 v -26.45577621459961 -3.443838119506836 -2.149142980575562 v -26.46640014648438 -2.246160984039307 -5.887526988983154 v -23.49448394775391 -3.47288703918457 -4.813465118408203 @@ -300,26 +300,26 @@ v -10.52369499206543 27.51875305175781 29.59563827514648 v -0.9972569942474365 13.43557167053223 54.88214111328125 v -1.514698028564453 14.10584259033203 57.03571319580078 v 3.385565996170044 -29.84352111816406 80.76795196533203 -v 3.675970077514648 -31.37918090820312 79.70648956298828 +v 3.675970077514648 -31.37918090820313 79.70648956298828 v -29.43033599853516 -1.921316027641296 -4.146553039550781 v 4.587766170501709 -39.3502311706543 86.69120025634766 v -18.55141067504883 8.964324951171875 11.34670639038086 v -14.50934600830078 29.82746124267578 26.45841026306152 -v -13.3946418762207 29.56021118164062 31.82656478881836 +v -13.3946418762207 29.56021118164063 31.82656478881836 v -3.589093923568726 14.20652008056641 58.0562744140625 v 2.445001125335693 -29.51860809326172 81.25101470947266 -v -30.15432739257812 -2.742969989776611 -0.9014430046081543 +v -30.15432739257813 -2.742969989776611 -0.9014430046081543 v 4.197091102600098 -39.74774169921875 86.60486602783203 v -20.00806045532227 7.973351955413818 12.8470344543457 v -15.4754638671875 28.75201416015625 26.9644775390625 v -15.30904579162598 28.31040191650391 31.46907806396484 -v -5.658416748046875 13.66179847717285 57.17532348632812 +v -5.658416748046875 13.66179847717285 57.17532348632813 v 1.562493085861206 -30.64902877807617 80.79186248779297 v -28.0932731628418 -4.09240198135376 1.404078960418701 v 4.161306858062744 -40.34838485717773 86.31630706787109 v -19.53142166137695 6.477696895599365 14.54720878601074 v -15.32335662841797 27.08382415771484 27.34894752502441 -v -15.56659698486328 26.39956665039062 30.18951416015625 +v -15.56659698486328 26.39956665039063 30.18951416015625 v -6.164387226104736 12.8818302154541 55.05625915527344 v 1.402615070343018 -32.38360595703125 79.73628997802734 v -24.79911041259766 -4.953472137451172 1.033954977989197 @@ -338,7 +338,7 @@ v -2.426440954208374 12.70041084289551 53.21726226806641 v 3.097472906112671 -32.96916198730469 78.86588287353516 v -23.49448394775391 -3.47288703918457 -15.18653869628906 v -26.46640014648438 -2.246160984039307 -14.11247634887695 -v -26.45577621459961 -3.443838119506836 -17.85086059570312 +v -26.45577621459961 -3.443838119506836 -17.85086059570313 v 5.211228847503662 -39.9835319519043 -106.1982498168945 v 4.668338775634766 -40.01747512817383 -106.3362197875977 v 5.039107799530029 -39.45514678955078 -106.5102310180664 @@ -350,27 +350,27 @@ v -10.52369499206543 27.51875305175781 -49.59563446044922 v -11.26496505737305 29.20790100097656 -50.99276733398438 v -0.9972569942474365 13.43557167053223 -74.88213348388672 v -1.514698028564453 14.10584259033203 -77.03571319580078 -v 3.675970077514648 -31.37918090820312 -99.70648956298828 +v 3.675970077514648 -31.37918090820313 -99.70648956298828 v 3.38556694984436 -29.84352111816406 -100.767951965332 v -29.43033599853516 -1.921316027641296 -15.85345077514648 v 4.587764739990234 -39.3502311706543 -106.6912002563477 -v -18.55141067504883 8.964324951171875 -31.34671020507812 +v -18.55141067504883 8.964324951171875 -31.34671020507813 v -14.50934600830078 29.82746124267578 -46.45841217041016 -v -13.3946418762207 29.56021118164062 -51.82656097412109 +v -13.3946418762207 29.56021118164063 -51.82656097412109 v -3.589093923568726 14.20652008056641 -78.05626678466797 v 2.445001125335693 -29.51860809326172 -101.2510147094727 -v -30.15432739257812 -2.742969989776611 -19.09856033325195 +v -30.15432739257813 -2.742969989776611 -19.09856033325195 v 4.197090148925781 -39.74774169921875 -106.604866027832 v -20.00806045532227 7.973351955413818 -32.8470344543457 v -15.4754638671875 28.75201416015625 -46.9644775390625 v -15.30904579162598 28.31040191650391 -51.46907806396484 v -5.658416748046875 13.66179847717285 -77.17531585693359 v 1.562493085861206 -30.64902877807617 -100.791862487793 -v -28.0932731628418 -4.09240198135376 -21.40408325195312 +v -28.0932731628418 -4.09240198135376 -21.40408325195313 v 4.161307811737061 -40.34838485717773 -106.3163070678711 v -19.53142166137695 6.477696895599365 -34.54721069335938 v -15.32335662841797 27.08382415771484 -47.34894561767578 -v -15.56659698486328 26.39956665039062 -50.18951416015625 +v -15.56659698486328 26.39956665039063 -50.18951416015625 v -6.164387226104736 12.8818302154541 -75.05625152587891 v 1.402615070343018 -32.38360595703125 -99.73628997802734 v -24.79911041259766 -4.953472137451172 -21.03395843505859 @@ -391,14 +391,14 @@ v -14.25648880004883 -6.954940795898438 -3.301691055297852 v -14.10265731811523 -6.075778961181641 -7.124460220336914 v -11.2052116394043 -7.280231952667236 -5.841878890991211 v 19.74986457824707 -37.60753631591797 68.32992553710938 -v 19.34836387634277 -38.14849472045898 68.15628051757812 +v 19.34836387634277 -38.14849472045898 68.15628051757813 v 19.89711761474609 -38.15519714355469 68.03912353515625 v -4.907510757446289 6.093640804290771 10.12681770324707 v -2.877649068832397 5.517601013183594 11.07694053649902 v 1.745674014091492 26.13694000244141 21.00781440734863 v 0.4745520055294037 27.20939636230469 20.97971534729004 v 3.233434915542603 28.02400207519531 25.24942970275879 -v 4.282450199127197 26.64773559570312 23.71314430236816 +v 4.282450199127197 26.64773559570313 23.71314430236816 v 14.8602180480957 5.642467975616455 47.61897277832031 v 14.56025314331055 6.223588943481445 49.83868408203125 v 18.9760627746582 -28.07810020446777 62.27335357666016 @@ -432,28 +432,28 @@ v 1.932853937149048 23.20393180847168 23.79626274108887 v 11.57662582397461 3.190187931060791 46.84990692138672 v 17.50724792480469 -31.60873603820801 60.42989349365234 v -10.6054573059082 -8.239757537841797 -2.646497964859009 -v 19.63114547729492 -38.69778442382812 67.83663940429688 +v 19.63114547729492 -38.69778442382813 67.83663940429688 v -2.475620031356812 4.172726154327393 12.91663932800293 v 2.032040119171143 24.59943771362305 21.57402229309082 v 3.703634023666382 24.50261497497559 23.06640815734863 -v 13.53237915039062 4.292479038238525 46.28885650634766 +v 13.53237915039063 4.292479038238525 46.28885650634766 v 18.54694938659668 -31.23143768310547 60.44495391845703 v -12.53854370117188 -7.280231952667236 -13.491455078125 v -15.43598937988281 -6.075778961181641 -12.2088737487793 v -15.58982086181641 -6.954940795898438 -16.03164291381836 -v 18.56378555297852 -38.15519714355469 -87.37246704101562 +v 18.56378555297852 -38.15519714355469 -87.37246704101563 v 18.0150318145752 -38.14849472045898 -87.4896240234375 v 18.41653251647949 -37.60753631591797 -87.66326904296875 v -4.210980892181396 5.517601013183594 -30.41027450561523 v -6.240842819213867 6.093640804290771 -29.46015167236328 v 0.4123420119285583 26.13694000244141 -40.34114837646484 v -0.8587800264358521 27.20939636230469 -40.31304931640625 -v 2.949118137359619 26.64773559570312 -43.04647827148438 +v 2.949118137359619 26.64773559570313 -43.04647827148438 v 1.900102972984314 28.02400207519531 -44.582763671875 -v 13.52688598632812 5.642467975616455 -66.95231628417969 -v 13.22692108154297 6.223588943481445 -69.17202758789062 +v 13.52688598632813 5.642467975616455 -66.95231628417969 +v 13.22692108154297 6.223588943481445 -69.17202758789063 v 17.86732864379883 -29.66015243530273 -80.59872436523438 -v 17.64273071289062 -28.07810020446777 -81.60670471191406 +v 17.64273071289063 -28.07810020446777 -81.60670471191406 v -18.44928359985352 -5.533359050750732 -13.80491638183594 v 17.96691513061523 -37.46723175048828 -87.82330322265625 v -8.370006561279297 5.467060089111328 -30.11508178710938 @@ -469,7 +469,7 @@ v -1.290704965591431 25.68392181396484 -45.89799499511719 v 9.702729225158691 4.237391948699951 -70.18302917480469 v 15.76919937133789 -28.75799560546875 -81.57952880859375 v -17.36852645874023 -7.262344837188721 -19.56281280517578 -v 17.48766136169434 -38.44494247436523 -87.45840454101562 +v 17.48766136169434 -38.44494247436523 -87.45840454101563 v -7.645581245422363 3.043694019317627 -33.43013000488281 v -1.641402959823608 24.23861885070801 -41.86458587646484 v -1.029770016670227 23.72967147827148 -44.68647766113281 @@ -483,7 +483,7 @@ v 0.5995219945907593 23.20393180847168 -43.12960052490234 v 10.24329376220703 3.190187931060791 -66.18324279785156 v 16.17391586303711 -31.60873603820801 -79.76324462890625 v -11.93878936767578 -8.239757537841797 -16.68683624267578 -v 18.29781341552734 -38.69778442382812 -87.16998291015625 +v 18.29781341552734 -38.69778442382813 -87.16998291015625 v -3.808951854705811 4.172726154327393 -32.24997329711914 v 0.6987079977989197 24.59943771362305 -40.90735626220703 v 2.370301961898804 24.50261497497559 -42.39974212646484 @@ -517,7 +517,7 @@ v -51.75783920288086 11.98240089416504 0.8355600237846375 v -56.05172729492188 7.156466007232666 5.002277851104736 v -53.53396987915039 14.21004676818848 1.72101902961731 v -57.36484146118164 8.803488731384277 5.656900882720947 -v -56.62808227539062 15.23869514465332 0.7346760034561157 +v -56.62808227539063 15.23869514465332 0.7346760034561157 v -59.24757766723633 9.889246940612793 4.827473163604736 v -58.71025466918945 14.29374885559082 -1.380638957023621 v -60.28214263916016 9.596194267272949 3.138458967208862 @@ -554,7 +554,7 @@ v -40.64442825317383 21.88604164123535 -0.7607129812240601 v -44.44827651977539 21.88604164123535 2.546009063720703 v -53.9999885559082 20.33333778381348 0.4478580057621002 v -60.29326629638672 19.47619819641113 -2.199142932891846 -v -63.06387329101562 19.47619819641113 -6.810235023498535 +v -63.06387329101563 19.47619819641113 -6.810235023498535 v -64.39229583740234 20.33333778381348 -9.944446563720703 v -63.32090759277344 15.14286994934082 -6.139256000518799 v -62.36603164672852 15.39914894104004 -5.604844093322754 @@ -616,7 +616,7 @@ v -38.80768203735352 21.88604164123535 -9.988886833190918 v -44.44827651977539 21.88604164123535 -22.47934150695801 v -53.9999885559082 20.33333778381348 -20.38118934631348 v -60.29326629638672 19.47619819641113 -17.73418998718262 -v -63.06387329101562 19.47619819641113 -13.12309837341309 +v -63.06387329101563 19.47619819641113 -13.12309837341309 v -64.39229583740234 20.33333778381348 -9.988886833190918 v -62.33220672607422 15.06181526184082 -14.44650936126709 v -62.36603164672852 15.39914894104004 -14.32849025726318 @@ -648,7 +648,7 @@ v -64.66415405273438 4.277801990509033 -18.2394905090332 v -63.78934860229492 3.570785999298096 -16.48468399047852 v -62.37599182128906 11.21470260620117 -16.82923698425293 v -66.95527648925781 4.531181812286377 -18.78395462036133 -v -63.80926132202148 13.24985885620117 -14.86489868164062 +v -63.80926132202148 13.24985885620117 -14.86489868164063 v -68.93736267089844 4.140174865722656 -17.70805549621582 v -64.48637390136719 12.67211532592773 -12.25428771972656 v -69.1180419921875 3.399224042892456 -15.82198143005371 @@ -668,7 +668,7 @@ v -51.75783920288086 12.03694534301758 -19.50222587585449 v -56.05172729492188 7.211010932922363 -23.66894340515137 v -53.53396987915039 14.26459121704102 -20.38768196105957 v -57.36484146118164 8.858034133911133 -24.32356452941895 -v -56.62808227539062 15.29323959350586 -19.40134239196777 +v -56.62808227539063 15.29323959350586 -19.40134239196777 v -59.24757766723633 9.943792343139648 -23.49413871765137 v -58.71025466918945 14.34829330444336 -17.28602600097656 v -60.28214263916016 9.650739669799805 -21.80512428283691 @@ -677,13 +677,13 @@ v -58.74361419677734 17.51846694946289 -2.271703958511353 v -59.46704864501953 18.40674209594727 -2.53897500038147 v -60.63759613037109 18.10347366333008 -2.337920904159546 v -61.55588531494141 18.15423965454102 -3.37207293510437 -v -60.57522583007812 18.69086074829102 -3.431842088699341 +v -60.57522583007813 18.69086074829102 -3.431842088699341 v -61.64485168457031 18.26233291625977 -4.609260082244873 v -61.38417816162109 17.94110488891602 -5.717274188995361 v -61.48154449462891 16.98392105102539 -6.448155879974365 v -62.26735687255859 17.28479385375977 -5.621510982513428 v -62.61495971679688 16.49116897583008 -5.094202995300293 -v -62.20498657226562 16.13167190551758 -6.081917762756348 +v -62.20498657226563 16.13167190551758 -6.081917762756348 v -61.27806091308594 15.97928333282471 -6.500585079193115 v -62.26735687255859 15.54427146911621 -4.988009929656982 v -61.38417816162109 14.97993564605713 -4.639497756958008 @@ -691,7 +691,7 @@ v -61.48154449462891 15.24338626861572 -5.814656257629395 v -60.47430419921875 15.08453464508057 -3.54331111907959 v -61.64485168457031 15.44609451293945 -3.584233999252319 v -61.55588531494141 16.32414627075195 -2.705970048904419 -v -60.57522583007812 15.87463855743408 -2.406815052032471 +v -60.57522583007813 15.87463855743408 -2.406815052032471 v -59.56442260742188 15.70901966094971 -2.636348009109497 v -60.63759613037109 17.02777481079102 -1.946398019790649 v -59.46704864501953 16.66621780395508 -1.905473947525024 @@ -702,13 +702,13 @@ v -59.46704864501953 18.14007568359375 -17.19435882568359 v -58.74361419677734 17.25180053710938 -17.46162986755371 v -59.67054748535156 17.40419006347656 -17.88029861450195 v -60.63759613037109 17.83680725097656 -17.39541244506836 -v -60.57522583007812 18.4241943359375 -16.30149078369141 +v -60.57522583007813 18.4241943359375 -16.30149078369141 v -61.55588531494141 17.8875732421875 -16.36125946044922 v -61.64485168457031 17.99566650390625 -15.12407302856445 v -62.26735687255859 17.01812744140625 -14.1118221282959 v -61.48154449462891 16.71725463867188 -13.28517723083496 v -61.38417816162109 17.6744384765625 -14.01605987548828 -v -62.20498657226562 15.86500549316406 -13.65141487121582 +v -62.20498657226563 15.86500549316406 -13.65141487121582 v -62.61495971679688 16.22450256347656 -14.63912963867188 v -61.27806091308594 15.71261596679688 -13.23274803161621 v -62.26735687255859 15.27760314941406 -14.74532318115234 @@ -716,7 +716,7 @@ v -61.48154449462891 14.97671890258789 -13.91867828369141 v -61.38417816162109 14.7132682800293 -15.09383583068848 v -61.64485168457031 15.17942810058594 -16.14909934997559 v -60.47430419921875 14.81786727905273 -16.19002342224121 -v -60.57522583007812 15.60797119140625 -17.32651901245117 +v -60.57522583007813 15.60797119140625 -17.32651901245117 v -61.55588531494141 16.05747985839844 -17.02736282348633 v -59.56442260742188 15.44235229492188 -17.09698486328125 v -60.63759613037109 16.7611083984375 -17.78693389892578 @@ -1247,7 +1247,7 @@ vn -0.7882999777793884 -0.6091880202293396 -0.08644299954175949 vn -0.6353080272674561 -0.5868319869041443 0.5020080208778381 vn -0.7489200234413147 -0.3426479995250702 0.5671960115432739 vn -0.8290749788284302 -0.1998199969530106 0.5222129821777344 -vn -0.8114089965820312 -0.2435930073261261 0.5312989950180054 +vn -0.8114089965820313 -0.2435930073261261 0.5312989950180054 vn -0.02972600050270557 -0.7129759788513184 -0.7005580067634583 vn -0.1212550029158592 -0.8703849911689758 -0.4772070050239563 vn 0.1511760056018829 -0.9298509955406189 -0.3354449868202209 @@ -1536,7 +1536,7 @@ vn -0.3590719997882843 -0.2934069931507111 -0.8859909772872925 vn -0.5312150120735168 -0.1616500020027161 -0.8316730260848999 vn 0.5217099785804749 -0.3334519863128662 -0.7852569818496704 vn 0.4982230067253113 -0.5182129740715027 -0.6951469779014587 -vn 0.3192520141601562 -0.6669300198554993 -0.6732630133628845 +vn 0.3192520141601563 -0.6669300198554993 -0.6732630133628845 vn 0.4172089993953705 0.6029300093650818 -0.6800090074539185 vn -0.3909519910812378 -0.5063930153846741 -0.7685850262641907 vn -0.785847008228302 -0.2199160009622574 -0.5779989957809448 @@ -1593,7 +1593,7 @@ vn -0.8313949704170227 0.3698750138282776 0.414698988199234 vn -0.7773889899253845 0.439754992723465 0.4497570097446442 vn -0.7120980024337769 0.07437500357627869 0.6981300115585327 vn -0.5221620202064514 -0.5821250081062317 0.6232789754867554 -vn -0.5362930297851562 0.8426250219345093 0.04870999976992607 +vn -0.5362930297851563 0.8426250219345093 0.04870999976992607 vn -0.6278550028800964 0.7403159737586975 0.2402739971876144 vn -0.817995011806488 0.4767960011959076 0.3217920064926147 vn -0.7291709780693054 0.6557949781417847 0.1955550014972687 diff --git a/test/models/PLY/cube_test.ply b/test/models/PLY/cube_test.ply index e70217c42..8de33f3de 100644 --- a/test/models/PLY/cube_test.ply +++ b/test/models/PLY/cube_test.ply @@ -1,6 +1,6 @@ ply format ascii 1.0 -comment Created by Open Asset Import Library - http://assimp.sf.net (v4.1.1712791017) +comment Created by Open Asset Import Library - http://assimp.sf.net (v4.1.3023643559) element vertex 8 property float x property float y diff --git a/test/unit/utFBXImporterExporter.cpp b/test/unit/utFBXImporterExporter.cpp index d2415a8e5..56590f494 100644 --- a/test/unit/utFBXImporterExporter.cpp +++ b/test/unit/utFBXImporterExporter.cpp @@ -97,3 +97,15 @@ TEST_F( utFBXImporterExporter, importPhongMaterial ) { EXPECT_EQ( mat->Get(AI_MATKEY_OPACITY, f), aiReturn_SUCCESS ); EXPECT_EQ( f, 0.5 ); } + +TEST_F(utFBXImporterExporter, importUnitScaleFactor) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/spider.fbx", aiProcess_ValidateDataStructure); + + EXPECT_NE(nullptr, scene); + EXPECT_NE(nullptr, scene->mMetaData); + + double factor(0.0); + scene->mMetaData->Get("UnitScaleFactor", factor); + EXPECT_DOUBLE_EQ(1.0, factor); +}