From 7d630e98da89bc9ad41bbbda28e820ef6189b58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D1=81=D0=BE=D0=B2=20=D0=95=D0=B2=D0=B3?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B9?= Date: Mon, 23 Jul 2018 16:44:20 +0300 Subject: [PATCH 01/15] STLImporter::LoadBinaryFile add one child node to produce same scene structure as in STLImporter::LoadASCIIFile --- code/STLLoader.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 5abccc774..71cbbc72b 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -535,11 +535,21 @@ bool STLImporter::LoadBinaryFile() // now copy faces addFacesToMesh(pMesh); + aiNode* root = pScene->mRootNode; + + // allocate one node + aiNode* node = new aiNode(); + node->mParent = root; + + root->mNumChildren = 1u; + root->mChildren = new aiNode*[root->mNumChildren]; + root->mChildren[0] = node; + // add all created meshes to the single node - pScene->mRootNode->mNumMeshes = pScene->mNumMeshes; - pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes]; + node->mNumMeshes = pScene->mNumMeshes; + node->mMeshes = new unsigned int[pScene->mNumMeshes]; for (unsigned int i = 0; i < pScene->mNumMeshes; i++) - pScene->mRootNode->mMeshes[i] = i; + node->mMeshes[i] = i; if (bIsMaterialise && !pMesh->mColors[0]) { From 9a6b07e5225ad566dab8e7399b121d5c348de9e7 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Wed, 25 Jul 2018 15:11:24 +0200 Subject: [PATCH 02/15] closes https://github.com/assimp/assimp/issues/1724: add default material access to the material API. --- code/Assimp.cpp | 2 + code/Importer.cpp | 3 ++ code/MaterialSystem.cpp | 80 +++++++++++++++++++++++---------- code/ObjFileMtlImporter.cpp | 2 - code/STLLoader.cpp | 14 +++--- code/ScenePrivate.h | 16 ++++--- code/Version.cpp | 8 ++-- include/assimp/Macros.h | 2 +- include/assimp/material.h | 43 +++++++++++++++--- include/assimp/material.inl | 4 +- test/unit/utMaterialSystem.cpp | 20 ++++++++- test/unit/utSTLImportExport.cpp | 2 +- 12 files changed, 144 insertions(+), 52 deletions(-) diff --git a/code/Assimp.cpp b/code/Assimp.cpp index b682d257b..2a9b896e7 100644 --- a/code/Assimp.cpp +++ b/code/Assimp.cpp @@ -272,6 +272,8 @@ void aiReleaseImport( const aiScene* pScene) ASSIMP_BEGIN_EXCEPTION_REGION(); + aiReleaseDefaultMaterial(); + // find the importer associated with this data const ScenePrivateData* priv = ScenePriv(pScene); if( !priv || !priv->mOrigImporter) { diff --git a/code/Importer.cpp b/code/Importer.cpp index 186818c95..7aabe0a5f 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -178,6 +178,7 @@ Importer::~Importer() { // Delete all import plugins DeleteImporterInstanceList(pimpl->mImporter); + aiReleaseDefaultMaterial(); // Delete all post-processing plug-ins for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) @@ -383,6 +384,8 @@ bool _ValidateFlags(unsigned int pFlags) void Importer::FreeScene( ) { ASSIMP_BEGIN_EXCEPTION_REGION(); + + aiReleaseDefaultMaterial(); delete pimpl->mScene; pimpl->mScene = NULL; diff --git a/code/MaterialSystem.cpp b/code/MaterialSystem.cpp index c8262dff0..3679c93c7 100644 --- a/code/MaterialSystem.cpp +++ b/code/MaterialSystem.cpp @@ -63,9 +63,9 @@ aiReturn aiGetMaterialProperty(const aiMaterial* pMat, unsigned int index, const aiMaterialProperty** pPropOut) { - ai_assert (pMat != NULL); - ai_assert (pKey != NULL); - ai_assert (pPropOut != NULL); + ai_assert( pMat != NULL ); + ai_assert( pKey != NULL ); + ai_assert( pPropOut != NULL ); /* Just search for a property with exactly this name .. * could be improved by hashing, but it's possibly @@ -76,7 +76,7 @@ aiReturn aiGetMaterialProperty(const aiMaterial* pMat, if (prop /* just for safety ... */ && 0 == strcmp( prop->mKey.data, pKey ) - && (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wildcard, but this is undocumented :-) */ + && (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wild-card, but this is undocumented :-) */ && (UINT_MAX == index || prop->mIndex == index)) { *pPropOut = pMat->mProperties[i]; @@ -96,8 +96,8 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat, ai_real* pOut, unsigned int* pMax) { - ai_assert (pOut != NULL); - ai_assert (pMat != NULL); + ai_assert( pOut != NULL ); + ai_assert( pMat != NULL ); const aiMaterialProperty* prop; aiGetMaterialProperty(pMat,pKey,type,index, (const aiMaterialProperty**) &prop); @@ -182,8 +182,8 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat, int* pOut, unsigned int* pMax) { - ai_assert (pOut != NULL); - ai_assert (pMat != NULL); + ai_assert( pOut != NULL ); + ai_assert( pMat != NULL ); const aiMaterialProperty* prop; aiGetMaterialProperty(pMat,pKey,type,index,(const aiMaterialProperty**) &prop); @@ -274,7 +274,7 @@ aiReturn aiGetMaterialUVTransform(const aiMaterial* pMat, aiUVTransform* pOut) { unsigned int iMax = 4; - return aiGetMaterialFloatArray(pMat,pKey,type,index,(ai_real*)pOut,&iMax); + return aiGetMaterialFloatArray(pMat,pKey,type,index,(ai_real*)pOut,&iMax); } // ------------------------------------------------------------------------------------------------ @@ -314,7 +314,7 @@ aiReturn aiGetMaterialString(const aiMaterial* pMat, // ------------------------------------------------------------------------------------------------ // Get the number of textures on a particular texture stack -ASSIMP_API unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat, +unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat, C_ENUM aiTextureType type) { ai_assert (pMat != NULL); @@ -347,12 +347,14 @@ aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat, unsigned int* flags /*= NULL*/ ) { - ai_assert(NULL != mat && NULL != path); + ai_assert( NULL != mat ); + ai_assert( NULL != path ); // Get the path to the texture if (AI_SUCCESS != aiGetMaterialString(mat,AI_MATKEY_TEXTURE(type,index),path)) { return AI_FAILURE; } + // Determine mapping type int mapping_ = static_cast(aiTextureMapping_UV); aiGetMaterialInteger(mat,AI_MATKEY_MAPPING(type,index), &mapping_); @@ -381,15 +383,37 @@ aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat, if (flags){ aiGetMaterialInteger(mat,AI_MATKEY_TEXFLAGS(type,index),(int*)flags); } + return AI_SUCCESS; } +static aiMaterial *DefaultMaterial = nullptr; + +// ------------------------------------------------------------------------------------------------ +// Will return the default material. +aiMaterial *aiCreateAndRegisterDefaultMaterial() { + if (nullptr == DefaultMaterial) { + DefaultMaterial = new aiMaterial; + aiString s; + s.Set(AI_DEFAULT_MATERIAL_NAME); + DefaultMaterial->AddProperty(&s, AI_MATKEY_NAME); + } + + return DefaultMaterial; +} + +// ------------------------------------------------------------------------------------------------ +// Will return the default material. +void aiReleaseDefaultMaterial() { + DefaultMaterial = nullptr; +} + static const unsigned int DefaultNumAllocated = 5; // ------------------------------------------------------------------------------------------------ // Construction. Actually the one and only way to get an aiMaterial instance aiMaterial::aiMaterial() -: mProperties( NULL ) +: mProperties( nullptr ) , mNumProperties( 0 ) , mNumAllocated( DefaultNumAllocated ) { // Allocate 5 entries by default @@ -404,12 +428,20 @@ aiMaterial::~aiMaterial() delete[] mProperties; } +// ------------------------------------------------------------------------------------------------ +aiString aiMaterial::GetName() { + aiString name; + Get(AI_MATKEY_NAME, name); + + return name; +} + // ------------------------------------------------------------------------------------------------ void aiMaterial::Clear() { - for (unsigned int i = 0; i < mNumProperties;++i) { + for ( unsigned int i = 0; i < mNumProperties; ++i ) { // delete this entry - delete mProperties[i]; + delete mProperties[ i ]; AI_DEBUG_INVALIDATE_PTR(mProperties[i]); } mNumProperties = 0; @@ -418,11 +450,9 @@ void aiMaterial::Clear() } // ------------------------------------------------------------------------------------------------ -aiReturn aiMaterial::RemoveProperty (const char* pKey,unsigned int type, - unsigned int index - ) +aiReturn aiMaterial::RemoveProperty ( const char* pKey,unsigned int type, unsigned int index ) { - ai_assert(NULL != pKey); + ai_assert( nullptr != pKey ); for (unsigned int i = 0; i < mNumProperties;++i) { aiMaterialProperty* prop = mProperties[i]; @@ -454,17 +484,18 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput, aiPropertyTypeInfo pType ) { - ai_assert (pInput != NULL); - ai_assert (pKey != NULL); - ai_assert (0 != pSizeInBytes); + ai_assert( pInput != NULL ); + ai_assert( pKey != NULL ); + ai_assert( 0 != pSizeInBytes ); if ( 0 == pSizeInBytes ) { } + // first search the list whether there is already an entry with this key - unsigned int iOutIndex = UINT_MAX; - for (unsigned int i = 0; i < mNumProperties;++i) { - aiMaterialProperty* prop = mProperties[i]; + unsigned int iOutIndex( UINT_MAX ); + for ( unsigned int i = 0; i < mNumProperties; ++i ) { + aiMaterialProperty *prop( mProperties[ i ] ); if (prop /* just for safety */ && !strcmp( prop->mKey.data, pKey ) && prop->mSemantic == type && prop->mIndex == index){ @@ -516,6 +547,7 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput, } // push back ... mProperties[mNumProperties++] = pcNew; + return AI_SUCCESS; } diff --git a/code/ObjFileMtlImporter.cpp b/code/ObjFileMtlImporter.cpp index 8f7588819..711740353 100644 --- a/code/ObjFileMtlImporter.cpp +++ b/code/ObjFileMtlImporter.cpp @@ -84,8 +84,6 @@ static const std::string BumpOption = "-bm"; static const std::string ChannelOption = "-imfchan"; static const std::string TypeOption = "-type"; - - // ------------------------------------------------------------------- // Constructor ObjFileMtlImporter::ObjFileMtlImporter( std::vector &buffer, diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 5abccc774..b556c3418 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -90,6 +90,9 @@ static bool IsBinarySTL(const char* buffer, unsigned int fileSize) { return expectedBinaryFileSize == fileSize; } +static const size_t BufferSize = 500; +static const char UnicodeBoundary = 127; + // An ascii STL buffer will begin with "solid NAME", where NAME is optional. // Note: The "solid NAME" check is necessary, but not sufficient, to determine // if the buffer is ASCII; a binary header could also begin with "solid NAME". @@ -108,10 +111,10 @@ static bool IsAsciiSTL(const char* buffer, unsigned int fileSize) { bool isASCII( strncmp( buffer, "solid", 5 ) == 0 ); if( isASCII ) { // A lot of importers are write solid even if the file is binary. So we have to check for ASCII-characters. - if( fileSize >= 500 ) { + if( fileSize >= BufferSize) { isASCII = true; - for( unsigned int i = 0; i < 500; i++ ) { - if( buffer[ i ] > 127 ) { + for( unsigned int i = 0; i < BufferSize; i++ ) { + if( buffer[ i ] > UnicodeBoundary) { isASCII = false; break; } @@ -211,10 +214,11 @@ void STLImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS // create a single default material, using a white diffuse color for consistency with // other geometric types (e.g., PLY). - aiMaterial* pcMat = new aiMaterial(); + aiMaterial* pcMat = aiCreateAndRegisterDefaultMaterial(); + /*aiMaterial* pcMat = new aiMaterial(); aiString s; s.Set(AI_DEFAULT_MATERIAL_NAME); - pcMat->AddProperty(&s, AI_MATKEY_NAME); + pcMat->AddProperty(&s, AI_MATKEY_NAME);*/ aiColor4D clrDiffuse(ai_real(1.0),ai_real(1.0),ai_real(1.0),ai_real(1.0)); if (bMatClr) { diff --git a/code/ScenePrivate.h b/code/ScenePrivate.h index 50959f455..751b007d8 100644 --- a/code/ScenePrivate.h +++ b/code/ScenePrivate.h @@ -55,12 +55,8 @@ namespace Assimp { class Importer; struct ScenePrivateData { - ScenePrivateData() - : mOrigImporter( nullptr ) - , mPPStepsApplied( 0 ) - , mIsCopy( false ) { - // empty - } + // The struct constructor. + ScenePrivateData(); // Importer that originally loaded the scene though the C-API // If set, this object is owned by this private data instance. @@ -77,6 +73,14 @@ struct ScenePrivateData { bool mIsCopy; }; +inline +ScenePrivateData::ScenePrivateData() +: mOrigImporter( nullptr ) +, mPPStepsApplied( 0 ) +, mIsCopy( false ) { + // empty +} + // Access private data stored in the scene inline ScenePrivateData* ScenePriv(aiScene* in) { diff --git a/code/Version.cpp b/code/Version.cpp index e35344674..b823abd68 100644 --- a/code/Version.cpp +++ b/code/Version.cpp @@ -150,9 +150,11 @@ ASSIMP_API aiScene::~aiScene() { delete mMeshes[a]; delete [] mMeshes; - if (mNumMaterials && mMaterials) - for( unsigned int a = 0; a < mNumMaterials; a++) - delete mMaterials[a]; + if (mNumMaterials && mMaterials) { + for (unsigned int a = 0; a < mNumMaterials; ++a ) { + delete mMaterials[ a ]; + } + } delete [] mMaterials; if (mNumAnimations && mAnimations) diff --git a/include/assimp/Macros.h b/include/assimp/Macros.h index 4a2d07569..3aaed4e97 100644 --- a/include/assimp/Macros.h +++ b/include/assimp/Macros.h @@ -3,7 +3,7 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2012, assimp team +Copyright (c) 2006-2018, assimp team All rights reserved. diff --git a/include/assimp/material.h b/include/assimp/material.h index 83244af37..6564e047b 100644 --- a/include/assimp/material.h +++ b/include/assimp/material.h @@ -608,16 +608,17 @@ struct aiMaterialProperty #ifdef __cplusplus aiMaterialProperty() - : mSemantic( 0 ) - , mIndex( 0 ) - , mDataLength( 0 ) - , mType( aiPTI_Float ) - , mData( NULL ) - { + : mSemantic( 0 ) + , mIndex( 0 ) + , mDataLength( 0 ) + , mType( aiPTI_Float ) + , mData(nullptr) { + // empty } ~aiMaterialProperty() { delete[] mData; + mData = nullptr; } #endif @@ -651,6 +652,14 @@ public: aiMaterial(); ~aiMaterial(); + // ------------------------------------------------------------------- + /** + * @brief Returns the name of the material. + * @return The name of the material. + */ + // ------------------------------------------------------------------- + aiString GetName(); + // ------------------------------------------------------------------- /** @brief Retrieve an array of Type values with a specific key * from the material @@ -1556,10 +1565,32 @@ C_ENUM aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat, unsigned int* flags /*= NULL*/); #endif // !#ifdef __cplusplus +// --------------------------------------------------------------------------- +/** @brief Helper function to get all values pertaining to a particular +* texture slot from a material structure. +* +* @return Pointer showing to the default material. +*/ +// --------------------------------------------------------------------------- +#ifdef __cplusplus +ASSIMP_API aiMaterial *aiCreateAndRegisterDefaultMaterial(void); +#else +C_STRUCT aiMaterial *aiCreateAndRegisterDefaultMaterial(void); +#endif // !#ifdef __cplusplus + +// --------------------------------------------------------------------------- +/** + * @brief Helper function to release the default material instance, the + * instance will not be destroyed. + */ +// --------------------------------------------------------------------------- +ASSIMP_API void aiReleaseDefaultMaterial(); + #ifdef __cplusplus } #include "material.inl" #endif //!__cplusplus + #endif //!!AI_MATERIAL_H_INC diff --git a/include/assimp/material.inl b/include/assimp/material.inl index b52b9befc..3d4b07c06 100644 --- a/include/assimp/material.inl +++ b/include/assimp/material.inl @@ -120,7 +120,7 @@ inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, const aiMaterialProperty* prop; const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx, (const aiMaterialProperty**)&prop); - if ( AI_SUCCESS == ret ) { + if ( AI_SUCCESS == ret ) { if (prop->mDataLength < sizeof(Type)) { return AI_FAILURE; @@ -130,7 +130,7 @@ inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, return AI_FAILURE; } - ::memcpy(&pOut,prop->mData,sizeof(Type)); + ::memcpy( &pOut, prop->mData, sizeof( Type ) ); } return ret; } diff --git a/test/unit/utMaterialSystem.cpp b/test/unit/utMaterialSystem.cpp index 529282393..70ee104c9 100644 --- a/test/unit/utMaterialSystem.cpp +++ b/test/unit/utMaterialSystem.cpp @@ -120,8 +120,7 @@ TEST_F(MaterialSystemTest, testColorProperty) } // ------------------------------------------------------------------------------------------------ -TEST_F(MaterialSystemTest, testStringProperty) -{ +TEST_F(MaterialSystemTest, testStringProperty) { aiString s; s.Set("Hello, this is a small test"); this->pcMat->AddProperty(&s,"testKey6"); @@ -129,3 +128,20 @@ TEST_F(MaterialSystemTest, testStringProperty) EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey6",0,0,s)); EXPECT_STREQ("Hello, this is a small test", s.data); } + +// ------------------------------------------------------------------------------------------------ +TEST_F(MaterialSystemTest, testDefaultMaterialAccess) { + aiMaterial *mat = aiCreateAndRegisterDefaultMaterial(); + EXPECT_NE(nullptr, mat); + aiReleaseDefaultMaterial(); +} + +// ------------------------------------------------------------------------------------------------ +TEST_F(MaterialSystemTest, testMaterialNameAccess) { + aiMaterial *mat = aiCreateAndRegisterDefaultMaterial(); + EXPECT_NE(nullptr, mat); + + aiString name = mat->GetName(); + const int retValue(strncmp(name.C_Str(), AI_DEFAULT_MATERIAL_NAME, name.length)); + EXPECT_EQ(0, retValue ); +} diff --git a/test/unit/utSTLImportExport.cpp b/test/unit/utSTLImportExport.cpp index de1e78a26..9ebfb0f05 100644 --- a/test/unit/utSTLImportExport.cpp +++ b/test/unit/utSTLImportExport.cpp @@ -63,7 +63,7 @@ public: } }; -TEST_F( utSTLImporterExporter, importXFromFileTest ) { +TEST_F( utSTLImporterExporter, importSTLFromFileTest ) { EXPECT_TRUE( importerTest() ); } From 7e6755331132289d3b8ecca1449f96c3c844599a Mon Sep 17 00:00:00 2001 From: kkulling Date: Wed, 25 Jul 2018 15:40:19 +0200 Subject: [PATCH 03/15] Fix memleak. --- test/unit/utMaterialSystem.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/unit/utMaterialSystem.cpp b/test/unit/utMaterialSystem.cpp index 70ee104c9..550dc63da 100644 --- a/test/unit/utMaterialSystem.cpp +++ b/test/unit/utMaterialSystem.cpp @@ -134,6 +134,8 @@ TEST_F(MaterialSystemTest, testDefaultMaterialAccess) { aiMaterial *mat = aiCreateAndRegisterDefaultMaterial(); EXPECT_NE(nullptr, mat); aiReleaseDefaultMaterial(); + + delete mat; } // ------------------------------------------------------------------------------------------------ @@ -144,4 +146,6 @@ TEST_F(MaterialSystemTest, testMaterialNameAccess) { aiString name = mat->GetName(); const int retValue(strncmp(name.C_Str(), AI_DEFAULT_MATERIAL_NAME, name.length)); EXPECT_EQ(0, retValue ); + + delete mat; } From a77887c8743fb53f014042d005bc426499dd680c Mon Sep 17 00:00:00 2001 From: Max Qian Date: Thu, 26 Jul 2018 07:40:05 -0700 Subject: [PATCH 04/15] Use a more accurate way of checking if the build is 64 bit --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d949badb9..4d40a04ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,7 +212,7 @@ IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW) ELSEIF(MSVC) # enable multi-core compilation with MSVC ADD_COMPILE_OPTIONS(/MP) - IF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)") + if(CMAKE_SIZEOF_VOID_P EQUAL 8) ADD_COMPILE_OPTIONS( /bigobj ) ENDIF() # disable "elements of array '' will be default initialized" warning on MSVC2013 From b965e7a6dc7aeea26af1ae239bfae707b492869b Mon Sep 17 00:00:00 2001 From: Sebastian Matusik Date: Sat, 28 Jul 2018 18:18:17 +0100 Subject: [PATCH 05/15] FlipUVsProcess should also process AnimMeshes (if any) --- code/ConvertToLHProcess.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/code/ConvertToLHProcess.cpp b/code/ConvertToLHProcess.cpp index 37ba970e4..9cb45cc69 100644 --- a/code/ConvertToLHProcess.cpp +++ b/code/ConvertToLHProcess.cpp @@ -59,6 +59,25 @@ using namespace Assimp; #ifndef ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS +namespace { + +template +void flipUVs(aiMeshType* pMesh) { + if (pMesh == nullptr) { return; } + // mirror texture y coordinate + for (unsigned int tcIdx = 0; tcIdx < AI_MAX_NUMBER_OF_TEXTURECOORDS; tcIdx++) { + if (!pMesh->HasTextureCoords(tcIdx)) { + break; + } + + for (unsigned int vIdx = 0; vIdx < pMesh->mNumVertices; vIdx++) { + pMesh->mTextureCoords[tcIdx][vIdx].y = 1.0f - pMesh->mTextureCoords[tcIdx][vIdx].y; + } + } +} + +} // namespace + // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer MakeLeftHandedProcess::MakeLeftHandedProcess() @@ -282,15 +301,9 @@ void FlipUVsProcess::ProcessMaterial (aiMaterial* _mat) // Converts a single mesh void FlipUVsProcess::ProcessMesh( aiMesh* pMesh) { - // mirror texture y coordinate - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) { - if( !pMesh->HasTextureCoords( a ) ) { - break; - } - - for( unsigned int b = 0; b < pMesh->mNumVertices; b++ ) { - pMesh->mTextureCoords[ a ][ b ].y = 1.0f - pMesh->mTextureCoords[ a ][ b ].y; - } + flipUVs(pMesh); + for (unsigned int idx = 0; idx < pMesh->mNumAnimMeshes; idx++) { + flipUVs(pMesh->mAnimMeshes[idx]); } } From 92490eea0109c46e73646ada433226b7325e3dfd Mon Sep 17 00:00:00 2001 From: FRICOTEAUX Date: Mon, 30 Jul 2018 17:27:03 +0200 Subject: [PATCH 06/15] Optimisation of FBX node name uniqueness --- code/FBXConverter.cpp | 34 +++++++++++----------------------- code/FBXConverter.h | 2 +- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 91f0dc906..c4b6c815f 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -185,12 +185,12 @@ void Converter::ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4& pa } if ( !name_carrier ) { - NodeNameCache::const_iterator it( std::find( mNodeNames.begin(), mNodeNames.end(), original_name ) ); + NodeNameCache::const_iterator it = mNodeNames.find(original_name); if ( it != mNodeNames.end() ) { original_name = original_name + std::string( "001" ); } - mNodeNames.push_back( original_name ); + mNodeNames.insert( original_name ); nodes_chain.push_back( new aiNode( original_name ) ); } else { original_name = nodes_chain.back()->mName.C_Str(); @@ -398,30 +398,18 @@ void Converter::ConvertCamera( const Camera& cam, const std::string &orig_name ) out_camera->mClipPlaneFar = cam.FarPlane(); } -static bool HasName( NodeNameCache &cache, const std::string &name ) { - NodeNameCache::const_iterator it( std::find( cache.begin(), cache.end(), name ) ); - return it != cache.end(); - -} -void Converter::GetUniqueName( const std::string &name, std::string &uniqueName ) { - if ( !HasName( mNodeNames, name ) ) { - uniqueName = name; - mNodeNames.push_back( uniqueName ); - return; - } - - int i( 0 ); - std::string newName( name ); - while ( HasName( mNodeNames, newName ) ) { +void Converter::GetUniqueName( const std::string &name, std::string &uniqueName ) +{ + int i = 0; + uniqueName = name; + while (mNodeNames.find(uniqueName) != mNodeNames.end()) + { ++i; - newName.clear(); - newName += name; std::stringstream ext; - ext << std::setfill( '0' ) << std::setw( 3 ) << i; - newName += ext.str(); + ext << name << std::setfill('0') << std::setw(3) << i; + uniqueName = ext.str(); } - uniqueName = newName; - mNodeNames.push_back( uniqueName ); + mNodeNames.insert(uniqueName); } diff --git a/code/FBXConverter.h b/code/FBXConverter.h index 2c0810d94..b6654e378 100644 --- a/code/FBXConverter.h +++ b/code/FBXConverter.h @@ -68,7 +68,7 @@ namespace FBX { class Document; -using NodeNameCache = std::vector; +using NodeNameCache = std::set; /** * Convert a FBX #Document to #aiScene From c2c44a831cd4af6fcb6273e83d6588888b9336d2 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Fri, 3 Aug 2018 14:51:01 +0200 Subject: [PATCH 07/15] Pass parameter by reference --- code/Importer/IFC/IFCGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Importer/IFC/IFCGeometry.cpp b/code/Importer/IFC/IFCGeometry.cpp index d49e5cb01..548de4e27 100644 --- a/code/Importer/IFC/IFCGeometry.cpp +++ b/code/Importer/IFC/IFCGeometry.cpp @@ -317,7 +317,7 @@ void ProcessRevolvedAreaSolid(const Schema_2x3::IfcRevolvedAreaSolid& solid, Tem } // ------------------------------------------------------------------------------------------------ -void ProcessSweptDiskSolid(const Schema_2x3::IfcSweptDiskSolid solid, TempMesh& result, ConversionData& conv) +void ProcessSweptDiskSolid(const Schema_2x3::IfcSweptDiskSolid &solid, TempMesh& result, ConversionData& conv) { const Curve* const curve = Curve::Convert(*solid.Directrix, conv); if(!curve) { From ae0f82d5b7972ac7353329501bfa3690227f8d97 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Tue, 31 Jul 2018 23:06:55 +0200 Subject: [PATCH 08/15] Fix #2077 : GLTF segfault using triangle strip --- code/glTF2Importer.cpp | 44 +++++++++++++++++++++++++++--------------- code/glTFImporter.cpp | 5 ----- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index adbeb90f2..0089ef072 100755 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -550,9 +550,18 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r) case PrimitiveMode_TRIANGLE_STRIP: { nFaces = count - 2; faces = new aiFace[nFaces]; - SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2)); - for (unsigned int i = 3; i < count; ++i) { - SetFace(faces[i - 2], faces[i - 1].mIndices[1], faces[i - 1].mIndices[2], data.GetUInt(i)); + for (unsigned int i = 0; i < nFaces; ++i) { + //The ordering is to ensure that the triangles are all drawn with the same orientation + if ((i + 1) % 2 == 0) + { + //For even n, vertices n + 1, n, and n + 2 define triangle n + SetFace(faces[i], data.GetUInt(i + 1), data.GetUInt(i), data.GetUInt(i + 2)); + } + else + { + //For odd n, vertices n, n+1, and n+2 define triangle n + SetFace(faces[i], data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2)); + } } break; } @@ -560,8 +569,8 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r) nFaces = count - 2; faces = new aiFace[nFaces]; SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2)); - for (unsigned int i = 3; i < count; ++i) { - SetFace(faces[i - 2], faces[0].mIndices[0], faces[i - 1].mIndices[2], data.GetUInt(i)); + for (unsigned int i = 1; i < nFaces; ++i) { + SetFace(faces[i], faces[0].mIndices[0], faces[i - 1].mIndices[2], data.GetUInt(i + 2)); } break; } @@ -615,9 +624,18 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r) case PrimitiveMode_TRIANGLE_STRIP: { nFaces = count - 2; faces = new aiFace[nFaces]; - SetFace(faces[0], 0, 1, 2); - for (unsigned int i = 3; i < count; ++i) { - SetFace(faces[i - 2], faces[i - 1].mIndices[1], faces[i - 1].mIndices[2], i); + for (unsigned int i = 0; i < nFaces; ++i) { + //The ordering is to ensure that the triangles are all drawn with the same orientation + if ((i+1) % 2 == 0) + { + //For even n, vertices n + 1, n, and n + 2 define triangle n + SetFace(faces[i], i+1, i, i+2); + } + else + { + //For odd n, vertices n, n+1, and n+2 define triangle n + SetFace(faces[i], i, i+1, i+2); + } } break; } @@ -625,8 +643,8 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r) nFaces = count - 2; faces = new aiFace[nFaces]; SetFace(faces[0], 0, 1, 2); - for (unsigned int i = 3; i < count; ++i) { - SetFace(faces[i - 2], faces[0].mIndices[0], faces[i - 1].mIndices[2], i); + for (unsigned int i = 1; i < nFaces; ++i) { + SetFace(faces[i], faces[0].mIndices[0], faces[i - 1].mIndices[2], i + 2); } break; } @@ -848,12 +866,6 @@ void glTF2Importer::InternReadFile(const std::string& pFile, aiScene* pScene, IO ImportNodes(asset); - // TODO: it does not split the loaded vertices, should it? - //pScene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT; - MakeVerboseFormatProcess process; - process.Execute(pScene); - - if (pScene->mNumMeshes == 0) { pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; } diff --git a/code/glTFImporter.cpp b/code/glTFImporter.cpp index a091ce7df..c68969dc6 100755 --- a/code/glTFImporter.cpp +++ b/code/glTFImporter.cpp @@ -740,11 +740,6 @@ void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOS ImportNodes(asset); - // TODO: it does not split the loaded vertices, should it? - //pScene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT; - MakeVerboseFormatProcess process; - process.Execute(pScene); - if (pScene->mNumMeshes == 0) { pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; From 9dcf83fabdcfd13ad7b1976d46439a33784dcb33 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Wed, 1 Aug 2018 23:27:04 +0200 Subject: [PATCH 09/15] Add unit test for glTF primitive mode --- .../models/glTF2/glTF-Asset-Generator/LICENSE | 21 +++++ .../Mesh_PrimitiveMode_00.bin | Bin 0 -> 12288 bytes .../Mesh_PrimitiveMode_00.gltf | 63 ++++++++++++++ .../Mesh_PrimitiveMode_01.bin | Bin 0 -> 96 bytes .../Mesh_PrimitiveMode_01.gltf | 63 ++++++++++++++ .../Mesh_PrimitiveMode_02.bin | Bin 0 -> 48 bytes .../Mesh_PrimitiveMode_02.gltf | 63 ++++++++++++++ .../Mesh_PrimitiveMode_03.bin | Bin 0 -> 60 bytes .../Mesh_PrimitiveMode_03.gltf | 63 ++++++++++++++ .../Mesh_PrimitiveMode_04.bin | Bin 0 -> 48 bytes .../Mesh_PrimitiveMode_04.gltf | 63 ++++++++++++++ .../Mesh_PrimitiveMode_05.bin | Bin 0 -> 48 bytes .../Mesh_PrimitiveMode_05.gltf | 63 ++++++++++++++ .../Mesh_PrimitiveMode_06.bin | Bin 0 -> 72 bytes .../Mesh_PrimitiveMode_06.gltf | 62 ++++++++++++++ .../Mesh_PrimitiveMode_07.bin | Bin 0 -> 16384 bytes .../Mesh_PrimitiveMode_07.gltf | 77 ++++++++++++++++++ .../Mesh_PrimitiveMode_08.bin | Bin 0 -> 80 bytes .../Mesh_PrimitiveMode_08.gltf | 77 ++++++++++++++++++ .../Mesh_PrimitiveMode_09.bin | Bin 0 -> 64 bytes .../Mesh_PrimitiveMode_09.gltf | 77 ++++++++++++++++++ .../Mesh_PrimitiveMode_10.bin | Bin 0 -> 68 bytes .../Mesh_PrimitiveMode_10.gltf | 77 ++++++++++++++++++ .../Mesh_PrimitiveMode_11.bin | Bin 0 -> 64 bytes .../Mesh_PrimitiveMode_11.gltf | 77 ++++++++++++++++++ .../Mesh_PrimitiveMode_12.bin | Bin 0 -> 64 bytes .../Mesh_PrimitiveMode_12.gltf | 77 ++++++++++++++++++ .../Mesh_PrimitiveMode_13.bin | Bin 0 -> 72 bytes .../Mesh_PrimitiveMode_13.gltf | 76 +++++++++++++++++ .../Mesh_PrimitiveMode_14.bin | Bin 0 -> 54 bytes .../Mesh_PrimitiveMode_14.gltf | 76 +++++++++++++++++ .../Mesh_PrimitiveMode_15.bin | Bin 0 -> 60 bytes .../Mesh_PrimitiveMode_15.gltf | 76 +++++++++++++++++ .../Mesh_PrimitiveMode/README.md | 33 ++++++++ test/unit/utglTF2ImportExport.cpp | 45 ++++++++++ 35 files changed, 1229 insertions(+) create mode 100644 test/models/glTF2/glTF-Asset-Generator/LICENSE create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_00.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_00.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_01.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_01.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_02.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_02.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_03.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_03.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_04.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_04.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_13.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_13.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_14.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_14.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_15.bin create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_15.gltf create mode 100644 test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/README.md diff --git a/test/models/glTF2/glTF-Asset-Generator/LICENSE b/test/models/glTF2/glTF-Asset-Generator/LICENSE new file mode 100644 index 000000000..7b7a04a5c --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Gary Hsu + +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. diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_00.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_00.bin new file mode 100644 index 0000000000000000000000000000000000000000..29c7c4b0d4a61999129ae8ecdfc38a1711e61a5a GIT binary patch literal 12288 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 rcd~7$6WTq<_6FbIIeVB#PeEDiu&Xao5G literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_04.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_04.gltf new file mode 100644 index 000000000..917f0a920 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_04.gltf @@ -0,0 +1,63 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_04.bin", + "byteLength": 48 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "mode": 5 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.bin new file mode 100644 index 0000000000000000000000000000000000000000..c16679daa320863633e50a3427e300dcf35522c3 GIT binary patch literal 48 dcmZQzV6bOkVAv1DAOK>6FbIIekl7$U0{~ZO1Ni^| literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.gltf new file mode 100644 index 000000000..b4f6546e6 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.gltf @@ -0,0 +1,63 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_05.bin", + "byteLength": 48 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "mode": 6 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.bin new file mode 100644 index 0000000000000000000000000000000000000000..867693d15211913f35cd133cfc6b3bacdab85d04 GIT binary patch literal 72 ccmZQzVA#(9!9a?^9*qs+g8;f3WN|PX0Pc(h^#A|> literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.gltf new file mode 100644 index 000000000..42bd31924 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.gltf @@ -0,0 +1,62 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 6, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_06.bin", + "byteLength": 72 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 72, + "name": "Positions" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + } + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.bin new file mode 100644 index 0000000000000000000000000000000000000000..cfc7d5d3e819ddcdab2ece975e6cde55e50a521a GIT binary patch literal 16384 zcmYk?4}4YgAII@qLdee$iZCQ0O!p$J8bTO`P=q08Ll{B`lVp-ilHExr$t0O1Q)?#4 zf-%s!Rcs%ube0@LrbMLw5o)fWH?ETm_{IRuqdvB56EZr)- zNqVF72I&^*_0sF4*Ge}_uaRCYy-K=CdZqLV>E+Um(#xcmN-vRakgk^wr58)rN-vUL zD7`?sM!H(MN_wtzrSu%>+0wJ5E2L*i&yb!jT`oOMdaCpk=`!ib(vzf1rAwqIN>7j; zFI_A>PI|2L80jME(bA)&M@kn;kB}ZNJxsbldZ={1^bqM>>A}(ir3XmoNM}p;m+mK> zC7mhVOFAK)A>Bi|yL4CSbm=bAouoTTr%88^ZZF+VIwsvZfBX5TMY>tKNxD(GLAqAD zM!HhELb_bKOu9t6Sh`5MP`W@mS2{;JOFBb3T{=xVCf!uE{rRbpE|V^l&XSHv7tY)M zbtpUk7oNJkW0~7KOS(|HOu9z8Njlbh``1a6PM6M*&XUfN&Xq2ZE|e~kE|xBlE|V^o zu8^*ju92>lZjf%2Zjx@6Zjo-4j`i98{Irv9FWo^pO}e9WC+RNI>C#=LyG!?w&X7(> z_ma+(&XVpY-CsIeI!Ahd^g!vs(z((@r1PbRN*72ElO8TTLb_0Tr1U81(b7fIW2DDQ zkCQHz9xpvXdZKiRbgA?t>B-V%(o>|TN>7t6m!2*?Lwcrkh4d`x+0t{QE2Za3S4me( z*GMmrUMRgtx>kCzbSPaf-5|Y0da3j>=|<`0(krA_N;gTbl3p#nM!H#gt@JwS_0lcU z8>BZ%Z<216-YmUEdaHDF{oj{!Q0l?GK=kiiM>DRYujM-W9*#lI z9sO>uqu<$e^jx@(o+H=MbLTpGPF+XOwd?3La2>riuA|q?b@W=gj$UKe(QEHIIwo94 z$BOId7;+sQTdt#H&UJJwx{i)f*U_=-Iy$CZN5{JB=sn=NI`!JPu9BWBT`4_Bdbac| z=?dwY(lex|OP5Pelb$L)MY>FSvh*bBQt1-uiP96K$4eJWkCPrNJx01ndbIQ?>5rjE|kuaj!8$? z`fmTWLH^14Ke{*Y>s9XGupZq@xb^5B!*!YLsgZ7yj_zUH{^;Jub#%|;I=UBfoi#rd zJovsj(z((F(uLB|y_uUWmi6df&aIcpdUWsS)+=N^x>t1THL_kS-5}j4-6Y*C-6Gv8 z9ji`#BOd&|?WEgFcaTn#?kL?!x{GwWbXV!_(mkXzq!ZG;q%)9Nw|q>H7;OHYuVC|x35Dm_Vh zvUHjB6zQqb)1=F#r%TU}o+(`+JxhAF^c?9*>ABKX($&&6(hH;)N-vVGm0m0zO4my_ zNH39ID!oj)QF^)b3h9;7P138RS4*#vZkApvy-s?)bc^%`>5bBxq+6voOK*|h>bq}g zGTCR_>1Qi{mb%{3Cok~5xldi_yR}au{=D0>sZVLr_eRzxx%Caq`fg#?_j+buaC_D< z>w7J0lihkVv%c3b>w7h`FS`QJ>BeTAju{Oo6FJ;#E z5@vljF#EFGQ_rmLkhQ69eKE7XYnk=Eh}l=%o`uZ%UclNkw_d}n?`md!S26pl+cTG0 z-<7PDyY)GJg24A|W_{0M_BFSsf?3})S)1G9K^}SP%5@vl*WY+ftX5Vys#xv`?n6(PGK8{)6W100mhS|5= zo+4&_k7jL_TOY-&?~%;GL5t9I*Y%=+%Ytnc>BzVG(5W7c=3Q-i>FELIo#E}WN$ z*ZJ>TRhsmj#kG9BpREc4-(^*Gq3@ciMEo%b4|DK0hA+((S2W)_3aK zKlRy=dekuMyOvqs4a|P!_B1lK=_1(g(?^b5Nc6(ygrAgoIs$;R`ZoPeV z5cuv;T^IUJtB%LNaeF#4>$?-PE8Kb)W__nK>$@wn-?}~Bnf2X+*_CcRgIV7RW_|Z! z_B*#HlUd(c%r?38e$4vr&#dokX1{lPa+vi!fZ0`UeIT>G2Q%wCm)RfOo*~To&S!SD zTOZ1-?*e9h4`cR6w`VxBzDF>-#;q4J>w6@#zDF_pliM?zS>Hv>HoNsP%=#Y7tnYEm z{_OS?GwXXivuoY@1ZI6tWY%{Hv%k1KrOf)C#Oyk^KABnHWz71X!tAeZ&s1i8Ph)ny zTQ6tU_jG1`&tUd9w`V4^zAKn*aqF{~^*x(e-*cG#-R-Gl*7sayH@NjGW_?#P>$`^8 zKir-L%=%u)>_)e~h*{sY%=%u;?4NE=$gJ;rW;eO@24;OPVb=FjX8&?~mNDzQk=a(a zzMNU#E131YlG(rAo+f5}uVQwyTVKtr?={T&Zf5o$w`VQ0zSl9k#jUSr)^`iDzBe%Y zuiLYcS>KzO-Rjm`nf1MyS>Icj{m<>$%B=5LUruuTy+icq%Pe1OTZiEm>qPt?YkpsA zo-1pfXX`NBXq|}vVa>5&&2eSTF=-u!spn$b&ya}!V$J)=n)jeJ?_cXMTy33*|6t8I z$C~q%HRn3(FkE4sh<{_v`PrItyEUH+)?v8Rn$II^KFh569JJ;$)H)19Yd*WJ`P{eW zn!%du4eKyWy-)me^`SM_NY;FYS#xb>9fnobToYPzJ!#Fgs5RHI)?ql?n(Jq4uDz|f zZnx%|-#QFuSaYvo&3%eB_c+!;kUD>D`yIn@sx|jz*4)!sb3bSu1e2}9aFR9mu-4rF zT62G59Rw4t!*GIiBL0kZY4U07SghDO2*z25;aKZL{0ZyQo6Q@U6Q=fI-i5aKmUpN_13Xiu5}m= zwk}Byvd#}Kvrfb>vF7h}t-~|$M->}(wb`&##m?`<86rCEnz2kX-0F4jS? zlXcJd4%R&P)+NcmxxS1ZeL1gMbI!CL60EW2TxVU9{Mwpxlr`rc>mk7+>(sTc|6V1@ z_pEupTk~GF9uiEm<~?X#l1y6j-m&I=VLc=mZO!p)oe{s&n&Z%#W6ZiX%(mv(u+E6b zt@DF!)+Nc#*0o^=YkpVj++dCW?-zX=I8plNAtU~_b#XFj&ChII6J}eNB|BT!gkkFc zyGlL!7KYi@+m^Pi$Lg|E{|{E`(U<+!e4Wf~%dx&qVYW5j*Saj3wC3lu=I6IA2-aBh z^?LiS*${TH=J~Pad9&^nk6ZIRTQ`K+){~Nhta-hxIp$b5b>-=Dib$z(bn)jnM z*GSfFVzEB{c}~Q4u+9s1vgSNsT^Dw+ZWBwhPQ>@N&I|Un=KNz_7k0636HB*F#1FI1 z3%Xfz-m|U?dsw%LWmqTTaqGO`L~G8s*7aegHOGc^B7TN-UT~H*=XvY;Fx#5X1#3Pp ztn-4)tV@%Ftn0(U)_fjW^EqXm7X;R&$s4Wf!=cuE4q9`pTIU6KTbCy9wXP3GSo0pV z=5yJa&uiegyj&)r)!8$LPXr20d zSa(duI6h--u>;y+N9=^1(H^^CSL}uk*d71F9!SHU*b953Blf|**bkl18T;b^bisi* z2nQn_hu}~ghORgq-EaiD<47EZqtOG$;8+}o3>=T1h$Dd$a3W4ZFPw~1kUE*BPJXF3 zX6lzu-S}kTG@Onz&<|(gES!!0I0xtAJY?g1T!0IagNtx6F2Mj?ipy|024WDdz?B$` zt8g{0K`ySvb+{fwa03G5As;v5CftmnxCOW3HWc7?+<`kW40qvf+=Jn`7x&?QjKBkU z5D%dc4`U=A!6-b6(Rd6+cpPK!1jgb?jKfnX#?u&&XD|WJVj`YH36dzq^O%GeFc~kR z3@>2{UdB|sf@yda<#-L#@j7PU4a~%wsK8s8g|{&q?_dtzMJ3+DT+Bli=A#<#qXr*f z0Y1b+e1t{#7`6BWi}5K!)S(`qp#h&`3BJHme2HcF3XS+0%kd3X;9IQ3cWA=*ScM<3 z8b4wUenK;T##;P>b@&zQ@f%w3J2v1CY{Z|~gul>=zp)wrU<>}mR{V$5o4*a(Vh6Ot zj@Su1qdj)PuGkG7usi;TJ&=Yyu^0A6N9==ru^&32Gxo;;=z;@r5DrE<4#A-~3|(6>y5|3aM9>r)ph9W$U zF?a%F@g&CKDHP*rjK?#WfM+og&!GfKl;U|z!V8#;7g2_nFaHPi(?pXvN>yjDN5N|6(itL+XRS4ccM{w8M_r2|J@bcEPUL4IQvM{)at~ zhCQ(t_C`nSgMG0dI-xW6#{uYq191=zMmi3`p*Rd(aX7l+2z1AhI0{Fj2adt9I1U*& z9z7990w>@^oP=ID8K>Y>WTH3vpf9p;8cxR<=!Y|L7S2Y0oP%?59<-RNyVl!rPdQcQ6O< zq7v_6F6N;M^HGiWQG*Y#03Tu@KEfh=j9Pqx#rPB<>QIl*(16de1Yck&zQi(og+_dh z<@g3G@GVy2J2c^YtilgijUTZFKcN{vV=aEcI{b?D_zf-i9UJfmHsVig!e3~`-`I?Q zum%5OEB-_3qQ4E=Vh6Otj@Su1qdj)PuGkG7usi;TJ&=Yyu^0A6N9==ru^&32Gxo;; z=z;@r5DrE<4#A-~3|(6>y5|3aM9>r)ph9W$UF?a%F@g&CKDHP*rjK?#WfM+og&!GfKl;U|z!V8#;7g2_n zFaHPi(?pXvN>yjDN5N|6(it!~X%#8KSBH literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.gltf new file mode 100644 index 000000000..800742242 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.gltf @@ -0,0 +1,77 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 1024, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + }, + { + "bufferView": 1, + "componentType": 5125, + "count": 1024, + "type": "SCALAR", + "name": "Indices Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_07.bin", + "byteLength": 16384 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 12288, + "name": "Positions" + }, + { + "buffer": 0, + "byteOffset": 12288, + "byteLength": 4096, + "name": "Indices" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "indices": 1, + "mode": 0 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.bin new file mode 100644 index 0000000000000000000000000000000000000000..77d730d6afd1c321f9939377e7f5d8c3ce516ef5 GIT binary patch literal 80 ucmZQzV6bOkVAv1DAONC~*&sO(u%9(^rX7UIz`zV-fG`sjGXiN41_1yye+AG0 literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf new file mode 100644 index 000000000..2a951b143 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf @@ -0,0 +1,77 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + }, + { + "bufferView": 1, + "componentType": 5125, + "count": 8, + "type": "SCALAR", + "name": "Indices Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_08.bin", + "byteLength": 80 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + }, + { + "buffer": 0, + "byteOffset": 48, + "byteLength": 32, + "name": "Indices" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "indices": 1, + "mode": 1 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.bin new file mode 100644 index 0000000000000000000000000000000000000000..b828a7af2a9306bbe91fefec2e1d6481ebd095f0 GIT binary patch literal 64 qcmZQzV6bOkVAv1DAONC~*&sO(u%9(^rX7UIz`zV-Faa?m5CZ_%a0SW$ literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf new file mode 100644 index 000000000..12cec564b --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf @@ -0,0 +1,77 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + }, + { + "bufferView": 1, + "componentType": 5125, + "count": 4, + "type": "SCALAR", + "name": "Indices Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_09.bin", + "byteLength": 64 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + }, + { + "buffer": 0, + "byteOffset": 48, + "byteLength": 16, + "name": "Indices" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "indices": 1, + "mode": 2 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.bin new file mode 100644 index 0000000000000000000000000000000000000000..eb4e3f822f789101dff5379a42f8ec4fb1ab428d GIT binary patch literal 68 qcmZQzV6bOkVAv1DAONC~*&sO(u%9(^rX7UIz`zV-Faa?mQ~&_)m<7rJ literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf new file mode 100644 index 000000000..1ca4afbaa --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf @@ -0,0 +1,77 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + }, + { + "bufferView": 1, + "componentType": 5125, + "count": 5, + "type": "SCALAR", + "name": "Indices Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_10.bin", + "byteLength": 68 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + }, + { + "buffer": 0, + "byteOffset": 48, + "byteLength": 20, + "name": "Indices" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "indices": 1, + "mode": 3 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.bin new file mode 100644 index 0000000000000000000000000000000000000000..cf641b2e8ad340b45372084817e97f4c2a7a310b GIT binary patch literal 64 lcmZQzV6bOkVAv1DAONC~*&sO(0MRfu12d4r2*gZ43;?ez1OEU3 literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.gltf new file mode 100644 index 000000000..43c87dab0 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.gltf @@ -0,0 +1,77 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + }, + { + "bufferView": 1, + "componentType": 5125, + "count": 4, + "type": "SCALAR", + "name": "Indices Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_11.bin", + "byteLength": 64 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + }, + { + "buffer": 0, + "byteOffset": 48, + "byteLength": 16, + "name": "Indices" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "indices": 1, + "mode": 5 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.bin new file mode 100644 index 0000000000000000000000000000000000000000..f0a45dc1e073d3206f7f7af11d01aac9da02e3a5 GIT binary patch literal 64 lcmZQzV6bOkVAv1DAONC~*&sO(0MRfu12d4r1jLL$3;?e%1OEU3 literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.gltf new file mode 100644 index 000000000..3e8ca5095 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.gltf @@ -0,0 +1,77 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + }, + { + "bufferView": 1, + "componentType": 5125, + "count": 4, + "type": "SCALAR", + "name": "Indices Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_12.bin", + "byteLength": 64 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + }, + { + "buffer": 0, + "byteOffset": 48, + "byteLength": 16, + "name": "Indices" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "indices": 1, + "mode": 6 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_13.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_13.bin new file mode 100644 index 0000000000000000000000000000000000000000..c3bea4f9c48633a564741f69dcc191eedcbd0e7b GIT binary patch literal 72 pcmZQzV6bOkVAv1DAONC~*&sO(0MTGJBbdv;zzn28Y!J-^!~oAU1Oos7 literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_13.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_13.gltf new file mode 100644 index 000000000..4408895b6 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_13.gltf @@ -0,0 +1,76 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + }, + { + "bufferView": 1, + "componentType": 5125, + "count": 6, + "type": "SCALAR", + "name": "Indices Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_13.bin", + "byteLength": 72 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + }, + { + "buffer": 0, + "byteOffset": 48, + "byteLength": 24, + "name": "Indices" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "indices": 1 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_14.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_14.bin new file mode 100644 index 0000000000000000000000000000000000000000..e25c8cdab353dd61c26273ccd9184b1485d7567a GIT binary patch literal 54 icmZQzV6bOkVAv1DAONC~*&sO(0MTGJBLg!dGZO%ZTLc3D literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_14.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_14.gltf new file mode 100644 index 000000000..7994e6413 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_14.gltf @@ -0,0 +1,76 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + }, + { + "bufferView": 1, + "componentType": 5121, + "count": 6, + "type": "SCALAR", + "name": "Indices Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_14.bin", + "byteLength": 54 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + }, + { + "buffer": 0, + "byteOffset": 48, + "byteLength": 6, + "name": "Indices" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "indices": 1 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_15.bin b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_15.bin new file mode 100644 index 0000000000000000000000000000000000000000..9968347aaae143d4499fc2f6c50cda3d2190bac7 GIT binary patch literal 60 lcmZQzV6bOkVAv1DAONC~*&sO(0MTGJBap$&zzD=l3;>@_1Oos7 literal 0 HcmV?d00001 diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_15.gltf b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_15.gltf new file mode 100644 index 000000000..ff2df27d5 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_15.gltf @@ -0,0 +1,76 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 4, + "type": "VEC3", + "max": [ + 0.5, + 0.5, + 0.0 + ], + "min": [ + -0.5, + -0.5, + 0.0 + ], + "name": "Positions Accessor" + }, + { + "bufferView": 1, + "componentType": 5123, + "count": 6, + "type": "SCALAR", + "name": "Indices Accessor" + } + ], + "asset": { + "generator": "glTF Asset Generator", + "version": "2.0" + }, + "buffers": [ + { + "uri": "Mesh_PrimitiveMode_15.bin", + "byteLength": 60 + } + ], + "bufferViews": [ + { + "buffer": 0, + "byteLength": 48, + "name": "Positions" + }, + { + "buffer": 0, + "byteOffset": 48, + "byteLength": 12, + "name": "Indices" + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "POSITION": 0 + }, + "indices": 1 + } + ] + } + ], + "nodes": [ + { + "mesh": 0 + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/README.md b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/README.md new file mode 100644 index 000000000..0e4707e06 --- /dev/null +++ b/test/models/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/README.md @@ -0,0 +1,33 @@ +These models are intended to test indices, vertexes without indices, and using mode to render different primitive types. + +All values of Byte, Short, and Int are unsigned. + +All model indices relate to vertices as shown by the Indices figure below, except for models using Points Mode: + +| Indices | Indices (For Points Mode) | +| :---: | :---: | +| | | + +
+ +The following table shows the properties that are set for a given model. + +| | Sample Image | Mode | Indices Values | Indices Component Type | +| :---: | :---: | :---: | :---: | :---: | +| [00](Mesh_PrimitiveMode_00.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=0) | [](Figures/SampleImages/Mesh_PrimitiveMode_00.png) | Points | | | +| [01](Mesh_PrimitiveMode_01.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=1) | [](Figures/SampleImages/Mesh_PrimitiveMode_01.png) | Lines | | | +| [02](Mesh_PrimitiveMode_02.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=2) | [](Figures/SampleImages/Mesh_PrimitiveMode_02.png) | Line Loop | | | +| [03](Mesh_PrimitiveMode_03.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=3) | [](Figures/SampleImages/Mesh_PrimitiveMode_03.png) | Line Strip | | | +| [04](Mesh_PrimitiveMode_04.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=4) | [](Figures/SampleImages/Mesh_PrimitiveMode_04.png) | Triangle Strip | | | +| [05](Mesh_PrimitiveMode_05.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=5) | [](Figures/SampleImages/Mesh_PrimitiveMode_05.png) | Triangle Fan | | | +| [06](Mesh_PrimitiveMode_06.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=6) | [](Figures/SampleImages/Mesh_PrimitiveMode_06.png) | Triangles | | | +| [07](Mesh_PrimitiveMode_07.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=7) | [](Figures/SampleImages/Mesh_PrimitiveMode_07.png) | Points | [0 - 1023] | Int | +| [08](Mesh_PrimitiveMode_08.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=8) | [](Figures/SampleImages/Mesh_PrimitiveMode_08.png) | Lines | [0, 3, 3, 2, 2, 1, 1, 0] | Int | +| [09](Mesh_PrimitiveMode_09.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=9) | [](Figures/SampleImages/Mesh_PrimitiveMode_09.png) | Line Loop | [0, 3, 2, 1] | Int | +| [10](Mesh_PrimitiveMode_10.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=10) | [](Figures/SampleImages/Mesh_PrimitiveMode_10.png) | Line Strip | [0, 3, 2, 1, 0] | Int | +| [11](Mesh_PrimitiveMode_11.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=11) | [](Figures/SampleImages/Mesh_PrimitiveMode_11.png) | Triangle Strip | [0, 3, 1, 2] | Int | +| [12](Mesh_PrimitiveMode_12.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=12) | [](Figures/SampleImages/Mesh_PrimitiveMode_12.png) | Triangle Fan | [0, 3, 2, 1] | Int | +| [13](Mesh_PrimitiveMode_13.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=13) | [](Figures/SampleImages/Mesh_PrimitiveMode_13.png) | Triangles | [1, 0, 3, 1, 3, 2] | Int | +| [14](Mesh_PrimitiveMode_14.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=14) | [](Figures/SampleImages/Mesh_PrimitiveMode_14.png) | Triangles | [1, 0, 3, 1, 3, 2] | Byte | +| [15](Mesh_PrimitiveMode_15.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=15) | [](Figures/SampleImages/Mesh_PrimitiveMode_15.png) | Triangles | [1, 0, 3, 1, 3, 2] | Short | + diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index 5117a56fc..a8866f86c 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include using namespace Assimp; @@ -100,6 +101,50 @@ TEST_F( utglTF2ImportExport, importBinaryglTF2FromFileTest ) { EXPECT_TRUE( binaryImporterTest() ); } +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFan) { + Assimp::Importer importer; + //Triangles fan + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); + std::array f1 = { 0, 3, 2 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); + for (int i = 0; i < 3; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); + } + + std::array f2 = { 0, 2, 1 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); + for (int i = 0; i < 3; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) { + Assimp::Importer importer; + //Triangles strip + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + std::array f1 = { 0, 3, 1 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); + for (int i = 0; i < 3; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); + } + + std::array f2 = { 1, 3, 2 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); + for (int i = 0; i < 3; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]); + } +} + #ifndef ASSIMP_BUILD_NO_EXPORT TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) { EXPECT_TRUE( exporterTest() ); From 29ebb126b87a250d8e2cf681e233d9342d2d369a Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Thu, 2 Aug 2018 19:05:45 +0200 Subject: [PATCH 10/15] Add test for glTF2 lines, line strip, lines loop --- test/unit/utglTF2ImportExport.cpp | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index a8866f86c..35b6030da 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -145,6 +145,51 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) { } } +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) { + Assimp::Importer importer; + //Line loop + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + std::array l1 = { 0, 3, 2, 1, 0}; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); + for (int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i+1]); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) { + Assimp::Importer importer; + //Lines + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + std::array l1 = { 0, 3, 2, 1, 0 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); + for (int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineStrip) { + Assimp::Importer importer; + //Lines Strip + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + std::array l1 = { 0, 3, 2, 1, 0 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); + for (int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]); + } +} + #ifndef ASSIMP_BUILD_NO_EXPORT TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) { EXPECT_TRUE( exporterTest() ); From 15c2a96d25055a46a738834e14609fd030886cfe Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Thu, 2 Aug 2018 19:07:51 +0200 Subject: [PATCH 11/15] Add test for glTF2 points --- test/unit/utglTF2ImportExport.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index 35b6030da..e7d214ebd 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -145,6 +145,19 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) { } } +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModePoints) { + Assimp::Importer importer; + //Line loop + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 1024); + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 1); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i); + } +} + TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) { Assimp::Importer importer; //Line loop @@ -153,7 +166,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) { EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); std::array l1 = { 0, 3, 2, 1, 0}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); - for (int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) { EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i+1]); @@ -168,7 +181,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) { EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); std::array l1 = { 0, 3, 2, 1, 0 }; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); - for (int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) { EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]); @@ -183,7 +196,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineStrip) { EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); std::array l1 = { 0, 3, 2, 1, 0 }; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); - for (int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) { EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]); From 319cd649300f17b3bb1607423d1289dd45124f97 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sat, 4 Aug 2018 12:20:56 +0200 Subject: [PATCH 12/15] Add missing unit tests for gltf2 primitive mode --- test/unit/utglTF2ImportExport.cpp | 232 +++++++++++++++++++++++------- 1 file changed, 179 insertions(+), 53 deletions(-) diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index e7d214ebd..fff2568ea 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -101,21 +101,81 @@ TEST_F( utglTF2ImportExport, importBinaryglTF2FromFileTest ) { EXPECT_TRUE( binaryImporterTest() ); } -TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFan) { +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModePointsWithoutIndices) { Assimp::Importer importer; - //Triangles fan - const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.gltf", aiProcess_ValidateDataStructure); + //Points without indices + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_00.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 1024); + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 1); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesWithoutIndices) { + Assimp::Importer importer; + //Lines without indices + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_01.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 8); + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i*2); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], i*2 + 1); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesLoopWithoutIndices) { + Assimp::Importer importer; + //Lines loop without indices + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_02.gltf", aiProcess_ValidateDataStructure); EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + + std::array l1 = { 0, 1, 2, 3, 0 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesStripWithoutIndices) { + Assimp::Importer importer; + //Lines strip without indices + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_03.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 5); + + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], i + 1); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStripWithoutIndices) { + Assimp::Importer importer; + //Triangles strip without indices + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_04.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); - std::array f1 = { 0, 3, 2 }; + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + std::array f1 = { 0, 1, 2 }; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); for (int i = 0; i < 3; ++i) { EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); } - std::array f2 = { 0, 2, 1 }; + std::array f2 = { 2, 1, 3 }; EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); for (int i = 0; i < 3; ++i) { @@ -123,6 +183,108 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFan) { } } +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFanWithoutIndices) { + Assimp::Importer importer; + //Triangles fan without indices + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + std::array f1 = { 0, 1, 2 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); + for (int i = 0; i < 3; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); + } + + std::array f2 = { 0, 2, 3 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); + for (int i = 0; i < 3; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesWithoutIndices) { + Assimp::Importer importer; + //Triangles without indices + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 6); + std::array f1 = { 0, 1, 2 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); + for (int i = 0; i < 3; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); + } + + std::array f2 = { 3, 4, 5 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); + for (int i = 0; i < 3; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModePoints) { + Assimp::Importer importer; + //Line loop + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 1024); + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 1); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) { + Assimp::Importer importer; + //Lines + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + std::array l1 = { 0, 3, 2, 1, 0 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) { + Assimp::Importer importer; + //Line loop + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + std::array l1 = { 0, 3, 2, 1, 0}; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i+1]); + } +} + +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineStrip) { + Assimp::Importer importer; + //Lines Strip + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf", aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); + std::array l1 = { 0, 3, 2, 1, 0 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); + for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + { + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); + EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]); + } +} + TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) { Assimp::Importer importer; //Triangles strip @@ -145,61 +307,25 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) { } } -TEST_F(utglTF2ImportExport, importglTF2PrimitiveModePoints) { +TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFan) { Assimp::Importer importer; - //Line loop - const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.gltf", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); - EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 1024); - for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) - { - EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 1); - EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i); - } -} - -TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) { - Assimp::Importer importer; - //Line loop - const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf", aiProcess_ValidateDataStructure); + //Triangles fan + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.gltf", aiProcess_ValidateDataStructure); EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array l1 = { 0, 3, 2, 1, 0}; - EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); - for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); + std::array f1 = { 0, 3, 2 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); + for (int i = 0; i < 3; ++i) { - EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); - EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i+1]); + EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); } -} -TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) { - Assimp::Importer importer; - //Lines - const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); - EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array l1 = { 0, 3, 2, 1, 0 }; - EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); - for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) + std::array f2 = { 0, 2, 1 }; + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); + for (int i = 0; i < 3; ++i) { - EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); - EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]); - } -} - -TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineStrip) { - Assimp::Importer importer; - //Lines Strip - const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); - EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array l1 = { 0, 3, 2, 1, 0 }; - EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); - for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) - { - EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]); - EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]); + EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]); } } From 3c37fbdc6ba0a3b5358e6b51c68e2cbae2373845 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sat, 4 Aug 2018 12:22:54 +0200 Subject: [PATCH 13/15] Remove try catch(...) on gltf2 importer Better to throw exception than hide it ? --- code/glTF2Importer.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index 0089ef072..bd645e9ce 100755 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -117,13 +117,9 @@ bool glTF2Importer::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool if (pIOHandler) { glTF2::Asset asset(pIOHandler); - try { - asset.Load(pFile, extension == "glb"); - std::string version = asset.asset.version; - return !version.empty() && version[0] == '2'; - } catch (...) { - return false; - } + asset.Load(pFile, extension == "glb"); + std::string version = asset.asset.version; + return !version.empty() && version[0] == '2'; } return false; From 5321e1036deed6a87440c8fd84270a97967e6710 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Sat, 4 Aug 2018 16:36:04 -0500 Subject: [PATCH 14/15] Fix .obj displacement texture parsing The string for an opacity texture is a substring of the displacement texture string. Due to the nature of the string comparison in the material texture parsing, any displacement textures will be incorrectly assigned as opacity textures. Fix this by simply performing the check for displacement texture before checking for opacity texture. --- code/ObjFileMtlImporter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/ObjFileMtlImporter.cpp b/code/ObjFileMtlImporter.cpp index 711740353..16bde1b43 100644 --- a/code/ObjFileMtlImporter.cpp +++ b/code/ObjFileMtlImporter.cpp @@ -332,6 +332,11 @@ void ObjFileMtlImporter::getTexture() { // Specular texture out = & m_pModel->m_pCurrentMaterial->textureSpecular; clampIndex = ObjFile::Material::TextureSpecularType; + } else if ( !ASSIMP_strincmp( pPtr, DisplacementTexture1.c_str(), static_cast(DisplacementTexture1.size()) ) || + !ASSIMP_strincmp( pPtr, DisplacementTexture2.c_str(), static_cast(DisplacementTexture2.size()) ) ) { + // Displacement texture + out = &m_pModel->m_pCurrentMaterial->textureDisp; + clampIndex = ObjFile::Material::TextureDispType; } else if ( !ASSIMP_strincmp( pPtr, OpacityTexture.c_str(), static_cast(OpacityTexture.size()) ) ) { // Opacity texture out = & m_pModel->m_pCurrentMaterial->textureOpacity; @@ -354,11 +359,6 @@ void ObjFileMtlImporter::getTexture() { // Reflection texture(s) //Do nothing here return; - } else if ( !ASSIMP_strincmp( pPtr, DisplacementTexture1.c_str(), static_cast(DisplacementTexture1.size()) ) || - !ASSIMP_strincmp( pPtr, DisplacementTexture2.c_str(), static_cast(DisplacementTexture2.size()) ) ) { - // Displacement texture - out = &m_pModel->m_pCurrentMaterial->textureDisp; - clampIndex = ObjFile::Material::TextureDispType; } else if ( !ASSIMP_strincmp( pPtr, SpecularityTexture.c_str(), static_cast(SpecularityTexture.size()) ) ) { // Specularity scaling (glossiness) out = & m_pModel->m_pCurrentMaterial->textureSpecularity; From ea40ea2822dade0561930c3811b551e06491d4bb Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 5 Aug 2018 00:49:29 +0200 Subject: [PATCH 15/15] Update utglTF2ImportExport.cpp Fix clang compiler warnings, see https://stackoverflow.com/questions/31555584/why-is-clang-warning-suggest-braces-around-initialization-of-subobject-wmis for more detailed information. --- test/unit/utglTF2ImportExport.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index fff2568ea..9eb3ef5bd 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -135,7 +135,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesLoopWithoutIndices) { EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array l1 = { 0, 1, 2, 3, 0 }; + std::array l1 = {{ 0, 1, 2, 3, 0 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) { @@ -168,14 +168,14 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStripWithoutIndices EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array f1 = { 0, 1, 2 }; + std::array f1 = {{ 0, 1, 2 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); for (int i = 0; i < 3; ++i) { EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); } - std::array f2 = { 2, 1, 3 }; + std::array f2 = {{ 2, 1, 3 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); for (int i = 0; i < 3; ++i) { @@ -190,14 +190,14 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFanWithoutIndices) EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array f1 = { 0, 1, 2 }; + std::array f1 = {{ 0, 1, 2 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); for (int i = 0; i < 3; ++i) { EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); } - std::array f2 = { 0, 2, 3 }; + std::array f2 = {{ 0, 2, 3 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); for (int i = 0; i < 3; ++i) { @@ -212,14 +212,14 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesWithoutIndices) { EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 6); - std::array f1 = { 0, 1, 2 }; + std::array f1 = {{ 0, 1, 2 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); for (int i = 0; i < 3; ++i) { EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); } - std::array f2 = { 3, 4, 5 }; + std::array f2 = {{ 3, 4, 5 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); for (int i = 0; i < 3; ++i) { @@ -246,7 +246,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) { const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure); EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array l1 = { 0, 3, 2, 1, 0 }; + std::array l1 = {{ 0, 3, 2, 1, 0 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) { @@ -261,7 +261,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) { const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf", aiProcess_ValidateDataStructure); EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array l1 = { 0, 3, 2, 1, 0}; + std::array l1 = {{ 0, 3, 2, 1, 0 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) { @@ -276,7 +276,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineStrip) { const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf", aiProcess_ValidateDataStructure); EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array l1 = { 0, 3, 2, 1, 0 }; + std::array l1 = {{ 0, 3, 2, 1, 0 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2); for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) { @@ -292,14 +292,14 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) { EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); - std::array f1 = { 0, 3, 1 }; + std::array f1 = {{ 0, 3, 1 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); for (int i = 0; i < 3; ++i) { EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); } - std::array f2 = { 1, 3, 2 }; + std::array f2 = {{ 1, 3, 2 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); for (int i = 0; i < 3; ++i) { @@ -314,14 +314,14 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFan) { EXPECT_NE(nullptr, scene); EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4); EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2); - std::array f1 = { 0, 3, 2 }; + std::array f1 = {{ 0, 3, 2 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3); for (int i = 0; i < 3; ++i) { EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]); } - std::array f2 = { 0, 2, 1 }; + std::array f2 = {{ 0, 2, 1 }}; EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3); for (int i = 0; i < 3; ++i) {