From 0c00edb40ec2310ff76b350731822a1ea6dc8800 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 12 Sep 2016 12:41:49 +0200 Subject: [PATCH 1/6] Blender: fix some minor findings. --- code/BlenderLoader.cpp | 9 ++++----- code/BlenderModifier.cpp | 5 +---- code/BlenderScene.cpp | 2 +- code/BlenderScene.h | 17 ++++++----------- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/code/BlenderLoader.cpp b/code/BlenderLoader.cpp index daf4f72c2..7bf9fde25 100644 --- a/code/BlenderLoader.cpp +++ b/code/BlenderLoader.cpp @@ -404,7 +404,7 @@ void BlenderImporter::ConvertBlendFile(aiScene* out, const Scene& in,const FileD } // acknowledge that the scene might come out incomplete - // by Assimps definition of `complete`: blender scenes + // by Assimp's definition of `complete`: blender scenes // can consist of thousands of cameras or lights with // not a single mesh between them. if (!out->mNumMeshes) { @@ -790,7 +790,7 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co ConversionData& conv_data, TempArray& temp ) { - // TODO: Resolve various problems with BMesh triangluation before re-enabling. + // TODO: Resolve various problems with BMesh triangulation before re-enabling. // See issues #400, #373, #318 #315 and #132. #if defined(TODO_FIX_BMESH_CONVERSION) BlenderBMeshConverter BMeshConverter( mesh ); @@ -852,7 +852,7 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co //out->mNumVertices = 0 out->mFaces = new aiFace[it.second](); - // all submeshes created from this mesh are named equally. this allows + // all sub-meshes created from this mesh are named equally. this allows // curious users to recover the original adjacency. out->mName = aiString(mesh->id.name+2); // skip over the name prefix 'ME' @@ -1304,5 +1304,4 @@ aiNode* BlenderImporter::ConvertNode(const Scene& in, const Object* obj, Convers return node.dismiss(); } - -#endif +#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER diff --git a/code/BlenderModifier.cpp b/code/BlenderModifier.cpp index 24aed25d0..f903a1380 100644 --- a/code/BlenderModifier.cpp +++ b/code/BlenderModifier.cpp @@ -275,9 +275,6 @@ void BlenderModifier_Mirror :: DoIt(aiNode& out, ConversionData& conv_data, co orig_object.id.name,"`"); } - - - // ------------------------------------------------------------------------------------------------ bool BlenderModifier_Subdivision :: IsActive (const ModifierData& modin) { @@ -323,4 +320,4 @@ void BlenderModifier_Subdivision :: DoIt(aiNode& out, ConversionData& conv_data orig_object.id.name,"`"); } -#endif +#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER diff --git a/code/BlenderScene.cpp b/code/BlenderScene.cpp index f4d07662e..8d6e96eb5 100644 --- a/code/BlenderScene.cpp +++ b/code/BlenderScene.cpp @@ -806,4 +806,4 @@ void DNA::RegisterConverters() { } -#endif +#endif ASSIMP_BUILD_NO_BLEND_IMPORTER diff --git a/code/BlenderScene.h b/code/BlenderScene.h index 765d95091..4f4ed81cc 100644 --- a/code/BlenderScene.h +++ b/code/BlenderScene.h @@ -64,7 +64,7 @@ namespace Blender { // * C++ style comments only // // * Structures may include the primitive types char, int, short, -// float, double. Signedness specifiers are not allowed on +// float, double. Signed specifiers are not allowed on // integers. Enum types are allowed, but they must have been // defined in this header. // @@ -85,9 +85,9 @@ namespace Blender { // provided they are neither pointers nor arrays. // // * One of WARN, FAIL can be appended to the declaration ( -// prior to the semiolon to specifiy the error handling policy if +// prior to the semicolon to specify the error handling policy if // this field is missing in the input DNA). If none of those -// is specified the default policy is to subtitute a default +// is specified the default policy is to substitute a default // value for the field. // @@ -102,16 +102,16 @@ struct Image; #define AI_BLEND_MESH_MAX_VERTS 2000000000L +static const size_t MaxNameLen = 1024; + // ------------------------------------------------------------------------------- struct ID : ElemBase { - - char name[1024] WARN; + char name[ MaxNameLen ] WARN; short flag; }; // ------------------------------------------------------------------------------- struct ListBase : ElemBase { - std::shared_ptr first; std::shared_ptr last; }; @@ -126,7 +126,6 @@ struct PackedFile : ElemBase { // ------------------------------------------------------------------------------- struct GroupObject : ElemBase { - std::shared_ptr prev,next FAIL; std::shared_ptr ob; }; @@ -142,7 +141,6 @@ struct Group : ElemBase { // ------------------------------------------------------------------------------- struct World : ElemBase { ID id FAIL; - }; // ------------------------------------------------------------------------------- @@ -217,7 +215,6 @@ struct TFace : ElemBase { // ------------------------------------------------------------------------------- struct MTFace : ElemBase { - float uv[4][2] FAIL; char flag; short mode; @@ -235,7 +232,6 @@ struct MDeformWeight : ElemBase { // ------------------------------------------------------------------------------- struct MDeformVert : ElemBase { - vector dw WARN; int totweight; }; @@ -264,7 +260,6 @@ struct Material : ElemBase { float darkness; float refrac; - float amb; float ang; float spectra; From 8b3f348d6308591044d9b61ae77f5b99057c08ec Mon Sep 17 00:00:00 2001 From: johnmaf Date: Wed, 14 Sep 2016 18:03:52 -0400 Subject: [PATCH 2/6] Flip UVs in glTFExporter --- code/glTFExporter.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index e333272be..b610e00fd 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -291,6 +291,13 @@ void glTFExporter::ExportMeshes() if (n) p.attributes.normal.push_back(n); for (int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) { + // Flip UV y coords + if (aim -> mNumUVComponents[i] > 1) { + for (unsigned int j = 0; j < aim->mNumVertices; ++j) { + aim->mTextureCoords[i][j].y = 1 - aim->mTextureCoords[i][j].y; + } + } + if (aim->mNumUVComponents[i] > 0) { AttribType::Value type = (aim->mNumUVComponents[i] == 2) ? AttribType::VEC2 : AttribType::VEC3; Ref tc = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mTextureCoords[i], AttribType::VEC3, type, ComponentType_FLOAT, true); From cd038209dd9cc2d75ce59c0e01ff79a88fa60353 Mon Sep 17 00:00:00 2001 From: johnmaf Date: Wed, 14 Sep 2016 18:14:23 -0400 Subject: [PATCH 3/6] Add all glTF data to single buffer --- code/glTFExporter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index e333272be..960dd3b11 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -267,6 +267,13 @@ void glTFExporter::ExportMaterials() void glTFExporter::ExportMeshes() { + std::string bufferId = mAsset->FindUniqueID("", "buffer"); + + Ref b = mAsset->GetBodyBuffer(); + if (!b) { + b = mAsset->buffers.Create(bufferId); + } + for (unsigned int i = 0; i < mScene->mNumMeshes; ++i) { const aiMesh* aim = mScene->mMeshes[i]; @@ -277,13 +284,6 @@ void glTFExporter::ExportMeshes() p.material = mAsset->materials.Get(aim->mMaterialIndex); - std::string bufferId = mAsset->FindUniqueID(meshId, "buffer"); - - Ref b = mAsset->GetBodyBuffer(); - if (!b) { - b = mAsset->buffers.Create(bufferId); - } - Ref v = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mVertices, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT); if (v) p.attributes.position.push_back(v); From a29f5622411781a2466dfc669d4d3a255a29530f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 17 Sep 2016 10:07:14 +0200 Subject: [PATCH 4/6] Doc: add uml-diagrams for import and export. --- .../Assimp_Arch_Import.class.violet.html | 656 ++++++++++++++++++ doc/UML_docs/assimp.object.violet.html | 107 +++ include/assimp/IOSystem.hpp | 3 +- 3 files changed, 765 insertions(+), 1 deletion(-) create mode 100644 doc/UML_docs/Assimp_Arch_Import.class.violet.html create mode 100644 doc/UML_docs/assimp.object.violet.html diff --git a/doc/UML_docs/Assimp_Arch_Import.class.violet.html b/doc/UML_docs/Assimp_Arch_Import.class.violet.html new file mode 100644 index 000000000..a7ed8c6ce --- /dev/null +++ b/doc/UML_docs/Assimp_Arch_Import.class.violet.html @@ -0,0 +1,656 @@ + + + + + + + + + This file was generated with Violet UML Editor 2.1.0. +   ( View Source / Download Violet ) +
+
+ +
+
+ embedded diagram image + + \ No newline at end of file diff --git a/doc/UML_docs/assimp.object.violet.html b/doc/UML_docs/assimp.object.violet.html new file mode 100644 index 000000000..1d82fa05f --- /dev/null +++ b/doc/UML_docs/assimp.object.violet.html @@ -0,0 +1,107 @@ + + + + + + + + + This file was generated with Violet UML Editor 2.1.0. +   ( View Source / Download Violet ) +
+
+ +
+
+ embedded diagram image + + \ No newline at end of file diff --git a/include/assimp/IOSystem.hpp b/include/assimp/IOSystem.hpp index 9a5876edf..83d927453 100644 --- a/include/assimp/IOSystem.hpp +++ b/include/assimp/IOSystem.hpp @@ -67,7 +67,8 @@ class IOStream; * to the importer library. If you implement this interface, you also want to * supply a custom implementation for IOStream. * - * @see Importer::SetIOHandler() */ + * @see Importer::SetIOHandler() + */ class ASSIMP_API IOSystem #ifndef SWIG : public Intern::AllocateFromAssimpHeap From 0b060d67383233b7ff24f7f78085f1b02f587f3f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 17 Sep 2016 10:20:03 +0200 Subject: [PATCH 5/6] Renaming doc. --- .../Assimp_Arch_Import.class.violet.html | 0 doc/{UML_docs => architecture}/assimp.object.violet.html | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename doc/{UML_docs => architecture}/Assimp_Arch_Import.class.violet.html (100%) rename doc/{UML_docs => architecture}/assimp.object.violet.html (100%) diff --git a/doc/UML_docs/Assimp_Arch_Import.class.violet.html b/doc/architecture/Assimp_Arch_Import.class.violet.html similarity index 100% rename from doc/UML_docs/Assimp_Arch_Import.class.violet.html rename to doc/architecture/Assimp_Arch_Import.class.violet.html diff --git a/doc/UML_docs/assimp.object.violet.html b/doc/architecture/assimp.object.violet.html similarity index 100% rename from doc/UML_docs/assimp.object.violet.html rename to doc/architecture/assimp.object.violet.html From 61419cc0aeca872a8b246d1727dfe563d9e8d643 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 19 Sep 2016 21:35:45 +0200 Subject: [PATCH 6/6] Unittest: add first approach for modeldiffer. --- include/assimp/anim.h | 2 - include/assimp/scene.h | 47 +++---- test/unit/ModelDiffer.cpp | 254 ++++++++++++++++++++++++++++++++++++++ test/unit/ModelDiffer.h | 65 ++++++++++ 4 files changed, 339 insertions(+), 29 deletions(-) create mode 100644 test/unit/ModelDiffer.cpp create mode 100644 test/unit/ModelDiffer.h diff --git a/include/assimp/anim.h b/include/assimp/anim.h index e2961a67c..6380b4650 100644 --- a/include/assimp/anim.h +++ b/include/assimp/anim.h @@ -255,7 +255,6 @@ struct aiNodeAnim * scaling and one position key. */ C_STRUCT aiQuatKey* mRotationKeys; - /** The number of scaling keys */ unsigned int mNumScalingKeys; @@ -266,7 +265,6 @@ struct aiNodeAnim * position and one rotation key.*/ C_STRUCT aiVectorKey* mScalingKeys; - /** Defines how the animation behaves before the first * key is encountered. * diff --git a/include/assimp/scene.h b/include/assimp/scene.h index 31bb8b6a1..398f712b4 100644 --- a/include/assimp/scene.h +++ b/include/assimp/scene.h @@ -60,9 +60,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern "C" { #endif - // ------------------------------------------------------------------------------- -/** A node in the imported hierarchy. +/** + * A node in the imported hierarchy. * * Each node has name, a parent node (except for the root node), * a transformation relative to its parent and possibly several child nodes. @@ -278,7 +278,6 @@ struct aiNode // ------------------------------------------------------------------------------- struct aiScene { - /** Any combination of the AI_SCENE_FLAGS_XXX flags. By default * this value is 0, no flags are set. Most applications will * want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE @@ -286,7 +285,6 @@ struct aiScene */ unsigned int mFlags; - /** The root node of the hierarchy. * * There will always be at least the root node if the import @@ -296,8 +294,6 @@ struct aiScene */ C_STRUCT aiNode* mRootNode; - - /** The number of meshes in the scene. */ unsigned int mNumMeshes; @@ -310,8 +306,6 @@ struct aiScene */ C_STRUCT aiMesh** mMeshes; - - /** The number of materials in the scene. */ unsigned int mNumMaterials; @@ -324,8 +318,6 @@ struct aiScene */ C_STRUCT aiMaterial** mMaterials; - - /** The number of animations in the scene. */ unsigned int mNumAnimations; @@ -336,8 +328,6 @@ struct aiScene */ C_STRUCT aiAnimation** mAnimations; - - /** The number of textures embedded into the file */ unsigned int mNumTextures; @@ -349,7 +339,6 @@ struct aiScene */ C_STRUCT aiTexture** mTextures; - /** The number of light sources in the scene. Light sources * are fully optional, in most cases this attribute will be 0 */ @@ -362,7 +351,6 @@ struct aiScene */ C_STRUCT aiLight** mLights; - /** The number of cameras in the scene. Cameras * are fully optional, in most cases this attribute will be 0 */ @@ -387,33 +375,38 @@ struct aiScene //! Check whether the scene contains meshes //! Unless no special scene flags are set this will always be true. - inline bool HasMeshes() const - { return mMeshes != NULL && mNumMeshes > 0; } + inline bool HasMeshes() const { + return mMeshes != NULL && mNumMeshes > 0; + } //! Check whether the scene contains materials //! Unless no special scene flags are set this will always be true. - inline bool HasMaterials() const - { return mMaterials != NULL && mNumMaterials > 0; } + inline bool HasMaterials() const { + return mMaterials != NULL && mNumMaterials > 0; + } //! Check whether the scene contains lights - inline bool HasLights() const - { return mLights != NULL && mNumLights > 0; } + inline bool HasLights() const { + return mLights != NULL && mNumLights > 0; + } //! Check whether the scene contains textures - inline bool HasTextures() const - { return mTextures != NULL && mNumTextures > 0; } + inline bool HasTextures() const { + return mTextures != NULL && mNumTextures > 0; + } //! Check whether the scene contains cameras - inline bool HasCameras() const - { return mCameras != NULL && mNumCameras > 0; } + inline bool HasCameras() const { + return mCameras != NULL && mNumCameras > 0; + } //! Check whether the scene contains animations - inline bool HasAnimations() const - { return mAnimations != NULL && mNumAnimations > 0; } + inline bool HasAnimations() const { + return mAnimations != NULL && mNumAnimations > 0; + } #endif // __cplusplus - /** Internal data, do not touch */ #ifdef __cplusplus void* mPrivate; diff --git a/test/unit/ModelDiffer.cpp b/test/unit/ModelDiffer.cpp new file mode 100644 index 000000000..8234643e6 --- /dev/null +++ b/test/unit/ModelDiffer.cpp @@ -0,0 +1,254 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2016, assimp team + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ +#include "ModelDiffer.h" +#include +#include + +using namespace Assimp; + +ModelDiffer::ModelDiffer() { + // empty +} + +ModelDiffer::~ModelDiffer() { + // empty +} + +bool ModelDiffer::isEqual( aiScene *expected, aiScene *toCompare ) { + if ( expected == toCompare ) { + return true; + } + + if ( nullptr == expected ) { + return false; + } + + if ( nullptr == toCompare ) { + return false; + } + + if ( expected->mNumMeshes != toCompare->mNumMeshes ) { + std::stringstream stream; + stream << "Number of meshes not equal ( expected: " << expected->mNumMeshes << ", found : " << toCompare->mNumMeshes << " )\n"; + addDiff( stream.str() ); + } + + for ( unsigned int i = 0; i < expected->mNumMeshes; i++ ) { + aiMesh *expMesh( expected->mMeshes[ i ] ); + aiMesh *toCompMesh( toCompare->mMeshes[ i ] ); + compareMesh( expMesh, toCompMesh ); + } +} + +void ModelDiffer::showReport() { + if ( m_diffs.empty() ) { + return; + } + + for ( std::vector::iterator it = m_diffs.begin(); it != m_diffs.end(); it++ ) { + std::cout << *it << "\n"; + } + + std::cout << std::endl; +} + +void ModelDiffer::reset() { + m_diffs.resize( 0 ); +} + +void ModelDiffer::addDiff( const std::string &diff ) { + if ( diff.empty() ) { + return; + } + m_diffs.push_back( diff ); +} + +static std::string dumpVector3( const aiVector3D &toDump ) { + std::stringstream stream; + stream << "( " << toDump.x << ", " << toDump.y << ", " << toDump.z << ")"; + return stream.str(); +} + +static std::string dumpColor4D( const aiColor4D &toDump ) { + std::stringstream stream; + stream << "( " << toDump.r << ", " << toDump.g << ", " << toDump.b << ", " << toDump.a << ")"; + return stream.str(); +} + +bool ModelDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) { + if ( expected == toCompare ) { + return true; + } + + if ( nullptr == expected || nullptr == toCompare ) { + return false; + } + + if ( expected->mName != toCompare->mName ) { + std::stringstream stream; + stream << "Mesh name not equal ( expected: " << expected->mName.C_Str() << ", found : " << toCompare->mName.C_Str() << " )\n"; + addDiff( stream.str() ); + } + + if ( expected->mNumVertices != toCompare->mNumVertices ) { + std::stringstream stream; + stream << "Number of vertices not equal ( expected: " << expected->mNumVertices << ", found : " << toCompare->mNumVertices << " )\n"; + addDiff( stream.str() ); + return false; + } + + // positions + if ( expected->HasPositions() != toCompare->HasPositions() ) { + addDiff( "Expected are vertices, toCompare does not have any." ); + return false; + } + + bool vertEqual( true ); + for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) { + aiVector3D &expVert( expected->mVertices[ i ] ); + aiVector3D &toCompVert( toCompare->mVertices[ i ] ); + if ( expVert != toCompVert ) { + std::stringstream stream; + stream << "Vertex not equal ( expected: " << dumpVector3( expVert ) << ", found: " << dumpVector3( toCompVert ) << "\n"; + addDiff( stream.str() ); + vertEqual = false; + } + } + if ( !vertEqual ) { + return false; + } + + // normals + if ( expected->HasNormals() != toCompare->HasNormals() ) { + addDiff( "Expected are normals, toCompare does not have any." ); + return false; + } + + bool normalEqual( true ); + for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) { + aiVector3D &expNormal( expected->mNormals[ i ] ); + aiVector3D &toCompNormal( toCompare->mNormals[ i ] ); + if ( expNormal != toCompNormal ) { + std::stringstream stream; + stream << "Normal not equal ( expected: " << dumpVector3( expNormal ) << ", found: " << dumpVector3( toCompNormal ) << "\n"; + addDiff( stream.str() ); + normalEqual = false; + } + } + if ( !normalEqual ) { + return false; + } + + // vertex colors + bool vertColEqual( true ); + for ( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++ ) { + if ( expected->HasVertexColors(a) != toCompare->HasVertexColors(a) ) { + addDiff( "Expected are normals, toCompare does not have any." ); + return false; + } + for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) { + aiColor4D &expColor4D( expected->mColors[ a ][ i ] ); + aiColor4D &toCompColor4D( toCompare->mColors[ a ][ i ] ); + if ( expColor4D != toCompColor4D ) { + std::stringstream stream; + stream << "Color4D not equal ( expected: " << dumpColor4D( expColor4D ) << ", found: " << dumpColor4D( toCompColor4D ) << "\n"; + addDiff( stream.str() ); + vertColEqual = false; + } + } + if ( !vertColEqual ) { + return false; + } + } + + // texture coords + bool texCoordsEqual( true ); + for ( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++ ) { + if ( expected->HasTextureCoords( a ) != toCompare->HasTextureCoords( a ) ) { + addDiff( "Expected are texture coords, toCompare does not have any." ); + return false; + } + for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) { + aiVector3D &expTexCoord( expected->mTextureCoords[ a ][ i ] ); + aiVector3D &toCompTexCoord( toCompare->mTextureCoords[ a ][ i ] ); + if ( expTexCoord != toCompTexCoord ) { + std::stringstream stream; + stream << "Texture coords not equal ( expected: " << dumpVector3( expTexCoord ) << ", found: " << dumpVector3( toCompTexCoord ) << "\n"; + addDiff( stream.str() ); + vertColEqual = false; + } + } + if ( !vertColEqual ) { + return false; + } + } + + // tangents and bi-tangents + if ( expected->HasTangentsAndBitangents() != toCompare->HasTangentsAndBitangents() ) { + addDiff( "Expected are tangents and bi-tangents, toCompare does not have any." ); + return false; + } + bool tangentsEqual( true ); + for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) { + aiVector3D &expTangents( expected->mTangents[ i ] ); + aiVector3D &toCompTangents( toCompare->mTangents[ i ] ); + if ( expTangents != toCompTangents ) { + std::stringstream stream; + stream << "Tangents not equal ( expected: " << dumpVector3( expTangents ) << ", found: " << dumpVector3( toCompTangents ) << "\n"; + addDiff( stream.str() ); + tangentsEqual = false; + } + + aiVector3D &expBiTangents( expected->mBitangents[ i ] ); + aiVector3D &toCompBiTangents( toCompare->mBitangents[ i ] ); + if ( expBiTangents != toCompBiTangents ) { + std::stringstream stream; + stream << "Tangents not equal ( expected: " << dumpVector3( expBiTangents ) << ", found: " << dumpVector3( toCompBiTangents ) << "\n"; + addDiff( stream.str() ); + tangentsEqual = false; + } + } + if ( !tangentsEqual ) { + return false; + } + + return true; +} diff --git a/test/unit/ModelDiffer.h b/test/unit/ModelDiffer.h new file mode 100644 index 000000000..03c4462ca --- /dev/null +++ b/test/unit/ModelDiffer.h @@ -0,0 +1,65 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2016, assimp team + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ +#pragma once + +#include "UnitTestPCH.h" +#include +#include +#include + +struct aiScene; +struct aiMesh; + +class ModelDiffer { +public: + ModelDiffer(); + ~ModelDiffer(); + bool isEqual( aiScene *expected, aiScene *toCompare ); + void showReport(); + void reset(); + +private: + void addDiff( const std::string &diff ); + bool compareMesh( aiMesh *expected, aiMesh *toCompare ); + +private: + std::vector m_diffs; +};