fix warnings
parent
02e5698a38
commit
f8757322be
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace
|
||||||
template<>
|
template<>
|
||||||
size_t select_ftell<8>(FILE* file)
|
size_t select_ftell<8>(FILE* file)
|
||||||
{
|
{
|
||||||
return ::_ftelli64(file);
|
return (size_t)::_ftelli64(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// Public ASSIMP data structures
|
// Public ASSIMP data structures
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// Public interface to Assimp
|
// Public interface to Assimp
|
||||||
class Importer;
|
class Importer;
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -70,10 +68,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/matrix4x4.h>
|
#include <assimp/matrix4x4.h>
|
||||||
#include <assimp/quaternion.h>
|
#include <assimp/quaternion.h>
|
||||||
|
|
||||||
typedef int32_t ai_int32;
|
typedef int32_t ai_int32;
|
||||||
typedef uint32_t ai_uint32 ;
|
typedef uint32_t ai_uint32;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <new> // for std::nothrow_t
|
#include <new> // for std::nothrow_t
|
||||||
#include <string> // for aiString::Set(const std::string&)
|
#include <string> // for aiString::Set(const std::string&)
|
||||||
|
|
|
@ -49,7 +49,9 @@ using namespace Assimp;
|
||||||
|
|
||||||
class TestProgressHandler : public ProgressHandler {
|
class TestProgressHandler : public ProgressHandler {
|
||||||
public:
|
public:
|
||||||
TestProgressHandler() : ProgressHandler() {
|
TestProgressHandler() :
|
||||||
|
ProgressHandler(),
|
||||||
|
mPercentage (0.f) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +62,7 @@ public:
|
||||||
bool Update(float percentage = -1.f) override {
|
bool Update(float percentage = -1.f) override {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
float mPercentage;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExporterTest : public ::testing::Test {
|
class ExporterTest : public ::testing::Test {
|
||||||
|
@ -77,12 +80,11 @@ TEST_F(ExporterTest, ExporterIdTest) {
|
||||||
Exporter exporter;
|
Exporter exporter;
|
||||||
size_t exportFormatCount = exporter.GetExportFormatCount();
|
size_t exportFormatCount = exporter.GetExportFormatCount();
|
||||||
EXPECT_NE(0u, exportFormatCount) << "No registered exporters";
|
EXPECT_NE(0u, exportFormatCount) << "No registered exporters";
|
||||||
typedef std::map<std::string, const aiExportFormatDesc*> ExportIdMap;
|
typedef std::map<std::string, const aiExportFormatDesc *> ExportIdMap;
|
||||||
ExportIdMap exporterMap;
|
ExportIdMap exporterMap;
|
||||||
for (size_t i = 0; i < exportFormatCount; ++i)
|
for (size_t i = 0; i < exportFormatCount; ++i) {
|
||||||
{
|
|
||||||
// Check that the exporter description exists and makes sense
|
// Check that the exporter description exists and makes sense
|
||||||
const aiExportFormatDesc* desc = exporter.GetExportFormatDescription(i);
|
const aiExportFormatDesc *desc = exporter.GetExportFormatDescription(i);
|
||||||
ASSERT_NE(nullptr, desc) << "Missing aiExportFormatDesc at index " << i;
|
ASSERT_NE(nullptr, desc) << "Missing aiExportFormatDesc at index " << i;
|
||||||
EXPECT_NE(nullptr, desc->id) << "Null exporter ID at index " << i;
|
EXPECT_NE(nullptr, desc->id) << "Null exporter ID at index " << i;
|
||||||
EXPECT_STRNE("", desc->id) << "Empty exporter ID at index " << i;
|
EXPECT_STRNE("", desc->id) << "Empty exporter ID at index " << i;
|
||||||
|
@ -97,6 +99,6 @@ TEST_F(ExporterTest, ExporterIdTest) {
|
||||||
EXPECT_TRUE(result.second) << "Duplicate exported id: '" << key << "' " << desc->description << " *." << desc->fileExtension << " at index " << i;
|
EXPECT_TRUE(result.second) << "Duplicate exported id: '" << key << "' " << desc->description << " *." << desc->fileExtension << " at index " << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
const aiExportFormatDesc* desc = exporter.GetExportFormatDescription(exportFormatCount);
|
const aiExportFormatDesc *desc = exporter.GetExportFormatDescription(exportFormatCount);
|
||||||
EXPECT_EQ(nullptr, desc) << "More exporters than claimed";
|
EXPECT_EQ(nullptr, desc) << "More exporters than claimed";
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,8 +88,6 @@ bool SceneDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDo!
|
|
||||||
return true;
|
|
||||||
// materials
|
// materials
|
||||||
if ( expected->mNumMaterials != toCompare->mNumMaterials ) {
|
if ( expected->mNumMaterials != toCompare->mNumMaterials ) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
|
@ -112,6 +110,7 @@ bool SceneDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << "Materials are not equal, index : " << i << "\n";
|
stream << "Materials are not equal, index : " << i << "\n";
|
||||||
addDiff( stream.str() );
|
addDiff( stream.str() );
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,83 +41,83 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include <assimp/scene.h>
|
#include "SceneDiffer.h"
|
||||||
#include <assimp/Importer.hpp>
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/Exporter.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const float VertComponents[ 24 * 3 ] = {
|
static const float VertComponents[24 * 3] = {
|
||||||
-0.500000, 0.500000, 0.500000,
|
-0.500000, 0.500000, 0.500000,
|
||||||
-0.500000, 0.500000, -0.500000,
|
-0.500000, 0.500000, -0.500000,
|
||||||
-0.500000, -0.500000, -0.500000,
|
-0.500000, -0.500000, -0.500000,
|
||||||
-0.500000, -0.500000, 0.500000,
|
-0.500000, -0.500000, 0.500000,
|
||||||
-0.500000, -0.500000, -0.500000,
|
-0.500000, -0.500000, -0.500000,
|
||||||
0.500000, -0.500000, -0.500000,
|
0.500000, -0.500000, -0.500000,
|
||||||
0.500000, -0.500000, 0.500000,
|
0.500000, -0.500000, 0.500000,
|
||||||
-0.500000, -0.500000, 0.500000,
|
-0.500000, -0.500000, 0.500000,
|
||||||
-0.500000, 0.500000, -0.500000,
|
-0.500000, 0.500000, -0.500000,
|
||||||
0.500000, 0.500000, -0.500000,
|
0.500000, 0.500000, -0.500000,
|
||||||
0.500000, -0.500000, -0.500000,
|
0.500000, -0.500000, -0.500000,
|
||||||
-0.500000, -0.500000, -0.500000,
|
-0.500000, -0.500000, -0.500000,
|
||||||
0.500000, 0.500000, 0.500000,
|
0.500000, 0.500000, 0.500000,
|
||||||
0.500000, 0.500000, -0.500000,
|
0.500000, 0.500000, -0.500000,
|
||||||
-0.500000, 0.500000, -0.500000,
|
-0.500000, 0.500000, -0.500000,
|
||||||
-0.500000, 0.500000, 0.500000,
|
-0.500000, 0.500000, 0.500000,
|
||||||
0.500000, -0.500000, 0.500000,
|
0.500000, -0.500000, 0.500000,
|
||||||
0.500000, 0.500000, 0.500000,
|
0.500000, 0.500000, 0.500000,
|
||||||
-0.500000, 0.500000, 0.500000,
|
-0.500000, 0.500000, 0.500000,
|
||||||
-0.500000, -0.500000, 0.500000,
|
-0.500000, -0.500000, 0.500000,
|
||||||
0.500000, -0.500000, -0.500000,
|
0.500000, -0.500000, -0.500000,
|
||||||
0.500000, 0.500000, -0.500000,
|
0.500000, 0.500000, -0.500000,
|
||||||
0.500000, 0.500000, 0.500000f,
|
0.500000, 0.500000, 0.500000f,
|
||||||
0.500000, -0.500000, 0.500000f
|
0.500000, -0.500000, 0.500000f
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *ObjModel =
|
static const char *ObjModel =
|
||||||
"o 1\n"
|
"o 1\n"
|
||||||
"\n"
|
"\n"
|
||||||
"# Vertex list\n"
|
"# Vertex list\n"
|
||||||
"\n"
|
"\n"
|
||||||
"v -0.5 -0.5 0.5\n"
|
"v -0.5 -0.5 0.5\n"
|
||||||
"v -0.5 -0.5 -0.5\n"
|
"v -0.5 -0.5 -0.5\n"
|
||||||
"v -0.5 0.5 -0.5\n"
|
"v -0.5 0.5 -0.5\n"
|
||||||
"v -0.5 0.5 0.5\n"
|
"v -0.5 0.5 0.5\n"
|
||||||
"v 0.5 -0.5 0.5\n"
|
"v 0.5 -0.5 0.5\n"
|
||||||
"v 0.5 -0.5 -0.5\n"
|
"v 0.5 -0.5 -0.5\n"
|
||||||
"v 0.5 0.5 -0.5\n"
|
"v 0.5 0.5 -0.5\n"
|
||||||
"v 0.5 0.5 0.5\n"
|
"v 0.5 0.5 0.5\n"
|
||||||
"\n"
|
"\n"
|
||||||
"# Point / Line / Face list\n"
|
"# Point / Line / Face list\n"
|
||||||
"\n"
|
"\n"
|
||||||
"g Box01\n"
|
"g Box01\n"
|
||||||
"usemtl Default\n"
|
"usemtl Default\n"
|
||||||
"f 4 3 2 1\n"
|
"f 4 3 2 1\n"
|
||||||
"f 2 6 5 1\n"
|
"f 2 6 5 1\n"
|
||||||
"f 3 7 6 2\n"
|
"f 3 7 6 2\n"
|
||||||
"f 8 7 3 4\n"
|
"f 8 7 3 4\n"
|
||||||
"f 5 8 4 1\n"
|
"f 5 8 4 1\n"
|
||||||
"f 6 7 8 5\n"
|
"f 6 7 8 5\n"
|
||||||
"\n"
|
"\n"
|
||||||
"# End of file\n";
|
"# End of file\n";
|
||||||
|
|
||||||
static const char *ObjModel_Issue1111 =
|
static const char *ObjModel_Issue1111 =
|
||||||
"o 1\n"
|
"o 1\n"
|
||||||
"\n"
|
"\n"
|
||||||
"# Vertex list\n"
|
"# Vertex list\n"
|
||||||
"\n"
|
"\n"
|
||||||
"v -0.5 -0.5 0.5\n"
|
"v -0.5 -0.5 0.5\n"
|
||||||
"v -0.5 -0.5 -0.5\n"
|
"v -0.5 -0.5 -0.5\n"
|
||||||
"v -0.5 0.5 -0.5\n"
|
"v -0.5 0.5 -0.5\n"
|
||||||
"\n"
|
"\n"
|
||||||
"usemtl\n"
|
"usemtl\n"
|
||||||
"f 1 2 3\n"
|
"f 1 2 3\n"
|
||||||
"\n"
|
"\n"
|
||||||
"# End of file\n";
|
"# End of file\n";
|
||||||
|
|
||||||
class utObjImportExport : public AbstractImportExportBase {
|
class utObjImportExport : public AbstractImportExportBase {
|
||||||
protected:
|
protected:
|
||||||
|
@ -133,68 +133,68 @@ protected:
|
||||||
aiScene *createScene() {
|
aiScene *createScene() {
|
||||||
aiScene *expScene = new aiScene;
|
aiScene *expScene = new aiScene;
|
||||||
expScene->mNumMeshes = 1;
|
expScene->mNumMeshes = 1;
|
||||||
expScene->mMeshes = new aiMesh*[ 1 ];
|
expScene->mMeshes = new aiMesh *[1];
|
||||||
aiMesh *mesh = new aiMesh;
|
aiMesh *mesh = new aiMesh;
|
||||||
mesh->mName.Set( "1" );
|
mesh->mName.Set("1");
|
||||||
mesh->mNumVertices = 24;
|
mesh->mNumVertices = 24;
|
||||||
mesh->mVertices = new aiVector3D[ 24 ];
|
mesh->mVertices = new aiVector3D[24];
|
||||||
::memcpy( &mesh->mVertices->x, &VertComponents[ 0 ], sizeof( float ) * 24 * 3 );
|
::memcpy(&mesh->mVertices->x, &VertComponents[0], sizeof(float) * 24 * 3);
|
||||||
mesh->mNumFaces = 6;
|
mesh->mNumFaces = 6;
|
||||||
mesh->mFaces = new aiFace[ mesh->mNumFaces ];
|
mesh->mFaces = new aiFace[mesh->mNumFaces];
|
||||||
|
|
||||||
mesh->mFaces[ 0 ].mNumIndices = 4;
|
mesh->mFaces[0].mNumIndices = 4;
|
||||||
mesh->mFaces[ 0 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
|
mesh->mFaces[0].mIndices = new unsigned int[mesh->mFaces[0].mNumIndices];
|
||||||
mesh->mFaces[ 0 ].mIndices[ 0 ] = 0;
|
mesh->mFaces[0].mIndices[0] = 0;
|
||||||
mesh->mFaces[ 0 ].mIndices[ 1 ] = 1;
|
mesh->mFaces[0].mIndices[1] = 1;
|
||||||
mesh->mFaces[ 0 ].mIndices[ 2 ] = 2;
|
mesh->mFaces[0].mIndices[2] = 2;
|
||||||
mesh->mFaces[ 0 ].mIndices[ 3 ] = 3;
|
mesh->mFaces[0].mIndices[3] = 3;
|
||||||
|
|
||||||
mesh->mFaces[ 1 ].mNumIndices = 4;
|
mesh->mFaces[1].mNumIndices = 4;
|
||||||
mesh->mFaces[ 1 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
|
mesh->mFaces[1].mIndices = new unsigned int[mesh->mFaces[0].mNumIndices];
|
||||||
mesh->mFaces[ 1 ].mIndices[ 0 ] = 4;
|
mesh->mFaces[1].mIndices[0] = 4;
|
||||||
mesh->mFaces[ 1 ].mIndices[ 1 ] = 5;
|
mesh->mFaces[1].mIndices[1] = 5;
|
||||||
mesh->mFaces[ 1 ].mIndices[ 2 ] = 6;
|
mesh->mFaces[1].mIndices[2] = 6;
|
||||||
mesh->mFaces[ 1 ].mIndices[ 3 ] = 7;
|
mesh->mFaces[1].mIndices[3] = 7;
|
||||||
|
|
||||||
mesh->mFaces[ 2 ].mNumIndices = 4;
|
mesh->mFaces[2].mNumIndices = 4;
|
||||||
mesh->mFaces[ 2 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
|
mesh->mFaces[2].mIndices = new unsigned int[mesh->mFaces[0].mNumIndices];
|
||||||
mesh->mFaces[ 2 ].mIndices[ 0 ] = 8;
|
mesh->mFaces[2].mIndices[0] = 8;
|
||||||
mesh->mFaces[ 2 ].mIndices[ 1 ] = 9;
|
mesh->mFaces[2].mIndices[1] = 9;
|
||||||
mesh->mFaces[ 2 ].mIndices[ 2 ] = 10;
|
mesh->mFaces[2].mIndices[2] = 10;
|
||||||
mesh->mFaces[ 2 ].mIndices[ 3 ] = 11;
|
mesh->mFaces[2].mIndices[3] = 11;
|
||||||
|
|
||||||
mesh->mFaces[ 3 ].mNumIndices = 4;
|
mesh->mFaces[3].mNumIndices = 4;
|
||||||
mesh->mFaces[ 3 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
|
mesh->mFaces[3].mIndices = new unsigned int[mesh->mFaces[0].mNumIndices];
|
||||||
mesh->mFaces[ 3 ].mIndices[ 0 ] = 12;
|
mesh->mFaces[3].mIndices[0] = 12;
|
||||||
mesh->mFaces[ 3 ].mIndices[ 1 ] = 13;
|
mesh->mFaces[3].mIndices[1] = 13;
|
||||||
mesh->mFaces[ 3 ].mIndices[ 2 ] = 14;
|
mesh->mFaces[3].mIndices[2] = 14;
|
||||||
mesh->mFaces[ 3 ].mIndices[ 3 ] = 15;
|
mesh->mFaces[3].mIndices[3] = 15;
|
||||||
|
|
||||||
mesh->mFaces[ 4 ].mNumIndices = 4;
|
mesh->mFaces[4].mNumIndices = 4;
|
||||||
mesh->mFaces[ 4 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
|
mesh->mFaces[4].mIndices = new unsigned int[mesh->mFaces[0].mNumIndices];
|
||||||
mesh->mFaces[ 4 ].mIndices[ 0 ] = 16;
|
mesh->mFaces[4].mIndices[0] = 16;
|
||||||
mesh->mFaces[ 4 ].mIndices[ 1 ] = 17;
|
mesh->mFaces[4].mIndices[1] = 17;
|
||||||
mesh->mFaces[ 4 ].mIndices[ 2 ] = 18;
|
mesh->mFaces[4].mIndices[2] = 18;
|
||||||
mesh->mFaces[ 4 ].mIndices[ 3 ] = 19;
|
mesh->mFaces[4].mIndices[3] = 19;
|
||||||
|
|
||||||
mesh->mFaces[ 5 ].mNumIndices = 4;
|
mesh->mFaces[5].mNumIndices = 4;
|
||||||
mesh->mFaces[ 5 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
|
mesh->mFaces[5].mIndices = new unsigned int[mesh->mFaces[0].mNumIndices];
|
||||||
mesh->mFaces[ 5 ].mIndices[ 0 ] = 20;
|
mesh->mFaces[5].mIndices[0] = 20;
|
||||||
mesh->mFaces[ 5 ].mIndices[ 1 ] = 21;
|
mesh->mFaces[5].mIndices[1] = 21;
|
||||||
mesh->mFaces[ 5 ].mIndices[ 2 ] = 22;
|
mesh->mFaces[5].mIndices[2] = 22;
|
||||||
mesh->mFaces[ 5 ].mIndices[ 3 ] = 23;
|
mesh->mFaces[5].mIndices[3] = 23;
|
||||||
|
|
||||||
expScene->mMeshes[ 0 ] = mesh;
|
expScene->mMeshes[0] = mesh;
|
||||||
|
|
||||||
expScene->mNumMaterials = 1;
|
expScene->mNumMaterials = 1;
|
||||||
expScene->mMaterials = new aiMaterial*[ expScene->mNumMaterials ];
|
expScene->mMaterials = new aiMaterial *[expScene->mNumMaterials];
|
||||||
|
|
||||||
return expScene;
|
return expScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
::Assimp::Importer importer;
|
::Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,11 +203,11 @@ protected:
|
||||||
virtual bool exporterTest() {
|
virtual bool exporterTest() {
|
||||||
::Assimp::Importer importer;
|
::Assimp::Importer importer;
|
||||||
::Assimp::Exporter exporter;
|
::Assimp::Exporter exporter;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.obj" ) );
|
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.obj"));
|
||||||
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "objnomtl", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_nomtl_out.obj" ) );
|
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "objnomtl", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_nomtl_out.obj"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,30 +218,29 @@ protected:
|
||||||
aiScene *m_expectedScene;
|
aiScene *m_expectedScene;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utObjImportExport, importObjFromFileTest ) {
|
TEST_F(utObjImportExport, importObjFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
TEST_F( utObjImportExport, exportObjFromFileTest ) {
|
TEST_F(utObjImportExport, exportObjFromFileTest) {
|
||||||
EXPECT_TRUE( exporterTest() );
|
EXPECT_TRUE(exporterTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
TEST_F( utObjImportExport, obj_import_test ) {
|
TEST_F(utObjImportExport, obj_import_test) {
|
||||||
const aiScene *scene = m_im->ReadFileFromMemory( (void*) ObjModel, strlen(ObjModel), 0 );
|
const aiScene *scene = m_im->ReadFileFromMemory((void *)ObjModel, strlen(ObjModel), 0);
|
||||||
aiScene *expected = createScene();
|
aiScene *expected = createScene();
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
SceneDiffer differ;
|
SceneDiffer differ;
|
||||||
EXPECT_TRUE( differ.isEqual( expected, scene ) );
|
EXPECT_TRUE(differ.isEqual(expected, scene));
|
||||||
differ.showReport();
|
differ.showReport();
|
||||||
|
|
||||||
m_im->FreeScene();
|
m_im->FreeScene();
|
||||||
for(unsigned int i = 0; i < expected->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < expected->mNumMeshes; ++i) {
|
||||||
{
|
|
||||||
delete expected->mMeshes[i];
|
delete expected->mMeshes[i];
|
||||||
}
|
}
|
||||||
delete[] expected->mMeshes;
|
delete[] expected->mMeshes;
|
||||||
|
@ -251,70 +250,70 @@ TEST_F( utObjImportExport, obj_import_test ) {
|
||||||
delete expected;
|
delete expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utObjImportExport, issue1111_no_mat_name_Test ) {
|
TEST_F(utObjImportExport, issue1111_no_mat_name_Test) {
|
||||||
const aiScene *scene = m_im->ReadFileFromMemory( ( void* ) ObjModel_Issue1111, strlen(ObjModel_Issue1111), 0 );
|
const aiScene *scene = m_im->ReadFileFromMemory((void *)ObjModel_Issue1111, strlen(ObjModel_Issue1111), 0);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utObjImportExport, issue809_vertex_color_Test ) {
|
TEST_F(utObjImportExport, issue809_vertex_color_Test) {
|
||||||
::Assimp::Importer importer;
|
::Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors.obj", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors.obj", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
::Assimp::Exporter exporter;
|
::Assimp::Exporter exporter;
|
||||||
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/test_out.obj" ) );
|
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/test_out.obj"));
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utObjImportExport, issue1923_vertex_color_Test ) {
|
TEST_F(utObjImportExport, issue1923_vertex_color_Test) {
|
||||||
::Assimp::Importer importer;
|
::Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors_uni.obj", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors_uni.obj", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
scene = importer.GetOrphanedScene();
|
scene = importer.GetOrphanedScene();
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
::Assimp::Exporter exporter;
|
::Assimp::Exporter exporter;
|
||||||
const aiExportDataBlob* blob = exporter.ExportToBlob( scene, "obj");
|
const aiExportDataBlob *blob = exporter.ExportToBlob(scene, "obj");
|
||||||
EXPECT_NE( nullptr, blob );
|
EXPECT_NE(nullptr, blob);
|
||||||
|
|
||||||
const aiScene *sceneReImport = importer.ReadFileFromMemory( blob->data, blob->size, aiProcess_ValidateDataStructure );
|
const aiScene *sceneReImport = importer.ReadFileFromMemory(blob->data, blob->size, aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
SceneDiffer differ;
|
SceneDiffer differ;
|
||||||
EXPECT_TRUE( differ.isEqual( scene, sceneReImport ) );
|
EXPECT_TRUE(differ.isEqual(scene, sceneReImport));
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
delete scene;
|
delete scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utObjImportExport, issue1453_segfault ) {
|
TEST_F(utObjImportExport, issue1453_segfault) {
|
||||||
static const char *ObjModel =
|
static const char *CurObjModel =
|
||||||
"v 0.0 0.0 0.0\n"
|
"v 0.0 0.0 0.0\n"
|
||||||
"v 0.0 0.0 1.0\n"
|
"v 0.0 0.0 1.0\n"
|
||||||
"v 0.0 1.0 0.0\n"
|
"v 0.0 1.0 0.0\n"
|
||||||
"v 0.0 1.0 1.0\n"
|
"v 0.0 1.0 1.0\n"
|
||||||
"v 1.0 0.0 0.0\n"
|
"v 1.0 0.0 0.0\n"
|
||||||
"v 1.0 0.0 1.0\n"
|
"v 1.0 0.0 1.0\n"
|
||||||
"v 1.0 1.0 0.0\n"
|
"v 1.0 1.0 0.0\n"
|
||||||
"v 1.0 1.0 1.0\nB";
|
"v 1.0 1.0 1.0\nB";
|
||||||
|
|
||||||
Assimp::Importer myimporter;
|
Assimp::Importer myimporter;
|
||||||
const aiScene *scene = myimporter.ReadFileFromMemory( ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure );
|
const aiScene *scene = myimporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), aiProcess_ValidateDataStructure);
|
||||||
EXPECT_EQ( nullptr, scene );
|
EXPECT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utObjImportExport, relative_indices_Test) {
|
TEST_F(utObjImportExport, relative_indices_Test) {
|
||||||
static const char *ObjModel =
|
static const char *CurObjModel =
|
||||||
"v -0.500000 0.000000 0.400000\n"
|
"v -0.500000 0.000000 0.400000\n"
|
||||||
"v -0.500000 0.000000 -0.800000\n"
|
"v -0.500000 0.000000 -0.800000\n"
|
||||||
"v -0.500000 1.000000 -0.800000\n"
|
"v -0.500000 1.000000 -0.800000\n"
|
||||||
"v -0.500000 1.000000 0.400000\n"
|
"v -0.500000 1.000000 0.400000\n"
|
||||||
"f -4 -3 -2 -1\nB";
|
"f -4 -3 -2 -1\nB";
|
||||||
|
|
||||||
Assimp::Importer myimporter;
|
Assimp::Importer myimporter;
|
||||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
|
const aiScene *scene = myimporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1U);
|
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||||
|
@ -323,22 +322,20 @@ TEST_F(utObjImportExport, relative_indices_Test) {
|
||||||
EXPECT_EQ(mesh->mNumFaces, 1U);
|
EXPECT_EQ(mesh->mNumFaces, 1U);
|
||||||
const aiFace face = mesh->mFaces[0];
|
const aiFace face = mesh->mFaces[0];
|
||||||
EXPECT_EQ(face.mNumIndices, 4U);
|
EXPECT_EQ(face.mNumIndices, 4U);
|
||||||
for (unsigned int i = 0; i < face.mNumIndices; ++i)
|
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
||||||
{
|
|
||||||
EXPECT_EQ(face.mIndices[i], i);
|
EXPECT_EQ(face.mIndices[i], i);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
|
TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
|
||||||
static const char *ObjModel =
|
static const char *CurObjModel =
|
||||||
"v -0.500000 0.000000 0.400000 0.50000\n"
|
"v -0.500000 0.000000 0.400000 0.50000\n"
|
||||||
"v -0.500000 0.000000 -0.800000 1.00000\n"
|
"v -0.500000 0.000000 -0.800000 1.00000\n"
|
||||||
"v 0.500000 1.000000 -0.800000 0.5000\n"
|
"v 0.500000 1.000000 -0.800000 0.5000\n"
|
||||||
"f 1 2 3\nB";
|
"f 1 2 3\nB";
|
||||||
|
|
||||||
Assimp::Importer myimporter;
|
Assimp::Importer myimporter;
|
||||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
|
const aiScene *scene = myimporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1U);
|
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||||
|
@ -354,84 +351,84 @@ TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utObjImportExport, homogeneous_coordinates_divide_by_zero_Test) {
|
TEST_F(utObjImportExport, homogeneous_coordinates_divide_by_zero_Test) {
|
||||||
static const char *ObjModel =
|
static const char *CurObjModel =
|
||||||
"v -0.500000 0.000000 0.400000 0.\n"
|
"v -0.500000 0.000000 0.400000 0.\n"
|
||||||
"v -0.500000 0.000000 -0.800000 1.00000\n"
|
"v -0.500000 0.000000 -0.800000 1.00000\n"
|
||||||
"v 0.500000 1.000000 -0.800000 0.5000\n"
|
"v 0.500000 1.000000 -0.800000 0.5000\n"
|
||||||
"f 1 2 3\nB";
|
"f 1 2 3\nB";
|
||||||
|
|
||||||
Assimp::Importer myimporter;
|
Assimp::Importer myimporter;
|
||||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
|
const aiScene *scene = myimporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), aiProcess_ValidateDataStructure);
|
||||||
EXPECT_EQ(nullptr, scene);
|
EXPECT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utObjImportExport, 0based_array_Test) {
|
TEST_F(utObjImportExport, 0based_array_Test) {
|
||||||
static const char *ObjModel =
|
static const char *CurObjModel =
|
||||||
"v -0.500000 0.000000 0.400000\n"
|
"v -0.500000 0.000000 0.400000\n"
|
||||||
"v -0.500000 0.000000 -0.800000\n"
|
"v -0.500000 0.000000 -0.800000\n"
|
||||||
"v -0.500000 1.000000 -0.800000\n"
|
"v -0.500000 1.000000 -0.800000\n"
|
||||||
"f 0 1 2\nB";
|
"f 0 1 2\nB";
|
||||||
|
|
||||||
Assimp::Importer myImporter;
|
Assimp::Importer myImporter;
|
||||||
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
const aiScene *scene = myImporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), 0);
|
||||||
EXPECT_EQ(nullptr, scene);
|
EXPECT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utObjImportExport, invalid_normals_uvs) {
|
TEST_F(utObjImportExport, invalid_normals_uvs) {
|
||||||
static const char *ObjModel =
|
static const char *CurObjModel =
|
||||||
"v -0.500000 0.000000 0.400000\n"
|
"v -0.500000 0.000000 0.400000\n"
|
||||||
"v -0.500000 0.000000 -0.800000\n"
|
"v -0.500000 0.000000 -0.800000\n"
|
||||||
"v -0.500000 1.000000 -0.800000\n"
|
"v -0.500000 1.000000 -0.800000\n"
|
||||||
"vt 0 0\n"
|
"vt 0 0\n"
|
||||||
"vn 0 1 0\n"
|
"vn 0 1 0\n"
|
||||||
"f 1/1/1 1/1/1 2/2/2\nB";
|
"f 1/1/1 1/1/1 2/2/2\nB";
|
||||||
|
|
||||||
Assimp::Importer myImporter;
|
Assimp::Importer myImporter;
|
||||||
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
const aiScene *scene = myImporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), 0);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utObjImportExport, no_vt_just_vns) {
|
TEST_F(utObjImportExport, no_vt_just_vns) {
|
||||||
static const char *ObjModel =
|
static const char *CurObjModel =
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 0 0 0\n"
|
"v 0 0 0\n"
|
||||||
"v 10 0 0\n"
|
"v 10 0 0\n"
|
||||||
"v 0 10 0\n"
|
"v 0 10 0\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"vn 0 0 1\n"
|
"vn 0 0 1\n"
|
||||||
"f 10/10 11/11 12/12\n";
|
"f 10/10 11/11 12/12\n";
|
||||||
|
|
||||||
Assimp::Importer myImporter;
|
Assimp::Importer myImporter;
|
||||||
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
const aiScene *scene = myImporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), 0);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utObjImportExport, mtllib_after_g ) {
|
TEST_F(utObjImportExport, mtllib_after_g) {
|
||||||
::Assimp::Importer importer;
|
::Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_mtllib_after_g.obj", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/cube_mtllib_after_g.obj", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE( nullptr, scene );
|
ASSERT_NE(nullptr, scene);
|
||||||
|
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1U);
|
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||||
const aiMesh *mesh = scene->mMeshes[0];
|
const aiMesh *mesh = scene->mMeshes[0];
|
||||||
const aiMaterial* mat = scene->mMaterials[mesh->mMaterialIndex];
|
const aiMaterial *mat = scene->mMaterials[mesh->mMaterialIndex];
|
||||||
aiString name;
|
aiString name;
|
||||||
ASSERT_EQ(aiReturn_SUCCESS, mat->Get(AI_MATKEY_NAME, name));
|
ASSERT_EQ(aiReturn_SUCCESS, mat->Get(AI_MATKEY_NAME, name));
|
||||||
EXPECT_STREQ("MyMaterial", name.C_Str());
|
EXPECT_STREQ("MyMaterial", name.C_Str());
|
||||||
|
@ -439,7 +436,7 @@ TEST_F( utObjImportExport, mtllib_after_g ) {
|
||||||
|
|
||||||
TEST_F(utObjImportExport, import_point_cloud) {
|
TEST_F(utObjImportExport, import_point_cloud) {
|
||||||
::Assimp::Importer importer;
|
::Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/point_cloud.obj", 0 );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/point_cloud.obj", 0);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,13 +448,13 @@ TEST_F(utObjImportExport, import_without_linend) {
|
||||||
|
|
||||||
TEST_F(utObjImportExport, import_with_line_continuations) {
|
TEST_F(utObjImportExport, import_with_line_continuations) {
|
||||||
static const char *ObjModel =
|
static const char *ObjModel =
|
||||||
"v -0.5 -0.5 0.5\n"
|
"v -0.5 -0.5 0.5\n"
|
||||||
"v -0.5 \\\n"
|
"v -0.5 \\\n"
|
||||||
" -0.5 -0.5\n"
|
" -0.5 -0.5\n"
|
||||||
"v -0.5 \\\n"
|
"v -0.5 \\\n"
|
||||||
" 0.5 \\\n"
|
" 0.5 \\\n"
|
||||||
" -0.5\n"
|
" -0.5\n"
|
||||||
"f 1 2 3\n";
|
"f 1 2 3\n";
|
||||||
|
|
||||||
Assimp::Importer myImporter;
|
Assimp::Importer myImporter;
|
||||||
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
||||||
|
|
|
@ -183,7 +183,7 @@ TEST_F(SortByPTypeProcessTest, SortByPTypeStep) {
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
for (unsigned int m = 0,real = 0; m< 10;++m) {
|
for (unsigned int m = 0,real = 0; m< 10;++m) {
|
||||||
for (unsigned int n = 0; n < 4;++n) {
|
for (unsigned int n = 0; n < 4;++n) {
|
||||||
idx = num[m][n])
|
idx = num[m][n];
|
||||||
if (idx) {
|
if (idx) {
|
||||||
EXPECT_TRUE(real < mScene->mNumMeshes);
|
EXPECT_TRUE(real < mScene->mNumMeshes);
|
||||||
|
|
||||||
|
|
|
@ -112,10 +112,10 @@ TEST_F(TriangulateProcessTest, testTriangulation) {
|
||||||
std::vector<bool> ait(q,false);
|
std::vector<bool> ait(q,false);
|
||||||
|
|
||||||
for (unsigned int i = 0, tt = q-2; i < tt; ++i,++m) {
|
for (unsigned int i = 0, tt = q-2; i < tt; ++i,++m) {
|
||||||
aiFace& face = pcMesh->mFaces[m];
|
const aiFace& curFace = pcMesh->mFaces[m];
|
||||||
EXPECT_EQ(3U, face.mNumIndices);
|
EXPECT_EQ(3U, curFace.mNumIndices);
|
||||||
|
|
||||||
for (unsigned int qqq = 0; qqq < face.mNumIndices; ++qqq) {
|
for (unsigned int qqq = 0; qqq < curFace.mNumIndices; ++qqq) {
|
||||||
ait[face.mIndices[qqq]-idx] = true;
|
ait[face.mIndices[qqq]-idx] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,9 +142,9 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
||||||
|
|
||||||
// if no output file is specified, take the file name from input file
|
// if no output file is specified, take the file name from input file
|
||||||
if (out[0] == '-') {
|
if (out[0] == '-') {
|
||||||
std::string::size_type s = in.find_last_of('.');
|
std::string::size_type pos = in.find_last_of('.');
|
||||||
if (s == std::string::npos) {
|
if (pos == std::string::npos) {
|
||||||
s = in.length();
|
pos = in.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
out = in.substr(0,s);
|
out = in.substr(0,s);
|
||||||
|
|
|
@ -155,7 +155,7 @@ int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int
|
||||||
info.biWidth = width;
|
info.biWidth = width;
|
||||||
info.biHeight = height;
|
info.biHeight = height;
|
||||||
info.biPlanes = 1;
|
info.biPlanes = 1;
|
||||||
info.biBitCount = numc<<3;
|
info.biBitCount = (int16_t) numc<<3;
|
||||||
info.biCompression = 0;
|
info.biCompression = 0;
|
||||||
info.biSizeImage = width*height*numc;
|
info.biSizeImage = width*height*numc;
|
||||||
info.biXPelsPerMeter = 1; // dummy
|
info.biXPelsPerMeter = 1; // dummy
|
||||||
|
|
|
@ -48,16 +48,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "Main.h"
|
#include "Main.h"
|
||||||
#include "PostProcessing/ProcessHelper.h"
|
#include "PostProcessing/ProcessHelper.h"
|
||||||
|
|
||||||
const char* AICMD_MSG_DUMP_HELP =
|
const char *AICMD_MSG_DUMP_HELP =
|
||||||
"assimp dump <model> [<out>] [-b] [-s] [-z] [common parameters]\n"
|
"assimp dump <model> [<out>] [-b] [-s] [-z] [common parameters]\n"
|
||||||
"\t -b Binary output \n"
|
"\t -b Binary output \n"
|
||||||
"\t -s Shortened \n"
|
"\t -s Shortened \n"
|
||||||
"\t -z Compressed \n"
|
"\t -z Compressed \n"
|
||||||
"\t[See the assimp_cmd docs for a full list of all common parameters] \n"
|
"\t[See the assimp_cmd docs for a full list of all common parameters] \n"
|
||||||
"\t -cfast Fast post processing preset, runs just a few important steps \n"
|
"\t -cfast Fast post processing preset, runs just a few important steps \n"
|
||||||
"\t -cdefault Default post processing: runs all recommended steps\n"
|
"\t -cdefault Default post processing: runs all recommended steps\n"
|
||||||
"\t -cfull Fires almost all post processing steps \n"
|
"\t -cfull Fires almost all post processing steps \n";
|
||||||
;
|
|
||||||
|
|
||||||
#include "Common/assbin_chunks.h"
|
#include "Common/assbin_chunks.h"
|
||||||
#include <assimp/DefaultIOSystem.h>
|
#include <assimp/DefaultIOSystem.h>
|
||||||
|
@ -66,107 +65,100 @@ const char* AICMD_MSG_DUMP_HELP =
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
FILE* out = NULL;
|
FILE *out = NULL;
|
||||||
bool shortened = false;
|
bool shortened = false;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
int Assimp_Dump (const char* const* params, unsigned int num)
|
int Assimp_Dump(const char *const *params, unsigned int num) {
|
||||||
{
|
const char *fail = "assimp dump: Invalid number of arguments. "
|
||||||
const char* fail = "assimp dump: Invalid number of arguments. "
|
"See \'assimp dump --help\'\r\n";
|
||||||
"See \'assimp dump --help\'\r\n";
|
|
||||||
|
|
||||||
// --help
|
// --help
|
||||||
if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) {
|
if (!strcmp(params[0], "-h") || !strcmp(params[0], "--help") || !strcmp(params[0], "-?")) {
|
||||||
printf("%s",AICMD_MSG_DUMP_HELP);
|
printf("%s", AICMD_MSG_DUMP_HELP);
|
||||||
return AssimpCmdError::Success;
|
return AssimpCmdError::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// asssimp dump in out [options]
|
// assimp dump in out [options]
|
||||||
if (num < 1) {
|
if (num < 1) {
|
||||||
printf("%s", fail);
|
printf("%s", fail);
|
||||||
return AssimpCmdError::InvalidNumberOfArguments;
|
return AssimpCmdError::InvalidNumberOfArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string in = std::string(params[0]);
|
std::string in = std::string(params[0]);
|
||||||
std::string out = (num > 1 ? std::string(params[1]) : std::string("-"));
|
std::string cur_out = (num > 1 ? std::string(params[1]) : std::string("-"));
|
||||||
|
|
||||||
// store full command line
|
// store full command line
|
||||||
std::string cmd;
|
std::string cmd;
|
||||||
for (unsigned int i = (out[0] == '-' ? 1 : 2); i < num;++i) {
|
for (unsigned int i = (cur_out[0] == '-' ? 1 : 2); i < num; ++i) {
|
||||||
if (!params[i])continue;
|
if (!params[i]) continue;
|
||||||
cmd.append(params[i]);
|
cmd.append(params[i]);
|
||||||
cmd.append(" ");
|
cmd.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// get import flags
|
// get import flags
|
||||||
ImportData import;
|
ImportData import;
|
||||||
ProcessStandardArguments(import,params+1,num-1);
|
ProcessStandardArguments(import, params + 1, num - 1);
|
||||||
|
|
||||||
bool binary = false, shortened = false,compressed=false;
|
bool binary = false, cur_shortened = false, compressed = false;
|
||||||
|
|
||||||
// process other flags
|
// process other flags
|
||||||
for (unsigned int i = 1; i < num;++i) {
|
for (unsigned int i = 1; i < num; ++i) {
|
||||||
if (!params[i])continue;
|
if (!params[i]) continue;
|
||||||
if (!strcmp( params[i], "-b") || !strcmp( params[i], "--binary")) {
|
if (!strcmp(params[i], "-b") || !strcmp(params[i], "--binary")) {
|
||||||
binary = true;
|
binary = true;
|
||||||
}
|
} else if (!strcmp(params[i], "-s") || !strcmp(params[i], "--short")) {
|
||||||
else if (!strcmp( params[i], "-s") || !strcmp( params[i], "--short")) {
|
cur_shortened = true;
|
||||||
shortened = true;
|
} else if (!strcmp(params[i], "-z") || !strcmp(params[i], "--compressed")) {
|
||||||
}
|
compressed = true;
|
||||||
else if (!strcmp( params[i], "-z") || !strcmp( params[i], "--compressed")) {
|
}
|
||||||
compressed = true;
|
|
||||||
}
|
|
||||||
#if 0
|
#if 0
|
||||||
else if (i > 2 || params[i][0] == '-') {
|
else if (i > 2 || params[i][0] == '-') {
|
||||||
::printf("Unknown parameter: %s\n",params[i]);
|
::printf("Unknown parameter: %s\n",params[i]);
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out[0] == '-') {
|
if (cur_out[0] == '-') {
|
||||||
// take file name from input file
|
// take file name from input file
|
||||||
std::string::size_type s = in.find_last_of('.');
|
std::string::size_type s = in.find_last_of('.');
|
||||||
if (s == std::string::npos) {
|
if (s == std::string::npos) {
|
||||||
s = in.length();
|
s = in.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
out = in.substr(0,s);
|
cur_out = in.substr(0, s);
|
||||||
out.append((binary ? ".assbin" : ".assxml"));
|
cur_out.append((binary ? ".assbin" : ".assxml"));
|
||||||
if (shortened && binary) {
|
if (cur_shortened && binary) {
|
||||||
out.append(".regress");
|
cur_out.append(".regress");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// import the main model
|
// import the main model
|
||||||
const aiScene* scene = ImportModel(import,in);
|
const aiScene *scene = ImportModel(import, in);
|
||||||
if (!scene) {
|
if (!scene) {
|
||||||
printf("assimp dump: Unable to load input file %s\n",in.c_str());
|
printf("assimp dump: Unable to load input file %s\n", in.c_str());
|
||||||
return AssimpCmdError::FailedToLoadInputFile;
|
return AssimpCmdError::FailedToLoadInputFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Dump the main model, using the appropriate method.
|
// Dump the main model, using the appropriate method.
|
||||||
std::unique_ptr<IOSystem> pIOSystem(new DefaultIOSystem());
|
std::unique_ptr<IOSystem> pIOSystem(new DefaultIOSystem());
|
||||||
if (binary) {
|
if (binary) {
|
||||||
DumpSceneToAssbin(out.c_str(), cmd.c_str(), pIOSystem.get(),
|
DumpSceneToAssbin(cur_out.c_str(), cmd.c_str(), pIOSystem.get(),
|
||||||
scene, shortened, compressed);
|
scene, shortened, compressed);
|
||||||
}
|
} else {
|
||||||
else {
|
DumpSceneToAssxml(cur_out.c_str(), cmd.c_str(), pIOSystem.get(),
|
||||||
DumpSceneToAssxml(out.c_str(), cmd.c_str(), pIOSystem.get(),
|
scene, shortened);
|
||||||
scene, shortened);
|
}
|
||||||
}
|
} catch (const std::exception &e) {
|
||||||
}
|
printf("%s", ("assimp dump: " + std::string(e.what())).c_str());
|
||||||
catch (const std::exception& e) {
|
return AssimpCmdError::ExceptionWasRaised;
|
||||||
printf("%s", ("assimp dump: " + std::string(e.what())).c_str());
|
} catch (...) {
|
||||||
return AssimpCmdError::ExceptionWasRaised;
|
printf("assimp dump: An unknown exception occured.\n");
|
||||||
}
|
return AssimpCmdError::ExceptionWasRaised;
|
||||||
catch (...) {
|
}
|
||||||
printf("assimp dump: An unknown exception occured.\n");
|
|
||||||
return AssimpCmdError::ExceptionWasRaised;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("assimp dump: Wrote output dump %s\n",out.c_str());
|
printf("assimp dump: Wrote output dump %s\n", out.c_str());
|
||||||
return AssimpCmdError::Success;
|
return AssimpCmdError::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue