Refactor: Use LF for end of line
parent
0af1f0d32f
commit
4b0f9f3e89
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
/* This is just a small test to check whether Assimp's API compiles from C */
|
/* This is just a small test to check whether Assimp's API compiles from C */
|
||||||
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/version.h>
|
#include <assimp/version.h>
|
||||||
#include <assimp/config.h>
|
#include <assimp/config.h>
|
||||||
#include <assimp/cimport.h>
|
#include <assimp/cimport.h>
|
||||||
#include <assimp/cexport.h>
|
#include <assimp/cexport.h>
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
#include "../../include/assimp/DefaultLogger.hpp"
|
#include "../../include/assimp/DefaultLogger.hpp"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
// seed the randomizer with the current system time
|
// seed the randomizer with the current system time
|
||||||
time_t t;time(&t);
|
time_t t;time(&t);
|
||||||
srand((unsigned int)t);
|
srand((unsigned int)t);
|
||||||
|
|
||||||
// ............................................................................
|
// ............................................................................
|
||||||
|
|
||||||
// create a logger from both CPP
|
// create a logger from both CPP
|
||||||
Assimp::DefaultLogger::create("AssimpLog_Cpp.txt",Assimp::Logger::VERBOSE,
|
Assimp::DefaultLogger::create("AssimpLog_Cpp.txt",Assimp::Logger::VERBOSE,
|
||||||
aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE);
|
aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE);
|
||||||
|
|
||||||
// .. and C. They should smoothly work together
|
// .. and C. They should smoothly work together
|
||||||
aiEnableVerboseLogging(AI_TRUE);
|
aiEnableVerboseLogging(AI_TRUE);
|
||||||
aiLogStream logstream= aiGetPredefinedLogStream(aiDefaultLogStream_FILE, "AssimpLog_C.txt");
|
aiLogStream logstream= aiGetPredefinedLogStream(aiDefaultLogStream_FILE, "AssimpLog_C.txt");
|
||||||
aiAttachLogStream(&logstream);
|
aiAttachLogStream(&logstream);
|
||||||
|
|
||||||
int result = RUN_ALL_TESTS();
|
int result = RUN_ALL_TESTS();
|
||||||
|
|
||||||
// ............................................................................
|
// ............................................................................
|
||||||
// but shutdown must be done from C to ensure proper deallocation
|
// but shutdown must be done from C to ensure proper deallocation
|
||||||
aiDetachAllLogStreams();
|
aiDetachAllLogStreams();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
|
|
||||||
|
|
||||||
// #ifndef ASSIMP_BUILD_SINGLETHREADED
|
// #ifndef ASSIMP_BUILD_SINGLETHREADED
|
||||||
// # include <boost/thread.hpp>
|
// # include <boost/thread.hpp>
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// We need to be sure to have the same STL settings as Assimp
|
// We need to be sure to have the same STL settings as Assimp
|
||||||
|
|
||||||
#include <assimp/cimport.h>
|
#include <assimp/cimport.h>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
|
|
|
@ -1,84 +1,84 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/cexport.h>
|
#include <assimp/cexport.h>
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
class ExporterTest : public ::testing::Test {
|
class ExporterTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp()
|
virtual void SetUp()
|
||||||
{
|
{
|
||||||
ex = new Assimp::Exporter();
|
ex = new Assimp::Exporter();
|
||||||
im = new Assimp::Importer();
|
im = new Assimp::Importer();
|
||||||
|
|
||||||
pTest = im->ReadFile("../../test/models/X/test.x",0);
|
pTest = im->ReadFile("../../test/models/X/test.x",0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown()
|
virtual void TearDown()
|
||||||
{
|
{
|
||||||
delete ex;
|
delete ex;
|
||||||
delete im;
|
delete im;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
const aiScene* pTest;
|
const aiScene* pTest;
|
||||||
Assimp::Exporter* ex;
|
Assimp::Exporter* ex;
|
||||||
Assimp::Importer* im;
|
Assimp::Importer* im;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ExporterTest, testExportToFile)
|
TEST_F(ExporterTest, testExportToFile)
|
||||||
{
|
{
|
||||||
const char* file = "unittest_output.dae";
|
const char* file = "unittest_output.dae";
|
||||||
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
|
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
|
||||||
|
|
||||||
// check if we can read it again
|
// check if we can read it again
|
||||||
EXPECT_TRUE(im->ReadFile(file,0));
|
EXPECT_TRUE(im->ReadFile(file,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ExporterTest, testExportToBlob)
|
TEST_F(ExporterTest, testExportToBlob)
|
||||||
{
|
{
|
||||||
const aiExportDataBlob* blob = ex->ExportToBlob(pTest,"collada");
|
const aiExportDataBlob* blob = ex->ExportToBlob(pTest,"collada");
|
||||||
ASSERT_TRUE(blob);
|
ASSERT_TRUE(blob);
|
||||||
EXPECT_TRUE(blob->data);
|
EXPECT_TRUE(blob->data);
|
||||||
EXPECT_GT(blob->size, 0U);
|
EXPECT_GT(blob->size, 0U);
|
||||||
EXPECT_EQ(0U, blob->name.length);
|
EXPECT_EQ(0U, blob->name.length);
|
||||||
|
|
||||||
// XXX test chained blobs (i.e. obj file with accompanying mtl script)
|
// XXX test chained blobs (i.e. obj file with accompanying mtl script)
|
||||||
|
|
||||||
// check if we can read it again
|
// check if we can read it again
|
||||||
EXPECT_TRUE(im->ReadFileFromMemory(blob->data,blob->size,0,"dae"));
|
EXPECT_TRUE(im->ReadFileFromMemory(blob->data,blob->size,0,"dae"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ExporterTest, testCppExportInterface)
|
TEST_F(ExporterTest, testCppExportInterface)
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(ex->GetExportFormatCount() > 0);
|
EXPECT_TRUE(ex->GetExportFormatCount() > 0);
|
||||||
for(size_t i = 0; i < ex->GetExportFormatCount(); ++i) {
|
for(size_t i = 0; i < ex->GetExportFormatCount(); ++i) {
|
||||||
const aiExportFormatDesc* const desc = ex->GetExportFormatDescription(i);
|
const aiExportFormatDesc* const desc = ex->GetExportFormatDescription(i);
|
||||||
ASSERT_TRUE(desc);
|
ASSERT_TRUE(desc);
|
||||||
EXPECT_TRUE(desc->description && strlen(desc->description));
|
EXPECT_TRUE(desc->description && strlen(desc->description));
|
||||||
EXPECT_TRUE(desc->fileExtension && strlen(desc->fileExtension));
|
EXPECT_TRUE(desc->fileExtension && strlen(desc->fileExtension));
|
||||||
EXPECT_TRUE(desc->id && strlen(desc->id));
|
EXPECT_TRUE(desc->id && strlen(desc->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(ex->IsDefaultIOHandler());
|
EXPECT_TRUE(ex->IsDefaultIOHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ExporterTest, testCExportInterface)
|
TEST_F(ExporterTest, testCExportInterface)
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(aiGetExportFormatCount() > 0);
|
EXPECT_TRUE(aiGetExportFormatCount() > 0);
|
||||||
for(size_t i = 0; i < aiGetExportFormatCount(); ++i) {
|
for(size_t i = 0; i < aiGetExportFormatCount(); ++i) {
|
||||||
const aiExportFormatDesc* const desc = aiGetExportFormatDescription(i);
|
const aiExportFormatDesc* const desc = aiGetExportFormatDescription(i);
|
||||||
EXPECT_TRUE(desc);
|
EXPECT_TRUE(desc);
|
||||||
// rest has aleady been validated by testCppExportInterface
|
// rest has aleady been validated by testCppExportInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,108 +1,108 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <FindDegenerates.h>
|
#include <FindDegenerates.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class FindDegeneratesProcessTest : public ::testing::Test
|
class FindDegeneratesProcessTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
aiMesh* mesh;
|
aiMesh* mesh;
|
||||||
FindDegeneratesProcess* process;
|
FindDegeneratesProcess* process;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void FindDegeneratesProcessTest::SetUp()
|
void FindDegeneratesProcessTest::SetUp()
|
||||||
{
|
{
|
||||||
mesh = new aiMesh();
|
mesh = new aiMesh();
|
||||||
process = new FindDegeneratesProcess();
|
process = new FindDegeneratesProcess();
|
||||||
|
|
||||||
mesh->mNumFaces = 1000;
|
mesh->mNumFaces = 1000;
|
||||||
mesh->mFaces = new aiFace[1000];
|
mesh->mFaces = new aiFace[1000];
|
||||||
|
|
||||||
mesh->mNumVertices = 5000*2;
|
mesh->mNumVertices = 5000*2;
|
||||||
mesh->mVertices = new aiVector3D[5000*2];
|
mesh->mVertices = new aiVector3D[5000*2];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 5000; ++i) {
|
for (unsigned int i = 0; i < 5000; ++i) {
|
||||||
mesh->mVertices[i] = mesh->mVertices[i+5000] = aiVector3D((float)i);
|
mesh->mVertices[i] = mesh->mVertices[i+5000] = aiVector3D((float)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh->mPrimitiveTypes = aiPrimitiveType_LINE | aiPrimitiveType_POINT |
|
mesh->mPrimitiveTypes = aiPrimitiveType_LINE | aiPrimitiveType_POINT |
|
||||||
aiPrimitiveType_POLYGON | aiPrimitiveType_TRIANGLE;
|
aiPrimitiveType_POLYGON | aiPrimitiveType_TRIANGLE;
|
||||||
|
|
||||||
unsigned int numOut = 0, numFaces = 0;
|
unsigned int numOut = 0, numFaces = 0;
|
||||||
for (unsigned int i = 0; i < 1000; ++i) {
|
for (unsigned int i = 0; i < 1000; ++i) {
|
||||||
aiFace& f = mesh->mFaces[i];
|
aiFace& f = mesh->mFaces[i];
|
||||||
f.mNumIndices = (i % 5)+1; // between 1 and 5
|
f.mNumIndices = (i % 5)+1; // between 1 and 5
|
||||||
f.mIndices = new unsigned int[f.mNumIndices];
|
f.mIndices = new unsigned int[f.mNumIndices];
|
||||||
bool had = false;
|
bool had = false;
|
||||||
for (unsigned int n = 0; n < f.mNumIndices;++n) {
|
for (unsigned int n = 0; n < f.mNumIndices;++n) {
|
||||||
// FIXME
|
// FIXME
|
||||||
#if 0
|
#if 0
|
||||||
// some duplicate indices
|
// some duplicate indices
|
||||||
if ( n && n == (i / 200)+1) {
|
if ( n && n == (i / 200)+1) {
|
||||||
f.mIndices[n] = f.mIndices[n-1];
|
f.mIndices[n] = f.mIndices[n-1];
|
||||||
had = true;
|
had = true;
|
||||||
}
|
}
|
||||||
// and some duplicate vertices
|
// and some duplicate vertices
|
||||||
#endif
|
#endif
|
||||||
if (n && i % 2 && 0 == n % 2) {
|
if (n && i % 2 && 0 == n % 2) {
|
||||||
f.mIndices[n] = f.mIndices[n-1]+5000;
|
f.mIndices[n] = f.mIndices[n-1]+5000;
|
||||||
had = true;
|
had = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
f.mIndices[n] = numOut++;
|
f.mIndices[n] = numOut++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!had)
|
if (!had)
|
||||||
++numFaces;
|
++numFaces;
|
||||||
}
|
}
|
||||||
mesh->mNumUVComponents[0] = numOut;
|
mesh->mNumUVComponents[0] = numOut;
|
||||||
mesh->mNumUVComponents[1] = numFaces;
|
mesh->mNumUVComponents[1] = numFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void FindDegeneratesProcessTest::TearDown()
|
void FindDegeneratesProcessTest::TearDown()
|
||||||
{
|
{
|
||||||
delete mesh;
|
delete mesh;
|
||||||
delete process;
|
delete process;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(FindDegeneratesProcessTest, testDegeneratesDetection)
|
TEST_F(FindDegeneratesProcessTest, testDegeneratesDetection)
|
||||||
{
|
{
|
||||||
process->EnableInstantRemoval(false);
|
process->EnableInstantRemoval(false);
|
||||||
process->ExecuteOnMesh(mesh);
|
process->ExecuteOnMesh(mesh);
|
||||||
|
|
||||||
unsigned int out = 0;
|
unsigned int out = 0;
|
||||||
for (unsigned int i = 0; i < 1000; ++i) {
|
for (unsigned int i = 0; i < 1000; ++i) {
|
||||||
aiFace& f = mesh->mFaces[i];
|
aiFace& f = mesh->mFaces[i];
|
||||||
out += f.mNumIndices;
|
out += f.mNumIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_EQ(1000U, mesh->mNumFaces);
|
EXPECT_EQ(1000U, mesh->mNumFaces);
|
||||||
EXPECT_EQ(10000U, mesh->mNumVertices);
|
EXPECT_EQ(10000U, mesh->mNumVertices);
|
||||||
EXPECT_EQ(out, mesh->mNumUVComponents[0]);
|
EXPECT_EQ(out, mesh->mNumUVComponents[0]);
|
||||||
EXPECT_EQ(static_cast<unsigned int>(
|
EXPECT_EQ(static_cast<unsigned int>(
|
||||||
aiPrimitiveType_LINE | aiPrimitiveType_POINT |
|
aiPrimitiveType_LINE | aiPrimitiveType_POINT |
|
||||||
aiPrimitiveType_POLYGON | aiPrimitiveType_TRIANGLE),
|
aiPrimitiveType_POLYGON | aiPrimitiveType_TRIANGLE),
|
||||||
mesh->mPrimitiveTypes);
|
mesh->mPrimitiveTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(FindDegeneratesProcessTest, testDegeneratesRemoval)
|
TEST_F(FindDegeneratesProcessTest, testDegeneratesRemoval)
|
||||||
{
|
{
|
||||||
process->EnableInstantRemoval(true);
|
process->EnableInstantRemoval(true);
|
||||||
process->ExecuteOnMesh(mesh);
|
process->ExecuteOnMesh(mesh);
|
||||||
|
|
||||||
EXPECT_EQ(mesh->mNumUVComponents[1], mesh->mNumFaces);
|
EXPECT_EQ(mesh->mNumUVComponents[1], mesh->mNumFaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,98 +1,98 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <FindInvalidDataProcess.h>
|
#include <FindInvalidDataProcess.h>
|
||||||
#include "../../include/assimp/mesh.h"
|
#include "../../include/assimp/mesh.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class FindInvalidDataProcessTest : public ::testing::Test
|
class FindInvalidDataProcessTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
aiMesh* pcMesh;
|
aiMesh* pcMesh;
|
||||||
FindInvalidDataProcess* piProcess;
|
FindInvalidDataProcess* piProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void FindInvalidDataProcessTest::SetUp()
|
void FindInvalidDataProcessTest::SetUp()
|
||||||
{
|
{
|
||||||
ASSERT_TRUE( AI_MAX_NUMBER_OF_TEXTURECOORDS >= 3);
|
ASSERT_TRUE( AI_MAX_NUMBER_OF_TEXTURECOORDS >= 3);
|
||||||
|
|
||||||
piProcess = new FindInvalidDataProcess();
|
piProcess = new FindInvalidDataProcess();
|
||||||
pcMesh = new aiMesh();
|
pcMesh = new aiMesh();
|
||||||
|
|
||||||
pcMesh->mNumVertices = 1000;
|
pcMesh->mNumVertices = 1000;
|
||||||
pcMesh->mVertices = new aiVector3D[1000];
|
pcMesh->mVertices = new aiVector3D[1000];
|
||||||
for (unsigned int i = 0; i < 1000;++i)
|
for (unsigned int i = 0; i < 1000;++i)
|
||||||
pcMesh->mVertices[i] = aiVector3D((float)i);
|
pcMesh->mVertices[i] = aiVector3D((float)i);
|
||||||
|
|
||||||
pcMesh->mNormals = new aiVector3D[1000];
|
pcMesh->mNormals = new aiVector3D[1000];
|
||||||
for (unsigned int i = 0; i < 1000;++i)
|
for (unsigned int i = 0; i < 1000;++i)
|
||||||
pcMesh->mNormals[i] = aiVector3D((float)i+1);
|
pcMesh->mNormals[i] = aiVector3D((float)i+1);
|
||||||
|
|
||||||
pcMesh->mTangents = new aiVector3D[1000];
|
pcMesh->mTangents = new aiVector3D[1000];
|
||||||
for (unsigned int i = 0; i < 1000;++i)
|
for (unsigned int i = 0; i < 1000;++i)
|
||||||
pcMesh->mTangents[i] = aiVector3D((float)i);
|
pcMesh->mTangents[i] = aiVector3D((float)i);
|
||||||
|
|
||||||
pcMesh->mBitangents = new aiVector3D[1000];
|
pcMesh->mBitangents = new aiVector3D[1000];
|
||||||
for (unsigned int i = 0; i < 1000;++i)
|
for (unsigned int i = 0; i < 1000;++i)
|
||||||
pcMesh->mBitangents[i] = aiVector3D((float)i);
|
pcMesh->mBitangents[i] = aiVector3D((float)i);
|
||||||
|
|
||||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a)
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a)
|
||||||
{
|
{
|
||||||
pcMesh->mTextureCoords[a] = new aiVector3D[1000];
|
pcMesh->mTextureCoords[a] = new aiVector3D[1000];
|
||||||
for (unsigned int i = 0; i < 1000;++i)
|
for (unsigned int i = 0; i < 1000;++i)
|
||||||
pcMesh->mTextureCoords[a][i] = aiVector3D((float)i);
|
pcMesh->mTextureCoords[a][i] = aiVector3D((float)i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void FindInvalidDataProcessTest::TearDown()
|
void FindInvalidDataProcessTest::TearDown()
|
||||||
{
|
{
|
||||||
delete piProcess;
|
delete piProcess;
|
||||||
delete pcMesh;
|
delete pcMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(FindInvalidDataProcessTest, testStepNegativeResult)
|
TEST_F(FindInvalidDataProcessTest, testStepNegativeResult)
|
||||||
{
|
{
|
||||||
::memset(pcMesh->mNormals,0,pcMesh->mNumVertices*sizeof(aiVector3D));
|
::memset(pcMesh->mNormals,0,pcMesh->mNumVertices*sizeof(aiVector3D));
|
||||||
::memset(pcMesh->mBitangents,0,pcMesh->mNumVertices*sizeof(aiVector3D));
|
::memset(pcMesh->mBitangents,0,pcMesh->mNumVertices*sizeof(aiVector3D));
|
||||||
|
|
||||||
pcMesh->mTextureCoords[2][455] = aiVector3D( std::numeric_limits<float>::quiet_NaN() );
|
pcMesh->mTextureCoords[2][455] = aiVector3D( std::numeric_limits<float>::quiet_NaN() );
|
||||||
|
|
||||||
piProcess->ProcessMesh(pcMesh);
|
piProcess->ProcessMesh(pcMesh);
|
||||||
|
|
||||||
EXPECT_TRUE(NULL != pcMesh->mVertices);
|
EXPECT_TRUE(NULL != pcMesh->mVertices);
|
||||||
EXPECT_TRUE(NULL == pcMesh->mNormals);
|
EXPECT_TRUE(NULL == pcMesh->mNormals);
|
||||||
EXPECT_TRUE(NULL == pcMesh->mTangents);
|
EXPECT_TRUE(NULL == pcMesh->mTangents);
|
||||||
EXPECT_TRUE(NULL == pcMesh->mBitangents);
|
EXPECT_TRUE(NULL == pcMesh->mBitangents);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 2;++i)
|
for (unsigned int i = 0; i < 2;++i)
|
||||||
EXPECT_TRUE(NULL != pcMesh->mTextureCoords[i]);
|
EXPECT_TRUE(NULL != pcMesh->mTextureCoords[i]);
|
||||||
|
|
||||||
for (unsigned int i = 2; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
|
for (unsigned int i = 2; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
|
||||||
EXPECT_TRUE(NULL == pcMesh->mTextureCoords[i]);
|
EXPECT_TRUE(NULL == pcMesh->mTextureCoords[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(FindInvalidDataProcessTest, testStepPositiveResult)
|
TEST_F(FindInvalidDataProcessTest, testStepPositiveResult)
|
||||||
{
|
{
|
||||||
piProcess->ProcessMesh(pcMesh);
|
piProcess->ProcessMesh(pcMesh);
|
||||||
|
|
||||||
EXPECT_TRUE(NULL != pcMesh->mVertices);
|
EXPECT_TRUE(NULL != pcMesh->mVertices);
|
||||||
|
|
||||||
EXPECT_TRUE(NULL != pcMesh->mNormals);
|
EXPECT_TRUE(NULL != pcMesh->mNormals);
|
||||||
EXPECT_TRUE(NULL != pcMesh->mTangents);
|
EXPECT_TRUE(NULL != pcMesh->mTangents);
|
||||||
EXPECT_TRUE(NULL != pcMesh->mBitangents);
|
EXPECT_TRUE(NULL != pcMesh->mBitangents);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
|
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
|
||||||
EXPECT_TRUE(NULL != pcMesh->mTextureCoords[i]);
|
EXPECT_TRUE(NULL != pcMesh->mTextureCoords[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
|
@ -1,52 +1,52 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <GenVertexNormalsProcess.h>
|
#include <GenVertexNormalsProcess.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class GenNormalsTest : public ::testing::Test
|
class GenNormalsTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
aiMesh* pcMesh;
|
aiMesh* pcMesh;
|
||||||
GenVertexNormalsProcess* piProcess;
|
GenVertexNormalsProcess* piProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void GenNormalsTest::SetUp()
|
void GenNormalsTest::SetUp()
|
||||||
{
|
{
|
||||||
piProcess = new GenVertexNormalsProcess();
|
piProcess = new GenVertexNormalsProcess();
|
||||||
pcMesh = new aiMesh();
|
pcMesh = new aiMesh();
|
||||||
pcMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
pcMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
||||||
pcMesh->mNumFaces = 1;
|
pcMesh->mNumFaces = 1;
|
||||||
pcMesh->mFaces = new aiFace[1];
|
pcMesh->mFaces = new aiFace[1];
|
||||||
pcMesh->mFaces[0].mIndices = new unsigned int[pcMesh->mFaces[0].mNumIndices = 3];
|
pcMesh->mFaces[0].mIndices = new unsigned int[pcMesh->mFaces[0].mNumIndices = 3];
|
||||||
pcMesh->mFaces[0].mIndices[0] = 0;
|
pcMesh->mFaces[0].mIndices[0] = 0;
|
||||||
pcMesh->mFaces[0].mIndices[1] = 1;
|
pcMesh->mFaces[0].mIndices[1] = 1;
|
||||||
pcMesh->mFaces[0].mIndices[2] = 1;
|
pcMesh->mFaces[0].mIndices[2] = 1;
|
||||||
pcMesh->mNumVertices = 3;
|
pcMesh->mNumVertices = 3;
|
||||||
pcMesh->mVertices = new aiVector3D[3];
|
pcMesh->mVertices = new aiVector3D[3];
|
||||||
pcMesh->mVertices[0] = aiVector3D(0.0f,1.0f,6.0f);
|
pcMesh->mVertices[0] = aiVector3D(0.0f,1.0f,6.0f);
|
||||||
pcMesh->mVertices[1] = aiVector3D(2.0f,3.0f,1.0f);
|
pcMesh->mVertices[1] = aiVector3D(2.0f,3.0f,1.0f);
|
||||||
pcMesh->mVertices[2] = aiVector3D(3.0f,2.0f,4.0f);
|
pcMesh->mVertices[2] = aiVector3D(3.0f,2.0f,4.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void GenNormalsTest::TearDown()
|
void GenNormalsTest::TearDown()
|
||||||
{
|
{
|
||||||
delete this->pcMesh;
|
delete this->pcMesh;
|
||||||
delete this->piProcess;
|
delete this->piProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(GenNormalsTest, testSimpleTriangle)
|
TEST_F(GenNormalsTest, testSimpleTriangle)
|
||||||
{
|
{
|
||||||
piProcess->GenMeshVertexNormals(pcMesh, 0);
|
piProcess->GenMeshVertexNormals(pcMesh, 0);
|
||||||
EXPECT_TRUE(pcMesh->mNormals != NULL);
|
EXPECT_TRUE(pcMesh->mNormals != NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,231 +1,231 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include "../../include/assimp/postprocess.h"
|
#include "../../include/assimp/postprocess.h"
|
||||||
#include "../../include/assimp/scene.h"
|
#include "../../include/assimp/scene.h"
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <BaseImporter.h>
|
#include <BaseImporter.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class ImporterTest : public ::testing::Test
|
class ImporterTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp() { pImp = new Importer(); }
|
virtual void SetUp() { pImp = new Importer(); }
|
||||||
virtual void TearDown() { delete pImp; }
|
virtual void TearDown() { delete pImp; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Importer* pImp;
|
Importer* pImp;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define InputData_BLOCK_SIZE 1310
|
#define InputData_BLOCK_SIZE 1310
|
||||||
|
|
||||||
// test data for Importer::ReadFileFromMemory() - ./test/3DS/CameraRollAnim.3ds
|
// test data for Importer::ReadFileFromMemory() - ./test/3DS/CameraRollAnim.3ds
|
||||||
static unsigned char InputData_abRawBlock[1310] = {
|
static unsigned char InputData_abRawBlock[1310] = {
|
||||||
77,77,30,5,0,0,2,0,10,0,0,0,3,0,0,0,61,61,91,3,0,0,62,61,10,0,0,0,3,0,0,0,
|
77,77,30,5,0,0,2,0,10,0,0,0,3,0,0,0,61,61,91,3,0,0,62,61,10,0,0,0,3,0,0,0,
|
||||||
0,1,10,0,0,0,0,0,128,63,0,64,254,2,0,0,66,111,120,48,49,0,0,65,242,2,0,0,16,65,64,1,
|
0,1,10,0,0,0,0,0,128,63,0,64,254,2,0,0,66,111,120,48,49,0,0,65,242,2,0,0,16,65,64,1,
|
||||||
0,0,26,0,102,74,198,193,102,74,198,193,0,0,0,0,205,121,55,66,102,74,198,193,0,0,0,0,102,74,198,193,
|
0,0,26,0,102,74,198,193,102,74,198,193,0,0,0,0,205,121,55,66,102,74,198,193,0,0,0,0,102,74,198,193,
|
||||||
138,157,184,65,0,0,0,0,205,121,55,66,138,157,184,65,0,0,0,0,102,74,198,193,102,74,198,193,90,252,26,66,
|
138,157,184,65,0,0,0,0,205,121,55,66,138,157,184,65,0,0,0,0,102,74,198,193,102,74,198,193,90,252,26,66,
|
||||||
205,121,55,66,102,74,198,193,90,252,26,66,102,74,198,193,138,157,184,65,90,252,26,66,205,121,55,66,138,157,184,65,
|
205,121,55,66,102,74,198,193,90,252,26,66,102,74,198,193,138,157,184,65,90,252,26,66,205,121,55,66,138,157,184,65,
|
||||||
90,252,26,66,102,74,198,193,102,74,198,193,0,0,0,0,205,121,55,66,102,74,198,193,0,0,0,0,205,121,55,66,
|
90,252,26,66,102,74,198,193,102,74,198,193,0,0,0,0,205,121,55,66,102,74,198,193,0,0,0,0,205,121,55,66,
|
||||||
102,74,198,193,90,252,26,66,205,121,55,66,102,74,198,193,90,252,26,66,102,74,198,193,102,74,198,193,90,252,26,66,
|
102,74,198,193,90,252,26,66,205,121,55,66,102,74,198,193,90,252,26,66,102,74,198,193,102,74,198,193,90,252,26,66,
|
||||||
102,74,198,193,102,74,198,193,0,0,0,0,205,121,55,66,138,157,184,65,0,0,0,0,205,121,55,66,102,74,198,193,
|
102,74,198,193,102,74,198,193,0,0,0,0,205,121,55,66,138,157,184,65,0,0,0,0,205,121,55,66,102,74,198,193,
|
||||||
90,252,26,66,205,121,55,66,138,157,184,65,0,0,0,0,102,74,198,193,138,157,184,65,0,0,0,0,102,74,198,193,
|
90,252,26,66,205,121,55,66,138,157,184,65,0,0,0,0,102,74,198,193,138,157,184,65,0,0,0,0,102,74,198,193,
|
||||||
138,157,184,65,90,252,26,66,102,74,198,193,138,157,184,65,90,252,26,66,205,121,55,66,138,157,184,65,90,252,26,66,
|
138,157,184,65,90,252,26,66,102,74,198,193,138,157,184,65,90,252,26,66,205,121,55,66,138,157,184,65,90,252,26,66,
|
||||||
205,121,55,66,138,157,184,65,0,0,0,0,102,74,198,193,138,157,184,65,0,0,0,0,102,74,198,193,102,74,198,193,
|
205,121,55,66,138,157,184,65,0,0,0,0,102,74,198,193,138,157,184,65,0,0,0,0,102,74,198,193,102,74,198,193,
|
||||||
90,252,26,66,102,74,198,193,102,74,198,193,90,252,26,66,102,74,198,193,138,157,184,65,0,0,0,0,64,65,216,0,
|
90,252,26,66,102,74,198,193,102,74,198,193,90,252,26,66,102,74,198,193,138,157,184,65,0,0,0,0,64,65,216,0,
|
||||||
0,0,26,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,
|
0,0,26,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,
|
||||||
0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,
|
0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,
|
||||||
0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,
|
0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,
|
||||||
0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,
|
0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,
|
||||||
0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,
|
0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,
|
||||||
0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,
|
0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,
|
||||||
0,0,128,63,0,0,128,63,0,0,128,63,0,0,0,0,0,0,0,0,96,65,54,0,0,0,0,0,128,63,0,0,
|
0,0,128,63,0,0,128,63,0,0,128,63,0,0,0,0,0,0,0,0,96,65,54,0,0,0,0,0,128,63,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,53,169,
|
0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,53,169,
|
||||||
40,65,176,205,90,191,0,0,0,0,32,65,158,0,0,0,12,0,0,0,2,0,3,0,6,0,3,0,1,0,0,0,
|
40,65,176,205,90,191,0,0,0,0,32,65,158,0,0,0,12,0,0,0,2,0,3,0,6,0,3,0,1,0,0,0,
|
||||||
6,0,4,0,5,0,7,0,6,0,7,0,6,0,4,0,6,0,8,0,9,0,10,0,6,0,11,0,12,0,13,0,
|
6,0,4,0,5,0,7,0,6,0,7,0,6,0,4,0,6,0,8,0,9,0,10,0,6,0,11,0,12,0,13,0,
|
||||||
6,0,1,0,14,0,7,0,6,0,7,0,15,0,1,0,6,0,16,0,17,0,18,0,6,0,19,0,20,0,21,0,
|
6,0,1,0,14,0,7,0,6,0,7,0,15,0,1,0,6,0,16,0,17,0,18,0,6,0,19,0,20,0,21,0,
|
||||||
6,0,22,0,0,0,23,0,6,0,24,0,6,0,25,0,6,0,80,65,54,0,0,0,2,0,0,0,2,0,0,0,
|
6,0,22,0,0,0,23,0,6,0,24,0,6,0,25,0,6,0,80,65,54,0,0,0,2,0,0,0,2,0,0,0,
|
||||||
4,0,0,0,4,0,0,0,8,0,0,0,8,0,0,0,16,0,0,0,16,0,0,0,32,0,0,0,32,0,0,0,
|
4,0,0,0,4,0,0,0,8,0,0,0,8,0,0,0,16,0,0,0,16,0,0,0,32,0,0,0,32,0,0,0,
|
||||||
64,0,0,0,64,0,0,0,0,64,67,0,0,0,67,97,109,101,114,97,48,49,0,0,71,52,0,0,0,189,19,25,
|
64,0,0,0,64,0,0,0,0,64,67,0,0,0,67,97,109,101,114,97,48,49,0,0,71,52,0,0,0,189,19,25,
|
||||||
195,136,104,81,64,147,56,182,65,96,233,20,194,67,196,97,190,147,56,182,65,0,0,0,0,85,85,85,66,32,71,14,
|
195,136,104,81,64,147,56,182,65,96,233,20,194,67,196,97,190,147,56,182,65,0,0,0,0,85,85,85,66,32,71,14,
|
||||||
0,0,0,0,0,0,0,0,0,122,68,0,176,179,1,0,0,10,176,21,0,0,0,5,0,77,65,88,83,67,69,78,
|
0,0,0,0,0,0,0,0,0,122,68,0,176,179,1,0,0,10,176,21,0,0,0,5,0,77,65,88,83,67,69,78,
|
||||||
69,0,44,1,0,0,8,176,14,0,0,0,0,0,0,0,44,1,0,0,9,176,10,0,0,0,128,2,0,0,2,176,
|
69,0,44,1,0,0,8,176,14,0,0,0,0,0,0,0,44,1,0,0,9,176,10,0,0,0,128,2,0,0,2,176,
|
||||||
168,0,0,0,48,176,8,0,0,0,0,0,16,176,18,0,0,0,66,111,120,48,49,0,0,64,0,0,255,255,19,176,
|
168,0,0,0,48,176,8,0,0,0,0,0,16,176,18,0,0,0,66,111,120,48,49,0,0,64,0,0,255,255,19,176,
|
||||||
18,0,0,0,0,0,0,128,0,0,0,128,0,0,0,128,32,176,38,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
18,0,0,0,0,0,0,128,0,0,0,128,0,0,0,128,32,176,38,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
1,0,0,0,0,0,0,0,0,0,53,169,40,65,176,205,90,191,0,0,0,0,33,176,42,0,0,0,0,0,0,0,
|
1,0,0,0,0,0,0,0,0,0,53,169,40,65,176,205,90,191,0,0,0,0,33,176,42,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
34,176,38,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,
|
34,176,38,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,
|
||||||
128,63,0,0,128,63,3,176,143,0,0,0,48,176,8,0,0,0,1,0,16,176,21,0,0,0,67,97,109,101,114,97,
|
128,63,0,0,128,63,3,176,143,0,0,0,48,176,8,0,0,0,1,0,16,176,21,0,0,0,67,97,109,101,114,97,
|
||||||
48,49,0,0,64,0,0,255,255,32,176,38,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,
|
48,49,0,0,64,0,0,255,255,32,176,38,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,
|
||||||
0,0,0,189,19,25,195,136,104,81,64,147,56,182,65,35,176,30,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
|
0,0,0,189,19,25,195,136,104,81,64,147,56,182,65,35,176,30,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,52,66,36,176,40,0,0,0,0,0,0,0,0,0,120,0,0,0,2,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,52,66,36,176,40,0,0,0,0,0,0,0,0,0,120,0,0,0,2,0,0,
|
||||||
0,0,0,0,0,0,0,120,13,90,189,120,0,0,0,0,0,99,156,154,194,4,176,73,0,0,0,48,176,8,0,0,
|
0,0,0,0,0,0,0,120,13,90,189,120,0,0,0,0,0,99,156,154,194,4,176,73,0,0,0,48,176,8,0,0,
|
||||||
0,2,0,16,176,21,0,0,0,67,97,109,101,114,97,48,49,0,0,64,0,0,255,255,32,176,38,0,0,0,0,0,
|
0,2,0,16,176,21,0,0,0,67,97,109,101,114,97,48,49,0,0,64,0,0,255,255,32,176,38,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,96,233,20,194,67,196,97,190,147,56,182,65,
|
0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,96,233,20,194,67,196,97,190,147,56,182,65,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define AIUT_DEF_ERROR_TEXT "sorry, this is a test"
|
#define AIUT_DEF_ERROR_TEXT "sorry, this is a test"
|
||||||
|
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static const aiImporterDesc desc = {
|
||||||
"UNIT TEST - IMPORTER",
|
"UNIT TEST - IMPORTER",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"apple mac linux windows"
|
"apple mac linux windows"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TestPlugin : public BaseImporter
|
class TestPlugin : public BaseImporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual bool CanRead(
|
virtual bool CanRead(
|
||||||
const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*test*/) const
|
const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*test*/) const
|
||||||
{
|
{
|
||||||
std::string::size_type pos = pFile.find_last_of('.');
|
std::string::size_type pos = pFile.find_last_of('.');
|
||||||
// no file extension - can't read
|
// no file extension - can't read
|
||||||
if( pos == std::string::npos)
|
if( pos == std::string::npos)
|
||||||
return false;
|
return false;
|
||||||
std::string extension = pFile.substr( pos);
|
std::string extension = pFile.substr( pos);
|
||||||
|
|
||||||
// todo ... make case-insensitive
|
// todo ... make case-insensitive
|
||||||
return (extension == ".apple" || extension == ".mac" ||
|
return (extension == ".apple" || extension == ".mac" ||
|
||||||
extension == ".linux" || extension == ".windows" );
|
extension == ".linux" || extension == ".windows" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const aiImporterDesc* GetInfo () const
|
virtual const aiImporterDesc* GetInfo () const
|
||||||
{
|
{
|
||||||
return & desc;
|
return & desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void InternReadFile(
|
virtual void InternReadFile(
|
||||||
const std::string& /*pFile*/, aiScene* /*pScene*/, IOSystem* /*pIOHandler*/)
|
const std::string& /*pFile*/, aiScene* /*pScene*/, IOSystem* /*pIOHandler*/)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError(AIUT_DEF_ERROR_TEXT);
|
throw DeadlyImportError(AIUT_DEF_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testMemoryRead)
|
TEST_F(ImporterTest, testMemoryRead)
|
||||||
{
|
{
|
||||||
const aiScene* sc = pImp->ReadFileFromMemory(InputData_abRawBlock,InputData_BLOCK_SIZE,
|
const aiScene* sc = pImp->ReadFileFromMemory(InputData_abRawBlock,InputData_BLOCK_SIZE,
|
||||||
aiProcessPreset_TargetRealtime_Quality,"3ds");
|
aiProcessPreset_TargetRealtime_Quality,"3ds");
|
||||||
|
|
||||||
ASSERT_TRUE(sc != NULL);
|
ASSERT_TRUE(sc != NULL);
|
||||||
EXPECT_EQ(aiString("<3DSRoot>"), sc->mRootNode->mName);
|
EXPECT_EQ(aiString("<3DSRoot>"), sc->mRootNode->mName);
|
||||||
EXPECT_EQ(1U, sc->mNumMeshes);
|
EXPECT_EQ(1U, sc->mNumMeshes);
|
||||||
EXPECT_EQ(24U, sc->mMeshes[0]->mNumVertices);
|
EXPECT_EQ(24U, sc->mMeshes[0]->mNumVertices);
|
||||||
EXPECT_EQ(12U, sc->mMeshes[0]->mNumFaces);
|
EXPECT_EQ(12U, sc->mMeshes[0]->mNumFaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testIntProperty)
|
TEST_F(ImporterTest, testIntProperty)
|
||||||
{
|
{
|
||||||
bool b = pImp->SetPropertyInteger("quakquak",1503);
|
bool b = pImp->SetPropertyInteger("quakquak",1503);
|
||||||
EXPECT_FALSE(b);
|
EXPECT_FALSE(b);
|
||||||
EXPECT_EQ(1503, pImp->GetPropertyInteger("quakquak",0));
|
EXPECT_EQ(1503, pImp->GetPropertyInteger("quakquak",0));
|
||||||
EXPECT_EQ(314159, pImp->GetPropertyInteger("not_there",314159));
|
EXPECT_EQ(314159, pImp->GetPropertyInteger("not_there",314159));
|
||||||
|
|
||||||
b = pImp->SetPropertyInteger("quakquak",1504);
|
b = pImp->SetPropertyInteger("quakquak",1504);
|
||||||
EXPECT_TRUE(b);
|
EXPECT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testFloatProperty)
|
TEST_F(ImporterTest, testFloatProperty)
|
||||||
{
|
{
|
||||||
bool b = pImp->SetPropertyFloat("quakquak",1503.f);
|
bool b = pImp->SetPropertyFloat("quakquak",1503.f);
|
||||||
EXPECT_TRUE(!b);
|
EXPECT_TRUE(!b);
|
||||||
EXPECT_EQ(1503.f, pImp->GetPropertyFloat("quakquak",0.f));
|
EXPECT_EQ(1503.f, pImp->GetPropertyFloat("quakquak",0.f));
|
||||||
EXPECT_EQ(314159.f, pImp->GetPropertyFloat("not_there",314159.f));
|
EXPECT_EQ(314159.f, pImp->GetPropertyFloat("not_there",314159.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testStringProperty)
|
TEST_F(ImporterTest, testStringProperty)
|
||||||
{
|
{
|
||||||
bool b = pImp->SetPropertyString("quakquak","test");
|
bool b = pImp->SetPropertyString("quakquak","test");
|
||||||
EXPECT_TRUE(!b);
|
EXPECT_TRUE(!b);
|
||||||
EXPECT_EQ("test", pImp->GetPropertyString("quakquak","weghwekg"));
|
EXPECT_EQ("test", pImp->GetPropertyString("quakquak","weghwekg"));
|
||||||
EXPECT_EQ("ILoveYou", pImp->GetPropertyString("not_there","ILoveYou"));
|
EXPECT_EQ("ILoveYou", pImp->GetPropertyString("not_there","ILoveYou"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testPluginInterface)
|
TEST_F(ImporterTest, testPluginInterface)
|
||||||
{
|
{
|
||||||
pImp->RegisterLoader(new TestPlugin());
|
pImp->RegisterLoader(new TestPlugin());
|
||||||
EXPECT_TRUE(pImp->IsExtensionSupported(".apple"));
|
EXPECT_TRUE(pImp->IsExtensionSupported(".apple"));
|
||||||
EXPECT_TRUE(pImp->IsExtensionSupported(".mac"));
|
EXPECT_TRUE(pImp->IsExtensionSupported(".mac"));
|
||||||
EXPECT_TRUE(pImp->IsExtensionSupported("*.linux"));
|
EXPECT_TRUE(pImp->IsExtensionSupported("*.linux"));
|
||||||
EXPECT_TRUE(pImp->IsExtensionSupported("windows"));
|
EXPECT_TRUE(pImp->IsExtensionSupported("windows"));
|
||||||
EXPECT_TRUE(pImp->IsExtensionSupported(".x")); /* x and 3ds must be available in this Assimp build, of course! */
|
EXPECT_TRUE(pImp->IsExtensionSupported(".x")); /* x and 3ds must be available in this Assimp build, of course! */
|
||||||
EXPECT_TRUE(pImp->IsExtensionSupported(".3ds"));
|
EXPECT_TRUE(pImp->IsExtensionSupported(".3ds"));
|
||||||
EXPECT_FALSE(pImp->IsExtensionSupported("."));
|
EXPECT_FALSE(pImp->IsExtensionSupported("."));
|
||||||
|
|
||||||
TestPlugin* p = (TestPlugin*) pImp->GetImporter(".windows");
|
TestPlugin* p = (TestPlugin*) pImp->GetImporter(".windows");
|
||||||
ASSERT_TRUE(NULL != p);
|
ASSERT_TRUE(NULL != p);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
p->InternReadFile("",0,NULL);
|
p->InternReadFile("",0,NULL);
|
||||||
}
|
}
|
||||||
catch ( const DeadlyImportError& dead)
|
catch ( const DeadlyImportError& dead)
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(!strcmp(dead.what(),AIUT_DEF_ERROR_TEXT));
|
EXPECT_TRUE(!strcmp(dead.what(),AIUT_DEF_ERROR_TEXT));
|
||||||
|
|
||||||
// unregister the plugin and delete it
|
// unregister the plugin and delete it
|
||||||
pImp->UnregisterLoader(p);
|
pImp->UnregisterLoader(p);
|
||||||
delete p;
|
delete p;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EXPECT_TRUE(false); // control shouldn't reach this point
|
EXPECT_TRUE(false); // control shouldn't reach this point
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testExtensionCheck)
|
TEST_F(ImporterTest, testExtensionCheck)
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
pImp->GetExtensionList(s);
|
pImp->GetExtensionList(s);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testMultipleReads)
|
TEST_F(ImporterTest, testMultipleReads)
|
||||||
{
|
{
|
||||||
// see http://sourceforge.net/projects/assimp/forums/forum/817654/topic/3591099
|
// see http://sourceforge.net/projects/assimp/forums/forum/817654/topic/3591099
|
||||||
// Check whether reading and post-processing multiple times using
|
// Check whether reading and post-processing multiple times using
|
||||||
// the same objects is *generally* fine. This test doesn't target
|
// the same objects is *generally* fine. This test doesn't target
|
||||||
// importers. Testing post-processing stability is the main point.
|
// importers. Testing post-processing stability is the main point.
|
||||||
|
|
||||||
const unsigned int flags =
|
const unsigned int flags =
|
||||||
aiProcess_Triangulate |
|
aiProcess_Triangulate |
|
||||||
aiProcess_JoinIdenticalVertices |
|
aiProcess_JoinIdenticalVertices |
|
||||||
aiProcess_GenSmoothNormals |
|
aiProcess_GenSmoothNormals |
|
||||||
aiProcess_ValidateDataStructure |
|
aiProcess_ValidateDataStructure |
|
||||||
aiProcess_RemoveRedundantMaterials |
|
aiProcess_RemoveRedundantMaterials |
|
||||||
aiProcess_SortByPType |
|
aiProcess_SortByPType |
|
||||||
aiProcess_FindDegenerates |
|
aiProcess_FindDegenerates |
|
||||||
aiProcess_FindInvalidData |
|
aiProcess_FindInvalidData |
|
||||||
aiProcess_GenUVCoords |
|
aiProcess_GenUVCoords |
|
||||||
aiProcess_OptimizeMeshes |
|
aiProcess_OptimizeMeshes |
|
||||||
aiProcess_OptimizeGraph;
|
aiProcess_OptimizeGraph;
|
||||||
|
|
||||||
EXPECT_TRUE(pImp->ReadFile("../test/models/X/test.x",flags));
|
EXPECT_TRUE(pImp->ReadFile("../test/models/X/test.x",flags));
|
||||||
//EXPECT_TRUE(pImp->ReadFile("../../test/models/X/dwarf.x",flags)); # is in nonbsd
|
//EXPECT_TRUE(pImp->ReadFile("../../test/models/X/dwarf.x",flags)); # is in nonbsd
|
||||||
EXPECT_TRUE(pImp->ReadFile("../test/models/X/Testwuson.X",flags));
|
EXPECT_TRUE(pImp->ReadFile("../test/models/X/Testwuson.X",flags));
|
||||||
EXPECT_TRUE(pImp->ReadFile("../test/models/X/anim_test.x",flags));
|
EXPECT_TRUE(pImp->ReadFile("../test/models/X/anim_test.x",flags));
|
||||||
//EXPECT_TRUE(pImp->ReadFile("../../test/models/X/dwarf.x",flags)); # is in nonbsd
|
//EXPECT_TRUE(pImp->ReadFile("../../test/models/X/dwarf.x",flags)); # is in nonbsd
|
||||||
|
|
||||||
EXPECT_TRUE(pImp->ReadFile("../test/models/X/anim_test.x",flags));
|
EXPECT_TRUE(pImp->ReadFile("../test/models/X/anim_test.x",flags));
|
||||||
EXPECT_TRUE(pImp->ReadFile("../test/models/X/BCN_Epileptic.X",flags));
|
EXPECT_TRUE(pImp->ReadFile("../test/models/X/BCN_Epileptic.X",flags));
|
||||||
//EXPECT_TRUE(pImp->ReadFile("../../test/models/X/dwarf.x",flags)); # is in nonbsd
|
//EXPECT_TRUE(pImp->ReadFile("../../test/models/X/dwarf.x",flags)); # is in nonbsd
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
|
@ -1,105 +1,105 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <JoinVerticesProcess.h>
|
#include <JoinVerticesProcess.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class JoinVerticesTest : public ::testing::Test
|
class JoinVerticesTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
JoinVerticesProcess* piProcess;
|
JoinVerticesProcess* piProcess;
|
||||||
aiMesh* pcMesh;
|
aiMesh* pcMesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void JoinVerticesTest::SetUp()
|
void JoinVerticesTest::SetUp()
|
||||||
{
|
{
|
||||||
// construct the process
|
// construct the process
|
||||||
piProcess = new JoinVerticesProcess();
|
piProcess = new JoinVerticesProcess();
|
||||||
|
|
||||||
// create a quite small mesh for testing purposes -
|
// create a quite small mesh for testing purposes -
|
||||||
// the mesh itself is *something* but it has redundant vertices
|
// the mesh itself is *something* but it has redundant vertices
|
||||||
pcMesh = new aiMesh();
|
pcMesh = new aiMesh();
|
||||||
|
|
||||||
pcMesh->mNumVertices = 900;
|
pcMesh->mNumVertices = 900;
|
||||||
aiVector3D*& pv = pcMesh->mVertices = new aiVector3D[900];
|
aiVector3D*& pv = pcMesh->mVertices = new aiVector3D[900];
|
||||||
for (unsigned int i = 0; i < 3;++i)
|
for (unsigned int i = 0; i < 3;++i)
|
||||||
{
|
{
|
||||||
const unsigned int base = i*300;
|
const unsigned int base = i*300;
|
||||||
for (unsigned int a = 0; a < 300;++a)
|
for (unsigned int a = 0; a < 300;++a)
|
||||||
{
|
{
|
||||||
pv[base+a].x = pv[base+a].y = pv[base+a].z = (float)a;
|
pv[base+a].x = pv[base+a].y = pv[base+a].z = (float)a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate faces - each vertex is referenced once
|
// generate faces - each vertex is referenced once
|
||||||
pcMesh->mNumFaces = 300;
|
pcMesh->mNumFaces = 300;
|
||||||
pcMesh->mFaces = new aiFace[300];
|
pcMesh->mFaces = new aiFace[300];
|
||||||
for (unsigned int i = 0,p = 0; i < 300;++i)
|
for (unsigned int i = 0,p = 0; i < 300;++i)
|
||||||
{
|
{
|
||||||
aiFace& face = pcMesh->mFaces[i];
|
aiFace& face = pcMesh->mFaces[i];
|
||||||
face.mIndices = new unsigned int[ face.mNumIndices = 3 ];
|
face.mIndices = new unsigned int[ face.mNumIndices = 3 ];
|
||||||
for (unsigned int a = 0; a < 3;++a)
|
for (unsigned int a = 0; a < 3;++a)
|
||||||
face.mIndices[a] = p++;
|
face.mIndices[a] = p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate extra members - set them to zero to make sure they're identical
|
// generate extra members - set them to zero to make sure they're identical
|
||||||
pcMesh->mTextureCoords[0] = new aiVector3D[900];
|
pcMesh->mTextureCoords[0] = new aiVector3D[900];
|
||||||
for (unsigned int i = 0; i < 900;++i)pcMesh->mTextureCoords[0][i] = aiVector3D( 0.f );
|
for (unsigned int i = 0; i < 900;++i)pcMesh->mTextureCoords[0][i] = aiVector3D( 0.f );
|
||||||
|
|
||||||
pcMesh->mNormals = new aiVector3D[900];
|
pcMesh->mNormals = new aiVector3D[900];
|
||||||
for (unsigned int i = 0; i < 900;++i)pcMesh->mNormals[i] = aiVector3D( 0.f );
|
for (unsigned int i = 0; i < 900;++i)pcMesh->mNormals[i] = aiVector3D( 0.f );
|
||||||
|
|
||||||
pcMesh->mTangents = new aiVector3D[900];
|
pcMesh->mTangents = new aiVector3D[900];
|
||||||
for (unsigned int i = 0; i < 900;++i)pcMesh->mTangents[i] = aiVector3D( 0.f );
|
for (unsigned int i = 0; i < 900;++i)pcMesh->mTangents[i] = aiVector3D( 0.f );
|
||||||
|
|
||||||
pcMesh->mBitangents = new aiVector3D[900];
|
pcMesh->mBitangents = new aiVector3D[900];
|
||||||
for (unsigned int i = 0; i < 900;++i)pcMesh->mBitangents[i] = aiVector3D( 0.f );
|
for (unsigned int i = 0; i < 900;++i)pcMesh->mBitangents[i] = aiVector3D( 0.f );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void JoinVerticesTest::TearDown()
|
void JoinVerticesTest::TearDown()
|
||||||
{
|
{
|
||||||
delete this->pcMesh;
|
delete this->pcMesh;
|
||||||
delete this->piProcess;
|
delete this->piProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(JoinVerticesTest, testProcess)
|
TEST_F(JoinVerticesTest, testProcess)
|
||||||
{
|
{
|
||||||
// execute the step on the given data
|
// execute the step on the given data
|
||||||
piProcess->ProcessMesh(pcMesh,0);
|
piProcess->ProcessMesh(pcMesh,0);
|
||||||
|
|
||||||
// the number of faces shouldn't change
|
// the number of faces shouldn't change
|
||||||
ASSERT_EQ(300U, pcMesh->mNumFaces);
|
ASSERT_EQ(300U, pcMesh->mNumFaces);
|
||||||
ASSERT_EQ(300U, pcMesh->mNumVertices);
|
ASSERT_EQ(300U, pcMesh->mNumVertices);
|
||||||
|
|
||||||
ASSERT_TRUE(NULL != pcMesh->mNormals);
|
ASSERT_TRUE(NULL != pcMesh->mNormals);
|
||||||
ASSERT_TRUE(NULL != pcMesh->mTangents);
|
ASSERT_TRUE(NULL != pcMesh->mTangents);
|
||||||
ASSERT_TRUE(NULL != pcMesh->mBitangents);
|
ASSERT_TRUE(NULL != pcMesh->mBitangents);
|
||||||
ASSERT_TRUE(NULL != pcMesh->mTextureCoords[0]);
|
ASSERT_TRUE(NULL != pcMesh->mTextureCoords[0]);
|
||||||
|
|
||||||
// the order doesn't care
|
// the order doesn't care
|
||||||
float fSum = 0.f;
|
float fSum = 0.f;
|
||||||
for (unsigned int i = 0; i < 300;++i)
|
for (unsigned int i = 0; i < 300;++i)
|
||||||
{
|
{
|
||||||
aiVector3D& v = pcMesh->mVertices[i];
|
aiVector3D& v = pcMesh->mVertices[i];
|
||||||
fSum += v.x + v.y + v.z;
|
fSum += v.x + v.y + v.z;
|
||||||
|
|
||||||
EXPECT_FALSE(pcMesh->mNormals[i].x);
|
EXPECT_FALSE(pcMesh->mNormals[i].x);
|
||||||
EXPECT_FALSE(pcMesh->mTangents[i].x);
|
EXPECT_FALSE(pcMesh->mTangents[i].x);
|
||||||
EXPECT_FALSE(pcMesh->mBitangents[i].x);
|
EXPECT_FALSE(pcMesh->mBitangents[i].x);
|
||||||
EXPECT_FALSE(pcMesh->mTextureCoords[0][i].x);
|
EXPECT_FALSE(pcMesh->mTextureCoords[0][i].x);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(150.f*299.f*3.f, fSum); // gaussian sum equation
|
EXPECT_EQ(150.f*299.f*3.f, fSum); // gaussian sum equation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,101 +1,101 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <LimitBoneWeightsProcess.h>
|
#include <LimitBoneWeightsProcess.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class LimitBoneWeightsTest : public ::testing::Test {
|
class LimitBoneWeightsTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
LimitBoneWeightsProcess* piProcess;
|
LimitBoneWeightsProcess* piProcess;
|
||||||
aiMesh* pcMesh;
|
aiMesh* pcMesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void LimitBoneWeightsTest::SetUp()
|
void LimitBoneWeightsTest::SetUp()
|
||||||
{
|
{
|
||||||
// construct the process
|
// construct the process
|
||||||
this->piProcess = new LimitBoneWeightsProcess();
|
this->piProcess = new LimitBoneWeightsProcess();
|
||||||
|
|
||||||
// now need to create a nice mesh for testing purposes
|
// now need to create a nice mesh for testing purposes
|
||||||
this->pcMesh = new aiMesh();
|
this->pcMesh = new aiMesh();
|
||||||
|
|
||||||
pcMesh->mNumVertices = 500;
|
pcMesh->mNumVertices = 500;
|
||||||
pcMesh->mVertices = new aiVector3D[500]; // uninit.
|
pcMesh->mVertices = new aiVector3D[500]; // uninit.
|
||||||
pcMesh->mNumBones = 30;
|
pcMesh->mNumBones = 30;
|
||||||
pcMesh->mBones = new aiBone*[30];
|
pcMesh->mBones = new aiBone*[30];
|
||||||
unsigned int iCur = 0;
|
unsigned int iCur = 0;
|
||||||
for (unsigned int i = 0; i < 30;++i)
|
for (unsigned int i = 0; i < 30;++i)
|
||||||
{
|
{
|
||||||
aiBone* pc = pcMesh->mBones[i] = new aiBone();
|
aiBone* pc = pcMesh->mBones[i] = new aiBone();
|
||||||
pc->mNumWeights = 250;
|
pc->mNumWeights = 250;
|
||||||
pc->mWeights = new aiVertexWeight[pc->mNumWeights];
|
pc->mWeights = new aiVertexWeight[pc->mNumWeights];
|
||||||
for (unsigned int qq = 0; qq < pc->mNumWeights;++qq)
|
for (unsigned int qq = 0; qq < pc->mNumWeights;++qq)
|
||||||
{
|
{
|
||||||
aiVertexWeight& v = pc->mWeights[qq];
|
aiVertexWeight& v = pc->mWeights[qq];
|
||||||
v.mVertexId = iCur++;
|
v.mVertexId = iCur++;
|
||||||
if (500 == iCur)iCur = 0;
|
if (500 == iCur)iCur = 0;
|
||||||
v.mWeight = 1.0f / 15; // each vertex should occur once in two bones
|
v.mWeight = 1.0f / 15; // each vertex should occur once in two bones
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void LimitBoneWeightsTest::TearDown()
|
void LimitBoneWeightsTest::TearDown()
|
||||||
{
|
{
|
||||||
delete pcMesh;
|
delete pcMesh;
|
||||||
delete piProcess;
|
delete piProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(LimitBoneWeightsTest, testProcess)
|
TEST_F(LimitBoneWeightsTest, testProcess)
|
||||||
{
|
{
|
||||||
// execute the step on the given data
|
// execute the step on the given data
|
||||||
piProcess->ProcessMesh(pcMesh);
|
piProcess->ProcessMesh(pcMesh);
|
||||||
|
|
||||||
// check whether everything is ok ...
|
// check whether everything is ok ...
|
||||||
typedef std::vector<LimitBoneWeightsProcess::Weight> VertexWeightList;
|
typedef std::vector<LimitBoneWeightsProcess::Weight> VertexWeightList;
|
||||||
VertexWeightList* asWeights = new VertexWeightList[pcMesh->mNumVertices];
|
VertexWeightList* asWeights = new VertexWeightList[pcMesh->mNumVertices];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
|
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
|
||||||
asWeights[i].reserve(4);
|
asWeights[i].reserve(4);
|
||||||
|
|
||||||
// sort back as per-vertex lists
|
// sort back as per-vertex lists
|
||||||
for (unsigned int i = 0; i < pcMesh->mNumBones;++i)
|
for (unsigned int i = 0; i < pcMesh->mNumBones;++i)
|
||||||
{
|
{
|
||||||
aiBone& pcBone = **(pcMesh->mBones+i);
|
aiBone& pcBone = **(pcMesh->mBones+i);
|
||||||
for (unsigned int q = 0; q < pcBone.mNumWeights;++q)
|
for (unsigned int q = 0; q < pcBone.mNumWeights;++q)
|
||||||
{
|
{
|
||||||
aiVertexWeight weight = pcBone.mWeights[q];
|
aiVertexWeight weight = pcBone.mWeights[q];
|
||||||
asWeights[weight.mVertexId].push_back(LimitBoneWeightsProcess::Weight (i,weight.mWeight));
|
asWeights[weight.mVertexId].push_back(LimitBoneWeightsProcess::Weight (i,weight.mWeight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now validate the size of the lists and check whether all weights sum to 1.0f
|
// now validate the size of the lists and check whether all weights sum to 1.0f
|
||||||
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
|
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
|
||||||
{
|
{
|
||||||
EXPECT_LE(asWeights[i].size(), 4U);
|
EXPECT_LE(asWeights[i].size(), 4U);
|
||||||
float fSum = 0.0f;
|
float fSum = 0.0f;
|
||||||
for (VertexWeightList::const_iterator
|
for (VertexWeightList::const_iterator
|
||||||
iter = asWeights[i].begin();
|
iter = asWeights[i].begin();
|
||||||
iter != asWeights[i].end();++iter)
|
iter != asWeights[i].end();++iter)
|
||||||
{
|
{
|
||||||
fSum += (*iter).mWeight;
|
fSum += (*iter).mWeight;
|
||||||
}
|
}
|
||||||
EXPECT_GE(fSum, 0.95F);
|
EXPECT_GE(fSum, 0.95F);
|
||||||
EXPECT_LE(fSum, 1.04F);
|
EXPECT_LE(fSum, 1.04F);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete allocated storage
|
// delete allocated storage
|
||||||
delete[] asWeights;
|
delete[] asWeights;
|
||||||
|
|
||||||
// everything seems to be OK
|
// everything seems to be OK
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,92 +1,92 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <MaterialSystem.h>
|
#include <MaterialSystem.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class MaterialSystemTest : public ::testing::Test
|
class MaterialSystemTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp() { this->pcMat = new aiMaterial(); }
|
virtual void SetUp() { this->pcMat = new aiMaterial(); }
|
||||||
virtual void TearDown() { delete this->pcMat; }
|
virtual void TearDown() { delete this->pcMat; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
aiMaterial* pcMat;
|
aiMaterial* pcMat;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(MaterialSystemTest, testFloatProperty)
|
TEST_F(MaterialSystemTest, testFloatProperty)
|
||||||
{
|
{
|
||||||
float pf = 150392.63f;
|
float pf = 150392.63f;
|
||||||
this->pcMat->AddProperty(&pf,1,"testKey1");
|
this->pcMat->AddProperty(&pf,1,"testKey1");
|
||||||
pf = 0.0f;
|
pf = 0.0f;
|
||||||
|
|
||||||
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey1",0,0,pf));
|
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey1",0,0,pf));
|
||||||
EXPECT_EQ(150392.63f, pf);
|
EXPECT_EQ(150392.63f, pf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(MaterialSystemTest, testFloatArrayProperty)
|
TEST_F(MaterialSystemTest, testFloatArrayProperty)
|
||||||
{
|
{
|
||||||
float pf[] = {0.0f,1.0f,2.0f,3.0f};
|
float pf[] = {0.0f,1.0f,2.0f,3.0f};
|
||||||
unsigned int pMax = sizeof(pf) / sizeof(float);
|
unsigned int pMax = sizeof(pf) / sizeof(float);
|
||||||
this->pcMat->AddProperty(&pf,pMax,"testKey2");
|
this->pcMat->AddProperty(&pf,pMax,"testKey2");
|
||||||
pf[0] = pf[1] = pf[2] = pf[3] = 12.0f;
|
pf[0] = pf[1] = pf[2] = pf[3] = 12.0f;
|
||||||
|
|
||||||
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2",0,0,pf,&pMax));
|
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2",0,0,pf,&pMax));
|
||||||
EXPECT_EQ(sizeof(pf) / sizeof(float), pMax);
|
EXPECT_EQ(sizeof(pf) / sizeof(float), pMax);
|
||||||
EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3] );
|
EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(MaterialSystemTest, testIntProperty)
|
TEST_F(MaterialSystemTest, testIntProperty)
|
||||||
{
|
{
|
||||||
int pf = 15039263;
|
int pf = 15039263;
|
||||||
this->pcMat->AddProperty(&pf,1,"testKey3");
|
this->pcMat->AddProperty(&pf,1,"testKey3");
|
||||||
pf = 12;
|
pf = 12;
|
||||||
|
|
||||||
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey3",0,0,pf));
|
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey3",0,0,pf));
|
||||||
EXPECT_EQ(15039263, pf);
|
EXPECT_EQ(15039263, pf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(MaterialSystemTest, testIntArrayProperty)
|
TEST_F(MaterialSystemTest, testIntArrayProperty)
|
||||||
{
|
{
|
||||||
int pf[] = {0,1,2,3};
|
int pf[] = {0,1,2,3};
|
||||||
unsigned int pMax = sizeof(pf) / sizeof(int);
|
unsigned int pMax = sizeof(pf) / sizeof(int);
|
||||||
this->pcMat->AddProperty(&pf,pMax,"testKey4");
|
this->pcMat->AddProperty(&pf,pMax,"testKey4");
|
||||||
pf[0] = pf[1] = pf[2] = pf[3] = 12;
|
pf[0] = pf[1] = pf[2] = pf[3] = 12;
|
||||||
|
|
||||||
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey4",0,0,pf,&pMax));
|
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey4",0,0,pf,&pMax));
|
||||||
EXPECT_EQ(sizeof(pf) / sizeof(int), pMax);
|
EXPECT_EQ(sizeof(pf) / sizeof(int), pMax);
|
||||||
EXPECT_TRUE(!pf[0] && 1 == pf[1] && 2 == pf[2] && 3 == pf[3] );
|
EXPECT_TRUE(!pf[0] && 1 == pf[1] && 2 == pf[2] && 3 == pf[3] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(MaterialSystemTest, testColorProperty)
|
TEST_F(MaterialSystemTest, testColorProperty)
|
||||||
{
|
{
|
||||||
aiColor4D clr;
|
aiColor4D clr;
|
||||||
clr.r = 2.0f;clr.g = 3.0f;clr.b = 4.0f;clr.a = 5.0f;
|
clr.r = 2.0f;clr.g = 3.0f;clr.b = 4.0f;clr.a = 5.0f;
|
||||||
this->pcMat->AddProperty(&clr,1,"testKey5");
|
this->pcMat->AddProperty(&clr,1,"testKey5");
|
||||||
clr.b = 1.0f;
|
clr.b = 1.0f;
|
||||||
clr.a = clr.g = clr.r = 0.0f;
|
clr.a = clr.g = clr.r = 0.0f;
|
||||||
|
|
||||||
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey5",0,0,clr));
|
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey5",0,0,clr));
|
||||||
EXPECT_TRUE(clr.r == 2.0f && clr.g == 3.0f && clr.b == 4.0f && clr.a == 5.0f);
|
EXPECT_TRUE(clr.r == 2.0f && clr.g == 3.0f && clr.b == 4.0f && clr.a == 5.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(MaterialSystemTest, testStringProperty)
|
TEST_F(MaterialSystemTest, testStringProperty)
|
||||||
{
|
{
|
||||||
aiString s;
|
aiString s;
|
||||||
s.Set("Hello, this is a small test");
|
s.Set("Hello, this is a small test");
|
||||||
this->pcMat->AddProperty(&s,"testKey6");
|
this->pcMat->AddProperty(&s,"testKey6");
|
||||||
s.Set("358358");
|
s.Set("358358");
|
||||||
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey6",0,0,s));
|
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey6",0,0,s));
|
||||||
EXPECT_STREQ("Hello, this is a small test", s.data);
|
EXPECT_STREQ("Hello, this is a small test", s.data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,72 +1,72 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include "BoostWorkaround/boost/tuple/tuple.hpp"
|
#include "BoostWorkaround/boost/tuple/tuple.hpp"
|
||||||
|
|
||||||
#define ASSIMP_FORCE_NOBOOST
|
#define ASSIMP_FORCE_NOBOOST
|
||||||
#include "BoostWorkaround/boost/format.hpp"
|
#include "BoostWorkaround/boost/format.hpp"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
using boost::format;
|
using boost::format;
|
||||||
using boost::str;
|
using boost::str;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST(NoBoostTest, testFormat)
|
TEST(NoBoostTest, testFormat)
|
||||||
{
|
{
|
||||||
EXPECT_EQ( "Ahoi!", boost::str( boost::format("Ahoi!") ));
|
EXPECT_EQ( "Ahoi!", boost::str( boost::format("Ahoi!") ));
|
||||||
EXPECT_EQ( "Ahoi! %", boost::str( boost::format("Ahoi! %%") ));
|
EXPECT_EQ( "Ahoi! %", boost::str( boost::format("Ahoi! %%") ));
|
||||||
EXPECT_EQ( "Ahoi! ", boost::str( boost::format("Ahoi! %s") ));
|
EXPECT_EQ( "Ahoi! ", boost::str( boost::format("Ahoi! %s") ));
|
||||||
EXPECT_EQ( "Ahoi! !!", boost::str( boost::format("Ahoi! %s") % "!!" ));
|
EXPECT_EQ( "Ahoi! !!", boost::str( boost::format("Ahoi! %s") % "!!" ));
|
||||||
EXPECT_EQ( "Ahoi! !!", boost::str( boost::format("Ahoi! %s") % "!!" % "!!" ));
|
EXPECT_EQ( "Ahoi! !!", boost::str( boost::format("Ahoi! %s") % "!!" % "!!" ));
|
||||||
EXPECT_EQ( "abc", boost::str( boost::format("%s%s%s") % "a" % std::string("b") % "c" ));
|
EXPECT_EQ( "abc", boost::str( boost::format("%s%s%s") % "a" % std::string("b") % "c" ));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct another
|
struct another
|
||||||
{
|
{
|
||||||
int dummy;
|
int dummy;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST(NoBoostTest, Tuple) {
|
TEST(NoBoostTest, Tuple) {
|
||||||
// Implicit conversion
|
// Implicit conversion
|
||||||
boost::tuple<unsigned,unsigned,unsigned> first = boost::make_tuple(4,4,4);
|
boost::tuple<unsigned,unsigned,unsigned> first = boost::make_tuple(4,4,4);
|
||||||
EXPECT_EQ(4U, first.get<0>());
|
EXPECT_EQ(4U, first.get<0>());
|
||||||
EXPECT_EQ(4U, first.get<1>());
|
EXPECT_EQ(4U, first.get<1>());
|
||||||
EXPECT_EQ(4U, first.get<2>());
|
EXPECT_EQ(4U, first.get<2>());
|
||||||
|
|
||||||
boost::tuple<int,float,double,bool,another> second;
|
boost::tuple<int,float,double,bool,another> second;
|
||||||
bool b = second.get<3>();
|
bool b = second.get<3>();
|
||||||
EXPECT_FALSE(b);
|
EXPECT_FALSE(b);
|
||||||
|
|
||||||
// check empty tuple, ignore compile warning
|
// check empty tuple, ignore compile warning
|
||||||
boost::tuple<> third;
|
boost::tuple<> third;
|
||||||
|
|
||||||
// FIXME: Explicit conversion not really required yet
|
// FIXME: Explicit conversion not really required yet
|
||||||
boost::tuple<float,float,float> last =
|
boost::tuple<float,float,float> last =
|
||||||
(boost::tuple<float,float,float>)boost::make_tuple(1.,2.,3.);
|
(boost::tuple<float,float,float>)boost::make_tuple(1.,2.,3.);
|
||||||
EXPECT_EQ(1.f, last.get<0>());
|
EXPECT_EQ(1.f, last.get<0>());
|
||||||
EXPECT_EQ(2.f, last.get<1>());
|
EXPECT_EQ(2.f, last.get<1>());
|
||||||
EXPECT_EQ(3.f, last.get<2>());
|
EXPECT_EQ(3.f, last.get<2>());
|
||||||
|
|
||||||
// Non-const access
|
// Non-const access
|
||||||
first.get<0>() = 1;
|
first.get<0>() = 1;
|
||||||
first.get<1>() = 2;
|
first.get<1>() = 2;
|
||||||
first.get<2>() = 3;
|
first.get<2>() = 3;
|
||||||
EXPECT_EQ(1U, first.get<0>());
|
EXPECT_EQ(1U, first.get<0>());
|
||||||
EXPECT_EQ(2U, first.get<1>());
|
EXPECT_EQ(2U, first.get<1>());
|
||||||
EXPECT_EQ(3U, first.get<2>());
|
EXPECT_EQ(3U, first.get<2>());
|
||||||
|
|
||||||
// Const cases
|
// Const cases
|
||||||
const boost::tuple<unsigned,unsigned,unsigned> constant = boost::make_tuple(5,5,5);
|
const boost::tuple<unsigned,unsigned,unsigned> constant = boost::make_tuple(5,5,5);
|
||||||
first.get<0>() = constant.get<0>();
|
first.get<0>() = constant.get<0>();
|
||||||
EXPECT_EQ(5U, constant.get<0>());
|
EXPECT_EQ(5U, constant.get<0>());
|
||||||
EXPECT_EQ(5U, first.get<0>());
|
EXPECT_EQ(5U, first.get<0>());
|
||||||
|
|
||||||
// Direct assignment w. explicit conversion
|
// Direct assignment w. explicit conversion
|
||||||
last = first;
|
last = first;
|
||||||
EXPECT_EQ(5.f, last.get<0>());
|
EXPECT_EQ(5.f, last.get<0>());
|
||||||
EXPECT_EQ(2.f, last.get<1>());
|
EXPECT_EQ(2.f, last.get<1>());
|
||||||
EXPECT_EQ(3.f, last.get<2>());
|
EXPECT_EQ(3.f, last.get<2>());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,111 +1,111 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <PretransformVertices.h>
|
#include <PretransformVertices.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class PretransformVerticesTest : public ::testing::Test
|
class PretransformVerticesTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
aiScene* scene;
|
aiScene* scene;
|
||||||
PretransformVertices* process;
|
PretransformVertices* process;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void AddNodes(unsigned int num, aiNode* father, unsigned int depth)
|
void AddNodes(unsigned int num, aiNode* father, unsigned int depth)
|
||||||
{
|
{
|
||||||
father->mChildren = new aiNode*[father->mNumChildren = 5];
|
father->mChildren = new aiNode*[father->mNumChildren = 5];
|
||||||
for (unsigned int i = 0; i < 5; ++i) {
|
for (unsigned int i = 0; i < 5; ++i) {
|
||||||
aiNode* nd = father->mChildren[i] = new aiNode();
|
aiNode* nd = father->mChildren[i] = new aiNode();
|
||||||
|
|
||||||
nd->mName.length = sprintf(nd->mName.data,"%i%i",depth,i);
|
nd->mName.length = sprintf(nd->mName.data,"%i%i",depth,i);
|
||||||
|
|
||||||
// spawn two meshes
|
// spawn two meshes
|
||||||
nd->mMeshes = new unsigned int[nd->mNumMeshes = 2];
|
nd->mMeshes = new unsigned int[nd->mNumMeshes = 2];
|
||||||
nd->mMeshes[0] = num*5+i;
|
nd->mMeshes[0] = num*5+i;
|
||||||
nd->mMeshes[1] = 24-(num*5+i); // mesh 12 is special ... it references the same mesh twice
|
nd->mMeshes[1] = 24-(num*5+i); // mesh 12 is special ... it references the same mesh twice
|
||||||
|
|
||||||
// setup an unique transformation matrix
|
// setup an unique transformation matrix
|
||||||
nd->mTransformation.a1 = num*5.f+i + 1;
|
nd->mTransformation.a1 = num*5.f+i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depth > 1) {
|
if (depth > 1) {
|
||||||
for (unsigned int i = 0; i < 5; ++i)
|
for (unsigned int i = 0; i < 5; ++i)
|
||||||
AddNodes(i, father->mChildren[i],depth-1);
|
AddNodes(i, father->mChildren[i],depth-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void PretransformVerticesTest::SetUp()
|
void PretransformVerticesTest::SetUp()
|
||||||
{
|
{
|
||||||
scene = new aiScene();
|
scene = new aiScene();
|
||||||
|
|
||||||
// add 5 empty materials
|
// add 5 empty materials
|
||||||
scene->mMaterials = new aiMaterial*[scene->mNumMaterials = 5];
|
scene->mMaterials = new aiMaterial*[scene->mNumMaterials = 5];
|
||||||
for (unsigned int i = 0; i < 5;++i)
|
for (unsigned int i = 0; i < 5;++i)
|
||||||
scene->mMaterials[i] = new aiMaterial();
|
scene->mMaterials[i] = new aiMaterial();
|
||||||
|
|
||||||
// add 25 test meshes
|
// add 25 test meshes
|
||||||
scene->mMeshes = new aiMesh*[scene->mNumMeshes = 25];
|
scene->mMeshes = new aiMesh*[scene->mNumMeshes = 25];
|
||||||
for (unsigned int i = 0; i < 25;++i) {
|
for (unsigned int i = 0; i < 25;++i) {
|
||||||
aiMesh* mesh = scene->mMeshes[i] = new aiMesh();
|
aiMesh* mesh = scene->mMeshes[i] = new aiMesh();
|
||||||
|
|
||||||
mesh->mPrimitiveTypes = aiPrimitiveType_POINT;
|
mesh->mPrimitiveTypes = aiPrimitiveType_POINT;
|
||||||
mesh->mFaces = new aiFace[ mesh->mNumFaces = 10+i ];
|
mesh->mFaces = new aiFace[ mesh->mNumFaces = 10+i ];
|
||||||
mesh->mVertices = new aiVector3D[mesh->mNumVertices = mesh->mNumFaces];
|
mesh->mVertices = new aiVector3D[mesh->mNumVertices = mesh->mNumFaces];
|
||||||
for (unsigned int a = 0; a < mesh->mNumFaces; ++a ) {
|
for (unsigned int a = 0; a < mesh->mNumFaces; ++a ) {
|
||||||
aiFace& f = mesh->mFaces[a];
|
aiFace& f = mesh->mFaces[a];
|
||||||
f.mIndices = new unsigned int [f.mNumIndices = 1];
|
f.mIndices = new unsigned int [f.mNumIndices = 1];
|
||||||
f.mIndices[0] = a*3;
|
f.mIndices[0] = a*3;
|
||||||
|
|
||||||
mesh->mVertices[a] = aiVector3D((float)i,(float)a,0.f);
|
mesh->mVertices[a] = aiVector3D((float)i,(float)a,0.f);
|
||||||
}
|
}
|
||||||
mesh->mMaterialIndex = i%5;
|
mesh->mMaterialIndex = i%5;
|
||||||
|
|
||||||
if (i % 2)
|
if (i % 2)
|
||||||
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
|
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct some nodes (1+25)
|
// construct some nodes (1+25)
|
||||||
scene->mRootNode = new aiNode();
|
scene->mRootNode = new aiNode();
|
||||||
scene->mRootNode->mName.Set("Root");
|
scene->mRootNode->mName.Set("Root");
|
||||||
AddNodes(0,scene->mRootNode,2);
|
AddNodes(0,scene->mRootNode,2);
|
||||||
|
|
||||||
process = new PretransformVertices();
|
process = new PretransformVertices();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void PretransformVerticesTest::TearDown()
|
void PretransformVerticesTest::TearDown()
|
||||||
{
|
{
|
||||||
delete scene;
|
delete scene;
|
||||||
delete process;
|
delete process;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(PretransformVerticesTest, testProcessCollapseHierarchy)
|
TEST_F(PretransformVerticesTest, testProcessCollapseHierarchy)
|
||||||
{
|
{
|
||||||
process->KeepHierarchy(false);
|
process->KeepHierarchy(false);
|
||||||
process->Execute(scene);
|
process->Execute(scene);
|
||||||
|
|
||||||
EXPECT_EQ(5U, scene->mNumMaterials);
|
EXPECT_EQ(5U, scene->mNumMaterials);
|
||||||
EXPECT_EQ(10U, scene->mNumMeshes); // every second mesh has normals
|
EXPECT_EQ(10U, scene->mNumMeshes); // every second mesh has normals
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(PretransformVerticesTest, testProcessKeepHierarchy)
|
TEST_F(PretransformVerticesTest, testProcessKeepHierarchy)
|
||||||
{
|
{
|
||||||
process->KeepHierarchy(true);
|
process->KeepHierarchy(true);
|
||||||
process->Execute(scene);
|
process->Execute(scene);
|
||||||
|
|
||||||
EXPECT_EQ(5U, scene->mNumMaterials);
|
EXPECT_EQ(5U, scene->mNumMaterials);
|
||||||
EXPECT_EQ(49U, scene->mNumMeshes); // see note on mesh 12 above
|
EXPECT_EQ(49U, scene->mNumMeshes); // see note on mesh 12 above
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +1,55 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <RemoveComments.h>
|
#include <RemoveComments.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST(RemoveCommentsTest, testSingleLineComments)
|
TEST(RemoveCommentsTest, testSingleLineComments)
|
||||||
{
|
{
|
||||||
const char* szTest = "int i = 0; \n"
|
const char* szTest = "int i = 0; \n"
|
||||||
"if (4 == //)\n"
|
"if (4 == //)\n"
|
||||||
"\ttrue) { // do something here \n"
|
"\ttrue) { // do something here \n"
|
||||||
"\t// hello ... and bye //\n";
|
"\t// hello ... and bye //\n";
|
||||||
|
|
||||||
|
|
||||||
char* szTest2 = new char[::strlen(szTest)+1];
|
char* szTest2 = new char[::strlen(szTest)+1];
|
||||||
::strcpy(szTest2,szTest);
|
::strcpy(szTest2,szTest);
|
||||||
|
|
||||||
const char* szTestResult = "int i = 0; \n"
|
const char* szTestResult = "int i = 0; \n"
|
||||||
"if (4 == \n"
|
"if (4 == \n"
|
||||||
"\ttrue) { \n"
|
"\ttrue) { \n"
|
||||||
"\t \n";
|
"\t \n";
|
||||||
|
|
||||||
CommentRemover::RemoveLineComments("//",szTest2,' ');
|
CommentRemover::RemoveLineComments("//",szTest2,' ');
|
||||||
EXPECT_STREQ(szTestResult, szTest2);
|
EXPECT_STREQ(szTestResult, szTest2);
|
||||||
|
|
||||||
delete[] szTest2;
|
delete[] szTest2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST(RemoveCommentsTest, testMultiLineComments)
|
TEST(RemoveCommentsTest, testMultiLineComments)
|
||||||
{
|
{
|
||||||
const char* szTest =
|
const char* szTest =
|
||||||
"/* comment to be removed */\n"
|
"/* comment to be removed */\n"
|
||||||
"valid text /* \n "
|
"valid text /* \n "
|
||||||
" comment across multiple lines */"
|
" comment across multiple lines */"
|
||||||
" / * Incomplete comment */ /* /* multiple comments */ */";
|
" / * Incomplete comment */ /* /* multiple comments */ */";
|
||||||
|
|
||||||
const char* szTestResult =
|
const char* szTestResult =
|
||||||
" \n"
|
" \n"
|
||||||
"valid text "
|
"valid text "
|
||||||
" "
|
" "
|
||||||
" / * Incomplete comment */ */";
|
" / * Incomplete comment */ */";
|
||||||
|
|
||||||
char* szTest2 = new char[::strlen(szTest)+1];
|
char* szTest2 = new char[::strlen(szTest)+1];
|
||||||
::strcpy(szTest2,szTest);
|
::strcpy(szTest2,szTest);
|
||||||
|
|
||||||
CommentRemover::RemoveMultiLineComments("/*","*/",szTest2,' ');
|
CommentRemover::RemoveMultiLineComments("/*","*/",szTest2,' ');
|
||||||
EXPECT_STREQ(szTestResult, szTest2);
|
EXPECT_STREQ(szTestResult, szTest2);
|
||||||
|
|
||||||
delete[] szTest2;
|
delete[] szTest2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,190 +1,190 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <RemoveVCProcess.h>
|
#include <RemoveVCProcess.h>
|
||||||
#include <MaterialSystem.h>
|
#include <MaterialSystem.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class RemoveVCProcessTest : public ::testing::Test
|
class RemoveVCProcessTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
RemoveVCProcess* piProcess;
|
RemoveVCProcess* piProcess;
|
||||||
aiScene* pScene;
|
aiScene* pScene;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void RemoveVCProcessTest::SetUp()
|
void RemoveVCProcessTest::SetUp()
|
||||||
{
|
{
|
||||||
// construct the process
|
// construct the process
|
||||||
piProcess = new RemoveVCProcess();
|
piProcess = new RemoveVCProcess();
|
||||||
pScene = new aiScene();
|
pScene = new aiScene();
|
||||||
|
|
||||||
// fill the scene ..
|
// fill the scene ..
|
||||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes = 2];
|
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes = 2];
|
||||||
pScene->mMeshes[0] = new aiMesh();
|
pScene->mMeshes[0] = new aiMesh();
|
||||||
pScene->mMeshes[1] = new aiMesh();
|
pScene->mMeshes[1] = new aiMesh();
|
||||||
|
|
||||||
pScene->mMeshes[0]->mNumVertices = 120;
|
pScene->mMeshes[0]->mNumVertices = 120;
|
||||||
pScene->mMeshes[0]->mVertices = new aiVector3D[120];
|
pScene->mMeshes[0]->mVertices = new aiVector3D[120];
|
||||||
pScene->mMeshes[0]->mNormals = new aiVector3D[120];
|
pScene->mMeshes[0]->mNormals = new aiVector3D[120];
|
||||||
pScene->mMeshes[0]->mTextureCoords[0] = new aiVector3D[120];
|
pScene->mMeshes[0]->mTextureCoords[0] = new aiVector3D[120];
|
||||||
pScene->mMeshes[0]->mTextureCoords[1] = new aiVector3D[120];
|
pScene->mMeshes[0]->mTextureCoords[1] = new aiVector3D[120];
|
||||||
pScene->mMeshes[0]->mTextureCoords[2] = new aiVector3D[120];
|
pScene->mMeshes[0]->mTextureCoords[2] = new aiVector3D[120];
|
||||||
pScene->mMeshes[0]->mTextureCoords[3] = new aiVector3D[120];
|
pScene->mMeshes[0]->mTextureCoords[3] = new aiVector3D[120];
|
||||||
|
|
||||||
pScene->mMeshes[1]->mNumVertices = 120;
|
pScene->mMeshes[1]->mNumVertices = 120;
|
||||||
pScene->mMeshes[1]->mVertices = new aiVector3D[120];
|
pScene->mMeshes[1]->mVertices = new aiVector3D[120];
|
||||||
|
|
||||||
pScene->mAnimations = new aiAnimation*[pScene->mNumAnimations = 2];
|
pScene->mAnimations = new aiAnimation*[pScene->mNumAnimations = 2];
|
||||||
pScene->mAnimations[0] = new aiAnimation();
|
pScene->mAnimations[0] = new aiAnimation();
|
||||||
pScene->mAnimations[1] = new aiAnimation();
|
pScene->mAnimations[1] = new aiAnimation();
|
||||||
|
|
||||||
pScene->mTextures = new aiTexture*[pScene->mNumTextures = 2];
|
pScene->mTextures = new aiTexture*[pScene->mNumTextures = 2];
|
||||||
pScene->mTextures[0] = new aiTexture();
|
pScene->mTextures[0] = new aiTexture();
|
||||||
pScene->mTextures[1] = new aiTexture();
|
pScene->mTextures[1] = new aiTexture();
|
||||||
|
|
||||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = 2];
|
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = 2];
|
||||||
pScene->mMaterials[0] = new aiMaterial();
|
pScene->mMaterials[0] = new aiMaterial();
|
||||||
pScene->mMaterials[1] = new aiMaterial();
|
pScene->mMaterials[1] = new aiMaterial();
|
||||||
|
|
||||||
pScene->mLights = new aiLight*[pScene->mNumLights = 2];
|
pScene->mLights = new aiLight*[pScene->mNumLights = 2];
|
||||||
pScene->mLights[0] = new aiLight();
|
pScene->mLights[0] = new aiLight();
|
||||||
pScene->mLights[1] = new aiLight();
|
pScene->mLights[1] = new aiLight();
|
||||||
|
|
||||||
pScene->mCameras = new aiCamera*[pScene->mNumCameras = 2];
|
pScene->mCameras = new aiCamera*[pScene->mNumCameras = 2];
|
||||||
pScene->mCameras[0] = new aiCamera();
|
pScene->mCameras[0] = new aiCamera();
|
||||||
pScene->mCameras[1] = new aiCamera();
|
pScene->mCameras[1] = new aiCamera();
|
||||||
|
|
||||||
// COMPILE TEST: aiMaterial may no add any extra members,
|
// COMPILE TEST: aiMaterial may no add any extra members,
|
||||||
// so we don't need a virtual destructor
|
// so we don't need a virtual destructor
|
||||||
char check[sizeof(aiMaterial) == sizeof(aiMaterial) ? 10 : -1];
|
char check[sizeof(aiMaterial) == sizeof(aiMaterial) ? 10 : -1];
|
||||||
check[0] = 0;
|
check[0] = 0;
|
||||||
// to remove compiler warning
|
// to remove compiler warning
|
||||||
EXPECT_TRUE( check );
|
EXPECT_TRUE( check );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void RemoveVCProcessTest::TearDown()
|
void RemoveVCProcessTest::TearDown()
|
||||||
{
|
{
|
||||||
delete pScene;
|
delete pScene;
|
||||||
delete piProcess;
|
delete piProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testMeshRemove)
|
TEST_F(RemoveVCProcessTest, testMeshRemove)
|
||||||
{
|
{
|
||||||
piProcess->SetDeleteFlags(aiComponent_MESHES);
|
piProcess->SetDeleteFlags(aiComponent_MESHES);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
EXPECT_TRUE(NULL == pScene->mMeshes);
|
EXPECT_TRUE(NULL == pScene->mMeshes);
|
||||||
EXPECT_EQ(0U, pScene->mNumMeshes);
|
EXPECT_EQ(0U, pScene->mNumMeshes);
|
||||||
EXPECT_TRUE(pScene->mFlags == AI_SCENE_FLAGS_INCOMPLETE);
|
EXPECT_TRUE(pScene->mFlags == AI_SCENE_FLAGS_INCOMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testAnimRemove)
|
TEST_F(RemoveVCProcessTest, testAnimRemove)
|
||||||
{
|
{
|
||||||
piProcess->SetDeleteFlags(aiComponent_ANIMATIONS);
|
piProcess->SetDeleteFlags(aiComponent_ANIMATIONS);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
EXPECT_TRUE(NULL == pScene->mAnimations);
|
EXPECT_TRUE(NULL == pScene->mAnimations);
|
||||||
EXPECT_EQ(0U, pScene->mNumAnimations);
|
EXPECT_EQ(0U, pScene->mNumAnimations);
|
||||||
EXPECT_EQ(0U, pScene->mFlags);
|
EXPECT_EQ(0U, pScene->mFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testMaterialRemove)
|
TEST_F(RemoveVCProcessTest, testMaterialRemove)
|
||||||
{
|
{
|
||||||
piProcess->SetDeleteFlags(aiComponent_MATERIALS);
|
piProcess->SetDeleteFlags(aiComponent_MATERIALS);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
// there should be one default material now ...
|
// there should be one default material now ...
|
||||||
EXPECT_TRUE(1 == pScene->mNumMaterials &&
|
EXPECT_TRUE(1 == pScene->mNumMaterials &&
|
||||||
pScene->mMeshes[0]->mMaterialIndex == 0 &&
|
pScene->mMeshes[0]->mMaterialIndex == 0 &&
|
||||||
pScene->mMeshes[1]->mMaterialIndex == 0);
|
pScene->mMeshes[1]->mMaterialIndex == 0);
|
||||||
EXPECT_EQ(0U, pScene->mFlags);
|
EXPECT_EQ(0U, pScene->mFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testTextureRemove)
|
TEST_F(RemoveVCProcessTest, testTextureRemove)
|
||||||
{
|
{
|
||||||
piProcess->SetDeleteFlags(aiComponent_TEXTURES);
|
piProcess->SetDeleteFlags(aiComponent_TEXTURES);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
EXPECT_TRUE(NULL == pScene->mTextures);
|
EXPECT_TRUE(NULL == pScene->mTextures);
|
||||||
EXPECT_EQ(0U, pScene->mNumTextures);
|
EXPECT_EQ(0U, pScene->mNumTextures);
|
||||||
EXPECT_EQ(0U, pScene->mFlags);
|
EXPECT_EQ(0U, pScene->mFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testCameraRemove)
|
TEST_F(RemoveVCProcessTest, testCameraRemove)
|
||||||
{
|
{
|
||||||
piProcess->SetDeleteFlags(aiComponent_CAMERAS);
|
piProcess->SetDeleteFlags(aiComponent_CAMERAS);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
EXPECT_TRUE(NULL == pScene->mCameras);
|
EXPECT_TRUE(NULL == pScene->mCameras);
|
||||||
EXPECT_EQ(0U, pScene->mNumCameras);
|
EXPECT_EQ(0U, pScene->mNumCameras);
|
||||||
EXPECT_EQ(0U, pScene->mFlags);
|
EXPECT_EQ(0U, pScene->mFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testLightRemove)
|
TEST_F(RemoveVCProcessTest, testLightRemove)
|
||||||
{
|
{
|
||||||
piProcess->SetDeleteFlags(aiComponent_LIGHTS);
|
piProcess->SetDeleteFlags(aiComponent_LIGHTS);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
EXPECT_TRUE(NULL == pScene->mLights);
|
EXPECT_TRUE(NULL == pScene->mLights);
|
||||||
EXPECT_EQ(0U, pScene->mNumLights);
|
EXPECT_EQ(0U, pScene->mNumLights);
|
||||||
EXPECT_EQ(0U, pScene->mFlags);
|
EXPECT_EQ(0U, pScene->mFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testMeshComponentsRemoveA)
|
TEST_F(RemoveVCProcessTest, testMeshComponentsRemoveA)
|
||||||
{
|
{
|
||||||
piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_TEXCOORDSn(2) | aiComponent_TEXCOORDSn(3));
|
piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_TEXCOORDSn(2) | aiComponent_TEXCOORDSn(3));
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
EXPECT_TRUE(pScene->mMeshes[0]->mTextureCoords[0] &&
|
EXPECT_TRUE(pScene->mMeshes[0]->mTextureCoords[0] &&
|
||||||
!pScene->mMeshes[0]->mTextureCoords[1] &&
|
!pScene->mMeshes[0]->mTextureCoords[1] &&
|
||||||
!pScene->mMeshes[0]->mTextureCoords[2] &&
|
!pScene->mMeshes[0]->mTextureCoords[2] &&
|
||||||
!pScene->mMeshes[0]->mTextureCoords[3]);
|
!pScene->mMeshes[0]->mTextureCoords[3]);
|
||||||
EXPECT_EQ(0U, pScene->mFlags);
|
EXPECT_EQ(0U, pScene->mFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testMeshComponentsRemoveB)
|
TEST_F(RemoveVCProcessTest, testMeshComponentsRemoveB)
|
||||||
{
|
{
|
||||||
piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_NORMALS);
|
piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_NORMALS);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
EXPECT_TRUE(pScene->mMeshes[0]->mTextureCoords[0] &&
|
EXPECT_TRUE(pScene->mMeshes[0]->mTextureCoords[0] &&
|
||||||
pScene->mMeshes[0]->mTextureCoords[1] &&
|
pScene->mMeshes[0]->mTextureCoords[1] &&
|
||||||
pScene->mMeshes[0]->mTextureCoords[2] && // shift forward ...
|
pScene->mMeshes[0]->mTextureCoords[2] && // shift forward ...
|
||||||
!pScene->mMeshes[0]->mTextureCoords[3] &&
|
!pScene->mMeshes[0]->mTextureCoords[3] &&
|
||||||
!pScene->mMeshes[0]->mNormals);
|
!pScene->mMeshes[0]->mNormals);
|
||||||
EXPECT_EQ(0U, pScene->mFlags);
|
EXPECT_EQ(0U, pScene->mFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testRemoveEverything)
|
TEST_F(RemoveVCProcessTest, testRemoveEverything)
|
||||||
{
|
{
|
||||||
piProcess->SetDeleteFlags(aiComponent_LIGHTS | aiComponent_ANIMATIONS |
|
piProcess->SetDeleteFlags(aiComponent_LIGHTS | aiComponent_ANIMATIONS |
|
||||||
aiComponent_MATERIALS | aiComponent_MESHES | aiComponent_CAMERAS | aiComponent_TEXTURES);
|
aiComponent_MATERIALS | aiComponent_MESHES | aiComponent_CAMERAS | aiComponent_TEXTURES);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
EXPECT_EQ(0U, pScene->mNumAnimations);
|
EXPECT_EQ(0U, pScene->mNumAnimations);
|
||||||
EXPECT_EQ(0U, pScene->mNumCameras);
|
EXPECT_EQ(0U, pScene->mNumCameras);
|
||||||
EXPECT_EQ(0U, pScene->mNumLights);
|
EXPECT_EQ(0U, pScene->mNumLights);
|
||||||
EXPECT_EQ(0U, pScene->mNumMeshes);
|
EXPECT_EQ(0U, pScene->mNumMeshes);
|
||||||
EXPECT_EQ(0U, pScene->mNumTextures);
|
EXPECT_EQ(0U, pScene->mNumTextures);
|
||||||
// Only the default material should remain.
|
// Only the default material should remain.
|
||||||
EXPECT_EQ(1U, pScene->mNumMaterials);
|
EXPECT_EQ(1U, pScene->mNumMaterials);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,150 +1,150 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <RemoveRedundantMaterials.h>
|
#include <RemoveRedundantMaterials.h>
|
||||||
#include <MaterialSystem.h>
|
#include <MaterialSystem.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class RemoveRedundantMatsTest : public ::testing::Test
|
class RemoveRedundantMatsTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
RemoveRedundantMatsProcess* piProcess;
|
RemoveRedundantMatsProcess* piProcess;
|
||||||
|
|
||||||
aiScene* pcScene1;
|
aiScene* pcScene1;
|
||||||
aiScene* pcScene2;
|
aiScene* pcScene2;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
aiMaterial* getUniqueMaterial1()
|
aiMaterial* getUniqueMaterial1()
|
||||||
{
|
{
|
||||||
// setup an unique name for each material - this shouldn't care
|
// setup an unique name for each material - this shouldn't care
|
||||||
aiString mTemp;
|
aiString mTemp;
|
||||||
mTemp.Set("UniqueMat1");
|
mTemp.Set("UniqueMat1");
|
||||||
|
|
||||||
aiMaterial* pcMat = new aiMaterial();
|
aiMaterial* pcMat = new aiMaterial();
|
||||||
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
||||||
float f = 2.0f;
|
float f = 2.0f;
|
||||||
pcMat->AddProperty<float>(&f, 1, AI_MATKEY_BUMPSCALING);
|
pcMat->AddProperty<float>(&f, 1, AI_MATKEY_BUMPSCALING);
|
||||||
pcMat->AddProperty<float>(&f, 1, AI_MATKEY_SHININESS_STRENGTH);
|
pcMat->AddProperty<float>(&f, 1, AI_MATKEY_SHININESS_STRENGTH);
|
||||||
return pcMat;
|
return pcMat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
aiMaterial* getUniqueMaterial2()
|
aiMaterial* getUniqueMaterial2()
|
||||||
{
|
{
|
||||||
// setup an unique name for each material - this shouldn't care
|
// setup an unique name for each material - this shouldn't care
|
||||||
aiString mTemp;
|
aiString mTemp;
|
||||||
mTemp.Set("Unique Mat2");
|
mTemp.Set("Unique Mat2");
|
||||||
|
|
||||||
aiMaterial* pcMat = new aiMaterial();
|
aiMaterial* pcMat = new aiMaterial();
|
||||||
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
||||||
float f = 4.0f;int i = 1;
|
float f = 4.0f;int i = 1;
|
||||||
pcMat->AddProperty<float>(&f, 1, AI_MATKEY_BUMPSCALING);
|
pcMat->AddProperty<float>(&f, 1, AI_MATKEY_BUMPSCALING);
|
||||||
pcMat->AddProperty<int>(&i, 1, AI_MATKEY_ENABLE_WIREFRAME);
|
pcMat->AddProperty<int>(&i, 1, AI_MATKEY_ENABLE_WIREFRAME);
|
||||||
return pcMat;
|
return pcMat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
aiMaterial* getUniqueMaterial3()
|
aiMaterial* getUniqueMaterial3()
|
||||||
{
|
{
|
||||||
// setup an unique name for each material - this shouldn't care
|
// setup an unique name for each material - this shouldn't care
|
||||||
aiString mTemp;
|
aiString mTemp;
|
||||||
mTemp.Set("Complex material name");
|
mTemp.Set("Complex material name");
|
||||||
|
|
||||||
aiMaterial* pcMat = new aiMaterial();
|
aiMaterial* pcMat = new aiMaterial();
|
||||||
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
||||||
return pcMat;
|
return pcMat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void RemoveRedundantMatsTest::SetUp()
|
void RemoveRedundantMatsTest::SetUp()
|
||||||
{
|
{
|
||||||
// construct the process
|
// construct the process
|
||||||
piProcess = new RemoveRedundantMatsProcess();
|
piProcess = new RemoveRedundantMatsProcess();
|
||||||
|
|
||||||
// create a scene with 5 materials (2 is a duplicate of 0, 3 of 1)
|
// create a scene with 5 materials (2 is a duplicate of 0, 3 of 1)
|
||||||
pcScene1 = new aiScene();
|
pcScene1 = new aiScene();
|
||||||
pcScene1->mNumMaterials = 5;
|
pcScene1->mNumMaterials = 5;
|
||||||
pcScene1->mMaterials = new aiMaterial*[5];
|
pcScene1->mMaterials = new aiMaterial*[5];
|
||||||
|
|
||||||
pcScene1->mMaterials[0] = getUniqueMaterial1();
|
pcScene1->mMaterials[0] = getUniqueMaterial1();
|
||||||
pcScene1->mMaterials[1] = getUniqueMaterial2();
|
pcScene1->mMaterials[1] = getUniqueMaterial2();
|
||||||
pcScene1->mMaterials[4] = getUniqueMaterial3();
|
pcScene1->mMaterials[4] = getUniqueMaterial3();
|
||||||
|
|
||||||
// all materials must be referenced
|
// all materials must be referenced
|
||||||
pcScene1->mNumMeshes = 5;
|
pcScene1->mNumMeshes = 5;
|
||||||
pcScene1->mMeshes = new aiMesh*[5];
|
pcScene1->mMeshes = new aiMesh*[5];
|
||||||
for (unsigned int i = 0; i < 5;++i) {
|
for (unsigned int i = 0; i < 5;++i) {
|
||||||
pcScene1->mMeshes[i] = new aiMesh();
|
pcScene1->mMeshes[i] = new aiMesh();
|
||||||
pcScene1->mMeshes[i]->mMaterialIndex = i;
|
pcScene1->mMeshes[i]->mMaterialIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup an unique name for each material - this shouldn't care
|
// setup an unique name for each material - this shouldn't care
|
||||||
aiString mTemp;
|
aiString mTemp;
|
||||||
mTemp.length = 1;
|
mTemp.length = 1;
|
||||||
mTemp.data[0] = 48;
|
mTemp.data[0] = 48;
|
||||||
mTemp.data[1] = 0;
|
mTemp.data[1] = 0;
|
||||||
|
|
||||||
aiMaterial* pcMat;
|
aiMaterial* pcMat;
|
||||||
pcScene1->mMaterials[2] = pcMat = new aiMaterial();
|
pcScene1->mMaterials[2] = pcMat = new aiMaterial();
|
||||||
aiMaterial::CopyPropertyList(pcMat,(const aiMaterial*)pcScene1->mMaterials[0]);
|
aiMaterial::CopyPropertyList(pcMat,(const aiMaterial*)pcScene1->mMaterials[0]);
|
||||||
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
||||||
mTemp.data[0]++;
|
mTemp.data[0]++;
|
||||||
|
|
||||||
pcScene1->mMaterials[3] = pcMat = new aiMaterial();
|
pcScene1->mMaterials[3] = pcMat = new aiMaterial();
|
||||||
aiMaterial::CopyPropertyList(pcMat,(const aiMaterial*)pcScene1->mMaterials[1]);
|
aiMaterial::CopyPropertyList(pcMat,(const aiMaterial*)pcScene1->mMaterials[1]);
|
||||||
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
|
||||||
mTemp.data[0]++;
|
mTemp.data[0]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void RemoveRedundantMatsTest::TearDown()
|
void RemoveRedundantMatsTest::TearDown()
|
||||||
{
|
{
|
||||||
delete piProcess;
|
delete piProcess;
|
||||||
delete pcScene1;
|
delete pcScene1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveRedundantMatsTest, testRedundantMaterials)
|
TEST_F(RemoveRedundantMatsTest, testRedundantMaterials)
|
||||||
{
|
{
|
||||||
piProcess->SetFixedMaterialsString();
|
piProcess->SetFixedMaterialsString();
|
||||||
|
|
||||||
piProcess->Execute(pcScene1);
|
piProcess->Execute(pcScene1);
|
||||||
EXPECT_EQ(3U, pcScene1->mNumMaterials);
|
EXPECT_EQ(3U, pcScene1->mNumMaterials);
|
||||||
EXPECT_TRUE(0 != pcScene1->mMaterials &&
|
EXPECT_TRUE(0 != pcScene1->mMaterials &&
|
||||||
0 != pcScene1->mMaterials[0] &&
|
0 != pcScene1->mMaterials[0] &&
|
||||||
0 != pcScene1->mMaterials[1] &&
|
0 != pcScene1->mMaterials[1] &&
|
||||||
0 != pcScene1->mMaterials[2]);
|
0 != pcScene1->mMaterials[2]);
|
||||||
|
|
||||||
aiString sName;
|
aiString sName;
|
||||||
EXPECT_EQ(AI_SUCCESS, aiGetMaterialString(pcScene1->mMaterials[2],AI_MATKEY_NAME,&sName));
|
EXPECT_EQ(AI_SUCCESS, aiGetMaterialString(pcScene1->mMaterials[2],AI_MATKEY_NAME,&sName));
|
||||||
EXPECT_STREQ("Complex material name", sName.data);
|
EXPECT_STREQ("Complex material name", sName.data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveRedundantMatsTest, testRedundantMaterialsWithExcludeList)
|
TEST_F(RemoveRedundantMatsTest, testRedundantMaterialsWithExcludeList)
|
||||||
{
|
{
|
||||||
piProcess->SetFixedMaterialsString("\'Unique Mat2\'\t\'Complex material name\' and_another_one_which_we_wont_use");
|
piProcess->SetFixedMaterialsString("\'Unique Mat2\'\t\'Complex material name\' and_another_one_which_we_wont_use");
|
||||||
|
|
||||||
piProcess->Execute(pcScene1);
|
piProcess->Execute(pcScene1);
|
||||||
EXPECT_EQ(4U, pcScene1->mNumMaterials);
|
EXPECT_EQ(4U, pcScene1->mNumMaterials);
|
||||||
EXPECT_TRUE(0 != pcScene1->mMaterials &&
|
EXPECT_TRUE(0 != pcScene1->mMaterials &&
|
||||||
0 != pcScene1->mMaterials[0] &&
|
0 != pcScene1->mMaterials[0] &&
|
||||||
0 != pcScene1->mMaterials[1] &&
|
0 != pcScene1->mMaterials[1] &&
|
||||||
0 != pcScene1->mMaterials[2] &&
|
0 != pcScene1->mMaterials[2] &&
|
||||||
0 != pcScene1->mMaterials[3]);
|
0 != pcScene1->mMaterials[3]);
|
||||||
|
|
||||||
aiString sName;
|
aiString sName;
|
||||||
EXPECT_EQ(AI_SUCCESS, aiGetMaterialString(pcScene1->mMaterials[3],AI_MATKEY_NAME,&sName));
|
EXPECT_EQ(AI_SUCCESS, aiGetMaterialString(pcScene1->mMaterials[3],AI_MATKEY_NAME,&sName));
|
||||||
EXPECT_STREQ("Complex material name", sName.data);
|
EXPECT_STREQ("Complex material name", sName.data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,163 +1,163 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/mesh.h>
|
#include <assimp/mesh.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <ScenePreprocessor.h>
|
#include <ScenePreprocessor.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
class ScenePreprocessorTest : public ::testing::Test
|
class ScenePreprocessorTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void CheckIfOnly(aiMesh* p, unsigned int num, unsigned flag);
|
void CheckIfOnly(aiMesh* p, unsigned int num, unsigned flag);
|
||||||
|
|
||||||
void ProcessAnimation(aiAnimation* anim) { pp->ProcessAnimation(anim); }
|
void ProcessAnimation(aiAnimation* anim) { pp->ProcessAnimation(anim); }
|
||||||
void ProcessMesh(aiMesh* mesh) { pp->ProcessMesh(mesh); }
|
void ProcessMesh(aiMesh* mesh) { pp->ProcessMesh(mesh); }
|
||||||
|
|
||||||
ScenePreprocessor* pp;
|
ScenePreprocessor* pp;
|
||||||
aiScene* scene;
|
aiScene* scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void ScenePreprocessorTest::SetUp()
|
void ScenePreprocessorTest::SetUp()
|
||||||
{
|
{
|
||||||
// setup a dummy scene with a single node
|
// setup a dummy scene with a single node
|
||||||
scene = new aiScene();
|
scene = new aiScene();
|
||||||
scene->mRootNode = new aiNode();
|
scene->mRootNode = new aiNode();
|
||||||
scene->mRootNode->mName.Set("<test>");
|
scene->mRootNode->mName.Set("<test>");
|
||||||
|
|
||||||
// add some translation
|
// add some translation
|
||||||
scene->mRootNode->mTransformation.a4 = 1.f;
|
scene->mRootNode->mTransformation.a4 = 1.f;
|
||||||
scene->mRootNode->mTransformation.b4 = 2.f;
|
scene->mRootNode->mTransformation.b4 = 2.f;
|
||||||
scene->mRootNode->mTransformation.c4 = 3.f;
|
scene->mRootNode->mTransformation.c4 = 3.f;
|
||||||
|
|
||||||
// and allocate a ScenePreprocessor to operate on the scene
|
// and allocate a ScenePreprocessor to operate on the scene
|
||||||
pp = new ScenePreprocessor(scene);
|
pp = new ScenePreprocessor(scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void ScenePreprocessorTest::TearDown()
|
void ScenePreprocessorTest::TearDown()
|
||||||
{
|
{
|
||||||
delete pp;
|
delete pp;
|
||||||
delete scene;
|
delete scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Check whether ProcessMesh() returns flag for a mesh that consist of primitives with num indices
|
// Check whether ProcessMesh() returns flag for a mesh that consist of primitives with num indices
|
||||||
void ScenePreprocessorTest::CheckIfOnly(aiMesh* p, unsigned int num, unsigned int flag)
|
void ScenePreprocessorTest::CheckIfOnly(aiMesh* p, unsigned int num, unsigned int flag)
|
||||||
{
|
{
|
||||||
// Triangles only
|
// Triangles only
|
||||||
for (unsigned i = 0; i < p->mNumFaces;++i) {
|
for (unsigned i = 0; i < p->mNumFaces;++i) {
|
||||||
p->mFaces[i].mNumIndices = num;
|
p->mFaces[i].mNumIndices = num;
|
||||||
}
|
}
|
||||||
pp->ProcessMesh(p);
|
pp->ProcessMesh(p);
|
||||||
EXPECT_EQ(flag, p->mPrimitiveTypes);
|
EXPECT_EQ(flag, p->mPrimitiveTypes);
|
||||||
p->mPrimitiveTypes = 0;
|
p->mPrimitiveTypes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Check whether a mesh is preprocessed correctly. Case 1: The mesh needs preprocessing
|
// Check whether a mesh is preprocessed correctly. Case 1: The mesh needs preprocessing
|
||||||
TEST_F(ScenePreprocessorTest, testMeshPreprocessingPos)
|
TEST_F(ScenePreprocessorTest, testMeshPreprocessingPos)
|
||||||
{
|
{
|
||||||
aiMesh* p = new aiMesh();
|
aiMesh* p = new aiMesh();
|
||||||
p->mNumFaces = 100;
|
p->mNumFaces = 100;
|
||||||
p->mFaces = new aiFace[p->mNumFaces];
|
p->mFaces = new aiFace[p->mNumFaces];
|
||||||
|
|
||||||
p->mTextureCoords[0] = new aiVector3D[10];
|
p->mTextureCoords[0] = new aiVector3D[10];
|
||||||
p->mNumUVComponents[0] = 0;
|
p->mNumUVComponents[0] = 0;
|
||||||
p->mNumUVComponents[1] = 0;
|
p->mNumUVComponents[1] = 0;
|
||||||
|
|
||||||
CheckIfOnly(p,1,aiPrimitiveType_POINT);
|
CheckIfOnly(p,1,aiPrimitiveType_POINT);
|
||||||
CheckIfOnly(p,2,aiPrimitiveType_LINE);
|
CheckIfOnly(p,2,aiPrimitiveType_LINE);
|
||||||
CheckIfOnly(p,3,aiPrimitiveType_TRIANGLE);
|
CheckIfOnly(p,3,aiPrimitiveType_TRIANGLE);
|
||||||
CheckIfOnly(p,4,aiPrimitiveType_POLYGON);
|
CheckIfOnly(p,4,aiPrimitiveType_POLYGON);
|
||||||
CheckIfOnly(p,1249,aiPrimitiveType_POLYGON);
|
CheckIfOnly(p,1249,aiPrimitiveType_POLYGON);
|
||||||
|
|
||||||
// Polygons and triangles mixed
|
// Polygons and triangles mixed
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < p->mNumFaces/2;++i) {
|
for (i = 0; i < p->mNumFaces/2;++i) {
|
||||||
p->mFaces[i].mNumIndices = 3;
|
p->mFaces[i].mNumIndices = 3;
|
||||||
}
|
}
|
||||||
for (; i < p->mNumFaces-p->mNumFaces/4;++i) {
|
for (; i < p->mNumFaces-p->mNumFaces/4;++i) {
|
||||||
p->mFaces[i].mNumIndices = 4;
|
p->mFaces[i].mNumIndices = 4;
|
||||||
}
|
}
|
||||||
for (; i < p->mNumFaces;++i) {
|
for (; i < p->mNumFaces;++i) {
|
||||||
p->mFaces[i].mNumIndices = 10;
|
p->mFaces[i].mNumIndices = 10;
|
||||||
}
|
}
|
||||||
ProcessMesh(p);
|
ProcessMesh(p);
|
||||||
EXPECT_EQ(static_cast<unsigned int>(aiPrimitiveType_TRIANGLE|aiPrimitiveType_POLYGON),
|
EXPECT_EQ(static_cast<unsigned int>(aiPrimitiveType_TRIANGLE|aiPrimitiveType_POLYGON),
|
||||||
p->mPrimitiveTypes);
|
p->mPrimitiveTypes);
|
||||||
EXPECT_EQ(2U, p->mNumUVComponents[0]);
|
EXPECT_EQ(2U, p->mNumUVComponents[0]);
|
||||||
EXPECT_EQ(0U, p->mNumUVComponents[1]);
|
EXPECT_EQ(0U, p->mNumUVComponents[1]);
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Check whether a mesh is preprocessed correctly. Case 1: The mesh doesn't need preprocessing
|
// Check whether a mesh is preprocessed correctly. Case 1: The mesh doesn't need preprocessing
|
||||||
TEST_F(ScenePreprocessorTest, testMeshPreprocessingNeg)
|
TEST_F(ScenePreprocessorTest, testMeshPreprocessingNeg)
|
||||||
{
|
{
|
||||||
aiMesh* p = new aiMesh();
|
aiMesh* p = new aiMesh();
|
||||||
p->mPrimitiveTypes = aiPrimitiveType_TRIANGLE|aiPrimitiveType_POLYGON;
|
p->mPrimitiveTypes = aiPrimitiveType_TRIANGLE|aiPrimitiveType_POLYGON;
|
||||||
ProcessMesh(p);
|
ProcessMesh(p);
|
||||||
|
|
||||||
// should be unmodified
|
// should be unmodified
|
||||||
EXPECT_EQ(static_cast<unsigned int>(aiPrimitiveType_TRIANGLE|aiPrimitiveType_POLYGON),
|
EXPECT_EQ(static_cast<unsigned int>(aiPrimitiveType_TRIANGLE|aiPrimitiveType_POLYGON),
|
||||||
p->mPrimitiveTypes);
|
p->mPrimitiveTypes);
|
||||||
|
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Make a dummy animation with a single channel, '<test>'
|
// Make a dummy animation with a single channel, '<test>'
|
||||||
aiAnimation* MakeDummyAnimation()
|
aiAnimation* MakeDummyAnimation()
|
||||||
{
|
{
|
||||||
aiAnimation* p = new aiAnimation();
|
aiAnimation* p = new aiAnimation();
|
||||||
p->mNumChannels = 1;
|
p->mNumChannels = 1;
|
||||||
p->mChannels = new aiNodeAnim*[1];
|
p->mChannels = new aiNodeAnim*[1];
|
||||||
aiNodeAnim* anim = p->mChannels[0] = new aiNodeAnim();
|
aiNodeAnim* anim = p->mChannels[0] = new aiNodeAnim();
|
||||||
anim->mNodeName.Set("<test>");
|
anim->mNodeName.Set("<test>");
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Check whether an anim is preprocessed correctly. Case 1: The anim needs preprocessing
|
// Check whether an anim is preprocessed correctly. Case 1: The anim needs preprocessing
|
||||||
TEST_F(ScenePreprocessorTest, testAnimationPreprocessingPos)
|
TEST_F(ScenePreprocessorTest, testAnimationPreprocessingPos)
|
||||||
{
|
{
|
||||||
aiAnimation* p = MakeDummyAnimation();
|
aiAnimation* p = MakeDummyAnimation();
|
||||||
aiNodeAnim* anim = p->mChannels[0];
|
aiNodeAnim* anim = p->mChannels[0];
|
||||||
|
|
||||||
// we don't set the animation duration, but generate scaling channels
|
// we don't set the animation duration, but generate scaling channels
|
||||||
anim->mNumScalingKeys = 10;
|
anim->mNumScalingKeys = 10;
|
||||||
anim->mScalingKeys = new aiVectorKey[10];
|
anim->mScalingKeys = new aiVectorKey[10];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 10;++i) {
|
for (unsigned int i = 0; i < 10;++i) {
|
||||||
anim->mScalingKeys[i].mTime = i;
|
anim->mScalingKeys[i].mTime = i;
|
||||||
anim->mScalingKeys[i].mValue = aiVector3D((float)i);
|
anim->mScalingKeys[i].mValue = aiVector3D((float)i);
|
||||||
}
|
}
|
||||||
ProcessAnimation(p);
|
ProcessAnimation(p);
|
||||||
|
|
||||||
// we should now have a proper duration
|
// we should now have a proper duration
|
||||||
EXPECT_NEAR(p->mDuration, 9., 0.005);
|
EXPECT_NEAR(p->mDuration, 9., 0.005);
|
||||||
|
|
||||||
// ... one scaling key
|
// ... one scaling key
|
||||||
EXPECT_TRUE(anim->mNumPositionKeys == 1 &&
|
EXPECT_TRUE(anim->mNumPositionKeys == 1 &&
|
||||||
anim->mPositionKeys &&
|
anim->mPositionKeys &&
|
||||||
anim->mPositionKeys[0].mTime == 0.0 &&
|
anim->mPositionKeys[0].mTime == 0.0 &&
|
||||||
anim->mPositionKeys[0].mValue == aiVector3D(1.f,2.f,3.f));
|
anim->mPositionKeys[0].mValue == aiVector3D(1.f,2.f,3.f));
|
||||||
|
|
||||||
// ... and one rotation key
|
// ... and one rotation key
|
||||||
EXPECT_TRUE(anim->mNumRotationKeys == 1 && anim->mRotationKeys &&
|
EXPECT_TRUE(anim->mNumRotationKeys == 1 && anim->mRotationKeys &&
|
||||||
anim->mRotationKeys[0].mTime == 0.0);
|
anim->mRotationKeys[0].mTime == 0.0);
|
||||||
|
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,85 +1,85 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <BaseProcess.h>
|
#include <BaseProcess.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class SharedPPDataTest : public ::testing::Test
|
class SharedPPDataTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SharedPostProcessInfo* shared;
|
SharedPostProcessInfo* shared;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool destructed;
|
static bool destructed;
|
||||||
|
|
||||||
struct TestType
|
struct TestType
|
||||||
{
|
{
|
||||||
~TestType()
|
~TestType()
|
||||||
{
|
{
|
||||||
destructed = true;
|
destructed = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SharedPPDataTest::SetUp()
|
void SharedPPDataTest::SetUp()
|
||||||
{
|
{
|
||||||
shared = new SharedPostProcessInfo();
|
shared = new SharedPostProcessInfo();
|
||||||
destructed = false;
|
destructed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SharedPPDataTest::TearDown()
|
void SharedPPDataTest::TearDown()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(SharedPPDataTest, testPODProperty)
|
TEST_F(SharedPPDataTest, testPODProperty)
|
||||||
{
|
{
|
||||||
int i = 5;
|
int i = 5;
|
||||||
shared->AddProperty("test",i);
|
shared->AddProperty("test",i);
|
||||||
int o;
|
int o;
|
||||||
EXPECT_TRUE(shared->GetProperty("test",o));
|
EXPECT_TRUE(shared->GetProperty("test",o));
|
||||||
EXPECT_EQ(5, o);
|
EXPECT_EQ(5, o);
|
||||||
EXPECT_FALSE(shared->GetProperty("test2",o));
|
EXPECT_FALSE(shared->GetProperty("test2",o));
|
||||||
EXPECT_EQ(5, o);
|
EXPECT_EQ(5, o);
|
||||||
|
|
||||||
float f = 12.f, m;
|
float f = 12.f, m;
|
||||||
shared->AddProperty("test",f);
|
shared->AddProperty("test",f);
|
||||||
EXPECT_TRUE(shared->GetProperty("test",m));
|
EXPECT_TRUE(shared->GetProperty("test",m));
|
||||||
EXPECT_EQ(12.f, m);
|
EXPECT_EQ(12.f, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(SharedPPDataTest, testPropertyPointer)
|
TEST_F(SharedPPDataTest, testPropertyPointer)
|
||||||
{
|
{
|
||||||
int *i = new int[35];
|
int *i = new int[35];
|
||||||
shared->AddProperty("test16",i);
|
shared->AddProperty("test16",i);
|
||||||
int* o;
|
int* o;
|
||||||
EXPECT_TRUE(shared->GetProperty("test16",o));
|
EXPECT_TRUE(shared->GetProperty("test16",o));
|
||||||
EXPECT_EQ(i, o);
|
EXPECT_EQ(i, o);
|
||||||
shared->RemoveProperty("test16");
|
shared->RemoveProperty("test16");
|
||||||
EXPECT_FALSE(shared->GetProperty("test16",o));
|
EXPECT_FALSE(shared->GetProperty("test16",o));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(SharedPPDataTest, testPropertyDeallocation)
|
TEST_F(SharedPPDataTest, testPropertyDeallocation)
|
||||||
{
|
{
|
||||||
TestType *out, * pip = new TestType();
|
TestType *out, * pip = new TestType();
|
||||||
shared->AddProperty("quak",pip);
|
shared->AddProperty("quak",pip);
|
||||||
EXPECT_TRUE(shared->GetProperty("quak",out));
|
EXPECT_TRUE(shared->GetProperty("quak",out));
|
||||||
EXPECT_EQ(pip, out);
|
EXPECT_EQ(pip, out);
|
||||||
|
|
||||||
delete shared;
|
delete shared;
|
||||||
EXPECT_TRUE(destructed);
|
EXPECT_TRUE(destructed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,193 +1,193 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <ScenePreprocessor.h>
|
#include <ScenePreprocessor.h>
|
||||||
#include <SortByPTypeProcess.h>
|
#include <SortByPTypeProcess.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
class SortByPTypeProcessTest : public ::testing::Test
|
class SortByPTypeProcessTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SortByPTypeProcess* process1;
|
SortByPTypeProcess* process1;
|
||||||
aiScene* scene;
|
aiScene* scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static unsigned int num[10][4] =
|
static unsigned int num[10][4] =
|
||||||
{
|
{
|
||||||
{0,0,0,1000},
|
{0,0,0,1000},
|
||||||
{0,0,1000,0},
|
{0,0,1000,0},
|
||||||
{0,1000,0,0},
|
{0,1000,0,0},
|
||||||
{1000,0,0,0},
|
{1000,0,0,0},
|
||||||
{500,500,0,0},
|
{500,500,0,0},
|
||||||
{500,0,500,0},
|
{500,0,500,0},
|
||||||
{0,330,330,340},
|
{0,330,330,340},
|
||||||
{250,250,250,250},
|
{250,250,250,250},
|
||||||
{100,100,100,700},
|
{100,100,100,700},
|
||||||
{0,100,0,900},
|
{0,100,0,900},
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static unsigned int result[10] =
|
static unsigned int result[10] =
|
||||||
{
|
{
|
||||||
aiPrimitiveType_POLYGON,
|
aiPrimitiveType_POLYGON,
|
||||||
aiPrimitiveType_TRIANGLE,
|
aiPrimitiveType_TRIANGLE,
|
||||||
aiPrimitiveType_LINE,
|
aiPrimitiveType_LINE,
|
||||||
aiPrimitiveType_POINT,
|
aiPrimitiveType_POINT,
|
||||||
aiPrimitiveType_POINT | aiPrimitiveType_LINE,
|
aiPrimitiveType_POINT | aiPrimitiveType_LINE,
|
||||||
aiPrimitiveType_POINT | aiPrimitiveType_TRIANGLE,
|
aiPrimitiveType_POINT | aiPrimitiveType_TRIANGLE,
|
||||||
aiPrimitiveType_TRIANGLE | aiPrimitiveType_LINE | aiPrimitiveType_POLYGON,
|
aiPrimitiveType_TRIANGLE | aiPrimitiveType_LINE | aiPrimitiveType_POLYGON,
|
||||||
aiPrimitiveType_POLYGON | aiPrimitiveType_LINE | aiPrimitiveType_TRIANGLE | aiPrimitiveType_POINT,
|
aiPrimitiveType_POLYGON | aiPrimitiveType_LINE | aiPrimitiveType_TRIANGLE | aiPrimitiveType_POINT,
|
||||||
aiPrimitiveType_POLYGON | aiPrimitiveType_LINE | aiPrimitiveType_TRIANGLE | aiPrimitiveType_POINT,
|
aiPrimitiveType_POLYGON | aiPrimitiveType_LINE | aiPrimitiveType_TRIANGLE | aiPrimitiveType_POINT,
|
||||||
aiPrimitiveType_LINE | aiPrimitiveType_POLYGON,
|
aiPrimitiveType_LINE | aiPrimitiveType_POLYGON,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SortByPTypeProcessTest::SetUp()
|
void SortByPTypeProcessTest::SetUp()
|
||||||
{
|
{
|
||||||
// process0 = new DeterminePTypeHelperProcess();
|
// process0 = new DeterminePTypeHelperProcess();
|
||||||
process1 = new SortByPTypeProcess();
|
process1 = new SortByPTypeProcess();
|
||||||
scene = new aiScene();
|
scene = new aiScene();
|
||||||
|
|
||||||
scene->mNumMeshes = 10;
|
scene->mNumMeshes = 10;
|
||||||
scene->mMeshes = new aiMesh*[10];
|
scene->mMeshes = new aiMesh*[10];
|
||||||
|
|
||||||
bool five = false;
|
bool five = false;
|
||||||
for (unsigned int i = 0; i < 10; ++i)
|
for (unsigned int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
aiMesh* mesh = scene->mMeshes[i] = new aiMesh();
|
aiMesh* mesh = scene->mMeshes[i] = new aiMesh();
|
||||||
mesh->mNumFaces = 1000;
|
mesh->mNumFaces = 1000;
|
||||||
aiFace* faces = mesh->mFaces = new aiFace[1000];
|
aiFace* faces = mesh->mFaces = new aiFace[1000];
|
||||||
aiVector3D* pv = mesh->mVertices = new aiVector3D[mesh->mNumFaces*5];
|
aiVector3D* pv = mesh->mVertices = new aiVector3D[mesh->mNumFaces*5];
|
||||||
aiVector3D* pn = mesh->mNormals = new aiVector3D[mesh->mNumFaces*5];
|
aiVector3D* pn = mesh->mNormals = new aiVector3D[mesh->mNumFaces*5];
|
||||||
|
|
||||||
aiVector3D* pt = mesh->mTangents = new aiVector3D[mesh->mNumFaces*5];
|
aiVector3D* pt = mesh->mTangents = new aiVector3D[mesh->mNumFaces*5];
|
||||||
aiVector3D* pb = mesh->mBitangents = new aiVector3D[mesh->mNumFaces*5];
|
aiVector3D* pb = mesh->mBitangents = new aiVector3D[mesh->mNumFaces*5];
|
||||||
|
|
||||||
aiVector3D* puv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumFaces*5];
|
aiVector3D* puv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumFaces*5];
|
||||||
|
|
||||||
unsigned int remaining[4] = {num[i][0],num[i][1],num[i][2],num[i][3]};
|
unsigned int remaining[4] = {num[i][0],num[i][1],num[i][2],num[i][3]};
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
for (unsigned int m = 0; m < 1000; ++m)
|
for (unsigned int m = 0; m < 1000; ++m)
|
||||||
{
|
{
|
||||||
unsigned int idx = m % 4;
|
unsigned int idx = m % 4;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (!remaining[idx])
|
if (!remaining[idx])
|
||||||
{
|
{
|
||||||
if (4 == ++idx)idx = 0;
|
if (4 == ++idx)idx = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
faces->mNumIndices = idx+1;
|
faces->mNumIndices = idx+1;
|
||||||
if (4 == faces->mNumIndices)
|
if (4 == faces->mNumIndices)
|
||||||
{
|
{
|
||||||
if(five)++faces->mNumIndices;
|
if(five)++faces->mNumIndices;
|
||||||
five = !five;
|
five = !five;
|
||||||
}
|
}
|
||||||
faces->mIndices = new unsigned int[faces->mNumIndices];
|
faces->mIndices = new unsigned int[faces->mNumIndices];
|
||||||
for (unsigned int q = 0; q <faces->mNumIndices;++q,++n)
|
for (unsigned int q = 0; q <faces->mNumIndices;++q,++n)
|
||||||
{
|
{
|
||||||
faces->mIndices[q] = n;
|
faces->mIndices[q] = n;
|
||||||
float f = (float)remaining[idx];
|
float f = (float)remaining[idx];
|
||||||
|
|
||||||
// (the values need to be unique - otherwise all degenerates would be removed)
|
// (the values need to be unique - otherwise all degenerates would be removed)
|
||||||
*pv++ = aiVector3D(f,f+1.f,f+q);
|
*pv++ = aiVector3D(f,f+1.f,f+q);
|
||||||
*pn++ = aiVector3D(f,f+1.f,f+q);
|
*pn++ = aiVector3D(f,f+1.f,f+q);
|
||||||
*pt++ = aiVector3D(f,f+1.f,f+q);
|
*pt++ = aiVector3D(f,f+1.f,f+q);
|
||||||
*pb++ = aiVector3D(f,f+1.f,f+q);
|
*pb++ = aiVector3D(f,f+1.f,f+q);
|
||||||
*puv++ = aiVector3D(f,f+1.f,f+q);
|
*puv++ = aiVector3D(f,f+1.f,f+q);
|
||||||
}
|
}
|
||||||
++faces;
|
++faces;
|
||||||
--remaining[idx];
|
--remaining[idx];
|
||||||
}
|
}
|
||||||
mesh->mNumVertices = n;
|
mesh->mNumVertices = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
scene->mRootNode = new aiNode();
|
scene->mRootNode = new aiNode();
|
||||||
scene->mRootNode->mNumChildren = 5;
|
scene->mRootNode->mNumChildren = 5;
|
||||||
scene->mRootNode->mChildren = new aiNode*[5];
|
scene->mRootNode->mChildren = new aiNode*[5];
|
||||||
for (unsigned int i = 0; i< 5;++i )
|
for (unsigned int i = 0; i< 5;++i )
|
||||||
{
|
{
|
||||||
aiNode* node = scene->mRootNode->mChildren[i] = new aiNode();
|
aiNode* node = scene->mRootNode->mChildren[i] = new aiNode();
|
||||||
node->mNumMeshes = 2;
|
node->mNumMeshes = 2;
|
||||||
node->mMeshes = new unsigned int[2];
|
node->mMeshes = new unsigned int[2];
|
||||||
node->mMeshes[0] = (i<<1u);
|
node->mMeshes[0] = (i<<1u);
|
||||||
node->mMeshes[1] = (i<<1u)+1;
|
node->mMeshes[1] = (i<<1u)+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SortByPTypeProcessTest::TearDown()
|
void SortByPTypeProcessTest::TearDown()
|
||||||
{
|
{
|
||||||
//delete process0;
|
//delete process0;
|
||||||
delete process1;
|
delete process1;
|
||||||
delete scene;
|
delete scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
//TEST_F(SortByPTypeProcessTest, DeterminePTypeStep()
|
//TEST_F(SortByPTypeProcessTest, DeterminePTypeStep()
|
||||||
//{
|
//{
|
||||||
// process0->Execute(scene);
|
// process0->Execute(scene);
|
||||||
//
|
//
|
||||||
// for (unsigned int i = 0; i < 10; ++i)
|
// for (unsigned int i = 0; i < 10; ++i)
|
||||||
// {
|
// {
|
||||||
// aiMesh* mesh = scene->mMeshes[i];
|
// aiMesh* mesh = scene->mMeshes[i];
|
||||||
// EXPECT_TRUE(mesh->mPrimitiveTypes == result[i]);
|
// EXPECT_TRUE(mesh->mPrimitiveTypes == result[i]);
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(SortByPTypeProcessTest, SortByPTypeStep)
|
TEST_F(SortByPTypeProcessTest, SortByPTypeStep)
|
||||||
{
|
{
|
||||||
// process0->Execute(scene);
|
// process0->Execute(scene);
|
||||||
|
|
||||||
// and another small test for ScenePreprocessor
|
// and another small test for ScenePreprocessor
|
||||||
ScenePreprocessor s(scene);
|
ScenePreprocessor s(scene);
|
||||||
s.ProcessScene();
|
s.ProcessScene();
|
||||||
for (unsigned int m = 0; m< 10;++m)
|
for (unsigned int m = 0; m< 10;++m)
|
||||||
EXPECT_EQ(result[m], scene->mMeshes[m]->mPrimitiveTypes);
|
EXPECT_EQ(result[m], scene->mMeshes[m]->mPrimitiveTypes);
|
||||||
|
|
||||||
process1->Execute(scene);
|
process1->Execute(scene);
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
if ((idx = num[m][n]))
|
if ((idx = num[m][n]))
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(real < scene->mNumMeshes);
|
EXPECT_TRUE(real < scene->mNumMeshes);
|
||||||
|
|
||||||
aiMesh* mesh = scene->mMeshes[real];
|
aiMesh* mesh = scene->mMeshes[real];
|
||||||
|
|
||||||
EXPECT_TRUE(NULL != mesh);
|
EXPECT_TRUE(NULL != mesh);
|
||||||
EXPECT_EQ(AI_PRIMITIVE_TYPE_FOR_N_INDICES(n+1), mesh->mPrimitiveTypes);
|
EXPECT_EQ(AI_PRIMITIVE_TYPE_FOR_N_INDICES(n+1), mesh->mPrimitiveTypes);
|
||||||
EXPECT_TRUE(NULL != mesh->mVertices);
|
EXPECT_TRUE(NULL != mesh->mVertices);
|
||||||
EXPECT_TRUE(NULL != mesh->mNormals);
|
EXPECT_TRUE(NULL != mesh->mNormals);
|
||||||
EXPECT_TRUE(NULL != mesh->mTangents);
|
EXPECT_TRUE(NULL != mesh->mTangents);
|
||||||
EXPECT_TRUE(NULL != mesh->mBitangents);
|
EXPECT_TRUE(NULL != mesh->mBitangents);
|
||||||
EXPECT_TRUE(NULL != mesh->mTextureCoords[0]);
|
EXPECT_TRUE(NULL != mesh->mTextureCoords[0]);
|
||||||
|
|
||||||
EXPECT_TRUE(mesh->mNumFaces == idx);
|
EXPECT_TRUE(mesh->mNumFaces == idx);
|
||||||
for (unsigned int f = 0; f < mesh->mNumFaces;++f)
|
for (unsigned int f = 0; f < mesh->mNumFaces;++f)
|
||||||
{
|
{
|
||||||
aiFace& face = mesh->mFaces[f];
|
aiFace& face = mesh->mFaces[f];
|
||||||
EXPECT_TRUE(face.mNumIndices == (n+1) || (3 == n && face.mNumIndices > 3));
|
EXPECT_TRUE(face.mNumIndices == (n+1) || (3 == n && face.mNumIndices > 3));
|
||||||
}
|
}
|
||||||
++real;
|
++real;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,127 +1,127 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <SplitLargeMeshes.h>
|
#include <SplitLargeMeshes.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class SplitLargeMeshesTest : public ::testing::Test
|
class SplitLargeMeshesTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SplitLargeMeshesProcess_Triangle* piProcessTriangle;
|
SplitLargeMeshesProcess_Triangle* piProcessTriangle;
|
||||||
SplitLargeMeshesProcess_Vertex* piProcessVertex;
|
SplitLargeMeshesProcess_Vertex* piProcessVertex;
|
||||||
aiMesh* pcMesh1;
|
aiMesh* pcMesh1;
|
||||||
aiMesh* pcMesh2;
|
aiMesh* pcMesh2;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SplitLargeMeshesTest::SetUp()
|
void SplitLargeMeshesTest::SetUp()
|
||||||
{
|
{
|
||||||
// construct the processes
|
// construct the processes
|
||||||
this->piProcessTriangle = new SplitLargeMeshesProcess_Triangle();
|
this->piProcessTriangle = new SplitLargeMeshesProcess_Triangle();
|
||||||
this->piProcessVertex = new SplitLargeMeshesProcess_Vertex();
|
this->piProcessVertex = new SplitLargeMeshesProcess_Vertex();
|
||||||
|
|
||||||
this->piProcessTriangle->SetLimit(1000);
|
this->piProcessTriangle->SetLimit(1000);
|
||||||
this->piProcessVertex->SetLimit(1000);
|
this->piProcessVertex->SetLimit(1000);
|
||||||
|
|
||||||
this->pcMesh1 = new aiMesh();
|
this->pcMesh1 = new aiMesh();
|
||||||
pcMesh1->mNumVertices = 2100; // quersumme: 3
|
pcMesh1->mNumVertices = 2100; // quersumme: 3
|
||||||
pcMesh1->mVertices = new aiVector3D[pcMesh1->mNumVertices];
|
pcMesh1->mVertices = new aiVector3D[pcMesh1->mNumVertices];
|
||||||
pcMesh1->mNormals = new aiVector3D[pcMesh1->mNumVertices];
|
pcMesh1->mNormals = new aiVector3D[pcMesh1->mNumVertices];
|
||||||
|
|
||||||
pcMesh1->mNumFaces = pcMesh1->mNumVertices / 3;
|
pcMesh1->mNumFaces = pcMesh1->mNumVertices / 3;
|
||||||
pcMesh1->mFaces = new aiFace[pcMesh1->mNumFaces];
|
pcMesh1->mFaces = new aiFace[pcMesh1->mNumFaces];
|
||||||
|
|
||||||
unsigned int qq = 0;
|
unsigned int qq = 0;
|
||||||
for (unsigned int i = 0; i < pcMesh1->mNumFaces;++i)
|
for (unsigned int i = 0; i < pcMesh1->mNumFaces;++i)
|
||||||
{
|
{
|
||||||
aiFace& face = pcMesh1->mFaces[i];
|
aiFace& face = pcMesh1->mFaces[i];
|
||||||
face.mNumIndices = 3;
|
face.mNumIndices = 3;
|
||||||
face.mIndices = new unsigned int[3];
|
face.mIndices = new unsigned int[3];
|
||||||
face.mIndices[0] = qq++;
|
face.mIndices[0] = qq++;
|
||||||
face.mIndices[1] = qq++;
|
face.mIndices[1] = qq++;
|
||||||
face.mIndices[2] = qq++;
|
face.mIndices[2] = qq++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate many, many faces with randomized indices for
|
// generate many, many faces with randomized indices for
|
||||||
// the second mesh
|
// the second mesh
|
||||||
this->pcMesh2 = new aiMesh();
|
this->pcMesh2 = new aiMesh();
|
||||||
pcMesh2->mNumVertices = 3000;
|
pcMesh2->mNumVertices = 3000;
|
||||||
pcMesh2->mVertices = new aiVector3D[pcMesh2->mNumVertices];
|
pcMesh2->mVertices = new aiVector3D[pcMesh2->mNumVertices];
|
||||||
pcMesh2->mNormals = new aiVector3D[pcMesh2->mNumVertices];
|
pcMesh2->mNormals = new aiVector3D[pcMesh2->mNumVertices];
|
||||||
|
|
||||||
pcMesh2->mNumFaces = 10000;
|
pcMesh2->mNumFaces = 10000;
|
||||||
pcMesh2->mFaces = new aiFace[pcMesh2->mNumFaces];
|
pcMesh2->mFaces = new aiFace[pcMesh2->mNumFaces];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pcMesh2->mNumFaces;++i)
|
for (unsigned int i = 0; i < pcMesh2->mNumFaces;++i)
|
||||||
{
|
{
|
||||||
aiFace& face = pcMesh2->mFaces[i];
|
aiFace& face = pcMesh2->mFaces[i];
|
||||||
face.mNumIndices = 3;
|
face.mNumIndices = 3;
|
||||||
face.mIndices = new unsigned int[3];
|
face.mIndices = new unsigned int[3];
|
||||||
face.mIndices[0] = (unsigned int)((rand() / (float)RAND_MAX) * pcMesh2->mNumVertices);
|
face.mIndices[0] = (unsigned int)((rand() / (float)RAND_MAX) * pcMesh2->mNumVertices);
|
||||||
face.mIndices[1] = (unsigned int)((rand() / (float)RAND_MAX) * pcMesh2->mNumVertices);
|
face.mIndices[1] = (unsigned int)((rand() / (float)RAND_MAX) * pcMesh2->mNumVertices);
|
||||||
face.mIndices[2] = (unsigned int)((rand() / (float)RAND_MAX) * pcMesh2->mNumVertices);
|
face.mIndices[2] = (unsigned int)((rand() / (float)RAND_MAX) * pcMesh2->mNumVertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SplitLargeMeshesTest::TearDown()
|
void SplitLargeMeshesTest::TearDown()
|
||||||
{
|
{
|
||||||
delete this->piProcessTriangle;
|
delete this->piProcessTriangle;
|
||||||
delete this->piProcessVertex;
|
delete this->piProcessVertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(SplitLargeMeshesTest, testVertexSplit)
|
TEST_F(SplitLargeMeshesTest, testVertexSplit)
|
||||||
{
|
{
|
||||||
std::vector< std::pair<aiMesh*, unsigned int> > avOut;
|
std::vector< std::pair<aiMesh*, unsigned int> > avOut;
|
||||||
|
|
||||||
int iOldFaceNum = (int)pcMesh1->mNumFaces;
|
int iOldFaceNum = (int)pcMesh1->mNumFaces;
|
||||||
piProcessVertex->SplitMesh(0,pcMesh1,avOut);
|
piProcessVertex->SplitMesh(0,pcMesh1,avOut);
|
||||||
|
|
||||||
for (std::vector< std::pair<aiMesh*, unsigned int> >::const_iterator
|
for (std::vector< std::pair<aiMesh*, unsigned int> >::const_iterator
|
||||||
iter = avOut.begin(), end = avOut.end();
|
iter = avOut.begin(), end = avOut.end();
|
||||||
iter != end; ++iter)
|
iter != end; ++iter)
|
||||||
{
|
{
|
||||||
aiMesh* mesh = (*iter).first;
|
aiMesh* mesh = (*iter).first;
|
||||||
EXPECT_LT(mesh->mNumVertices, 1000U);
|
EXPECT_LT(mesh->mNumVertices, 1000U);
|
||||||
EXPECT_TRUE(NULL != mesh->mNormals);
|
EXPECT_TRUE(NULL != mesh->mNormals);
|
||||||
EXPECT_TRUE(NULL != mesh->mVertices);
|
EXPECT_TRUE(NULL != mesh->mVertices);
|
||||||
|
|
||||||
iOldFaceNum -= mesh->mNumFaces;
|
iOldFaceNum -= mesh->mNumFaces;
|
||||||
delete mesh;
|
delete mesh;
|
||||||
}
|
}
|
||||||
EXPECT_EQ(0, iOldFaceNum);
|
EXPECT_EQ(0, iOldFaceNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(SplitLargeMeshesTest, testTriangleSplit)
|
TEST_F(SplitLargeMeshesTest, testTriangleSplit)
|
||||||
{
|
{
|
||||||
std::vector< std::pair<aiMesh*, unsigned int> > avOut;
|
std::vector< std::pair<aiMesh*, unsigned int> > avOut;
|
||||||
|
|
||||||
// the number of faces shouldn't change
|
// the number of faces shouldn't change
|
||||||
int iOldFaceNum = (int)pcMesh2->mNumFaces;
|
int iOldFaceNum = (int)pcMesh2->mNumFaces;
|
||||||
piProcessTriangle->SplitMesh(0,pcMesh2,avOut);
|
piProcessTriangle->SplitMesh(0,pcMesh2,avOut);
|
||||||
|
|
||||||
for (std::vector< std::pair<aiMesh*, unsigned int> >::const_iterator
|
for (std::vector< std::pair<aiMesh*, unsigned int> >::const_iterator
|
||||||
iter = avOut.begin(), end = avOut.end();
|
iter = avOut.begin(), end = avOut.end();
|
||||||
iter != end; ++iter)
|
iter != end; ++iter)
|
||||||
{
|
{
|
||||||
aiMesh* mesh = (*iter).first;
|
aiMesh* mesh = (*iter).first;
|
||||||
EXPECT_LT(mesh->mNumFaces, 1000U);
|
EXPECT_LT(mesh->mNumFaces, 1000U);
|
||||||
EXPECT_TRUE(NULL != mesh->mNormals);
|
EXPECT_TRUE(NULL != mesh->mNormals);
|
||||||
EXPECT_TRUE(NULL != mesh->mVertices);
|
EXPECT_TRUE(NULL != mesh->mVertices);
|
||||||
|
|
||||||
iOldFaceNum -= mesh->mNumFaces;
|
iOldFaceNum -= mesh->mNumFaces;
|
||||||
delete mesh;
|
delete mesh;
|
||||||
}
|
}
|
||||||
EXPECT_EQ(0, iOldFaceNum);
|
EXPECT_EQ(0, iOldFaceNum);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
|
@ -1,113 +1,113 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <TriangulateProcess.h>
|
#include <TriangulateProcess.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class TriangulateProcessTest : public ::testing::Test
|
class TriangulateProcessTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
aiMesh* pcMesh;
|
aiMesh* pcMesh;
|
||||||
TriangulateProcess* piProcess;
|
TriangulateProcess* piProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
void TriangulateProcessTest::SetUp()
|
void TriangulateProcessTest::SetUp()
|
||||||
{
|
{
|
||||||
piProcess = new TriangulateProcess();
|
piProcess = new TriangulateProcess();
|
||||||
pcMesh = new aiMesh();
|
pcMesh = new aiMesh();
|
||||||
|
|
||||||
pcMesh->mNumFaces = 1000;
|
pcMesh->mNumFaces = 1000;
|
||||||
pcMesh->mFaces = new aiFace[1000];
|
pcMesh->mFaces = new aiFace[1000];
|
||||||
pcMesh->mVertices = new aiVector3D[10000];
|
pcMesh->mVertices = new aiVector3D[10000];
|
||||||
|
|
||||||
pcMesh->mPrimitiveTypes = aiPrimitiveType_POINT | aiPrimitiveType_LINE |
|
pcMesh->mPrimitiveTypes = aiPrimitiveType_POINT | aiPrimitiveType_LINE |
|
||||||
aiPrimitiveType_LINE | aiPrimitiveType_POLYGON;
|
aiPrimitiveType_LINE | aiPrimitiveType_POLYGON;
|
||||||
|
|
||||||
for (unsigned int m = 0, t = 0, q = 4; m < 1000; ++m)
|
for (unsigned int m = 0, t = 0, q = 4; m < 1000; ++m)
|
||||||
{
|
{
|
||||||
++t;
|
++t;
|
||||||
aiFace& face = pcMesh->mFaces[m];
|
aiFace& face = pcMesh->mFaces[m];
|
||||||
face.mNumIndices = t;
|
face.mNumIndices = t;
|
||||||
if (4 == t)
|
if (4 == t)
|
||||||
{
|
{
|
||||||
face.mNumIndices = q++;
|
face.mNumIndices = q++;
|
||||||
t = 0;
|
t = 0;
|
||||||
|
|
||||||
if (10 == q)q = 4;
|
if (10 == q)q = 4;
|
||||||
}
|
}
|
||||||
face.mIndices = new unsigned int[face.mNumIndices];
|
face.mIndices = new unsigned int[face.mNumIndices];
|
||||||
for (unsigned int p = 0; p < face.mNumIndices; ++p)
|
for (unsigned int p = 0; p < face.mNumIndices; ++p)
|
||||||
{
|
{
|
||||||
face.mIndices[p] = pcMesh->mNumVertices;
|
face.mIndices[p] = pcMesh->mNumVertices;
|
||||||
|
|
||||||
// construct fully convex input data in ccw winding, xy plane
|
// construct fully convex input data in ccw winding, xy plane
|
||||||
aiVector3D& v = pcMesh->mVertices[pcMesh->mNumVertices++];
|
aiVector3D& v = pcMesh->mVertices[pcMesh->mNumVertices++];
|
||||||
v.z = 0.f;
|
v.z = 0.f;
|
||||||
v.x = cos (p * (float)(AI_MATH_TWO_PI)/face.mNumIndices);
|
v.x = cos (p * (float)(AI_MATH_TWO_PI)/face.mNumIndices);
|
||||||
v.y = sin (p * (float)(AI_MATH_TWO_PI)/face.mNumIndices);
|
v.y = sin (p * (float)(AI_MATH_TWO_PI)/face.mNumIndices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriangulateProcessTest::TearDown()
|
void TriangulateProcessTest::TearDown()
|
||||||
{
|
{
|
||||||
delete piProcess;
|
delete piProcess;
|
||||||
delete pcMesh;
|
delete pcMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TriangulateProcessTest, testTriangulation)
|
TEST_F(TriangulateProcessTest, testTriangulation)
|
||||||
{
|
{
|
||||||
piProcess->TriangulateMesh(pcMesh);
|
piProcess->TriangulateMesh(pcMesh);
|
||||||
|
|
||||||
for (unsigned int m = 0, t = 0, q = 4, max = 1000, idx = 0; m < max;++m)
|
for (unsigned int m = 0, t = 0, q = 4, max = 1000, idx = 0; m < max;++m)
|
||||||
{
|
{
|
||||||
++t;
|
++t;
|
||||||
aiFace& face = pcMesh->mFaces[m];
|
aiFace& face = pcMesh->mFaces[m];
|
||||||
if (4 == t)
|
if (4 == t)
|
||||||
{
|
{
|
||||||
t = 0;
|
t = 0;
|
||||||
max += q-3;
|
max += q-3;
|
||||||
|
|
||||||
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];
|
aiFace& face = pcMesh->mFaces[m];
|
||||||
EXPECT_EQ(3U, face.mNumIndices);
|
EXPECT_EQ(3U, face.mNumIndices);
|
||||||
|
|
||||||
for (unsigned int qqq = 0; qqq < face.mNumIndices; ++qqq)
|
for (unsigned int qqq = 0; qqq < face.mNumIndices; ++qqq)
|
||||||
{
|
{
|
||||||
ait[face.mIndices[qqq]-idx] = true;
|
ait[face.mIndices[qqq]-idx] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (std::vector<bool>::const_iterator it = ait.begin(); it != ait.end(); ++it)
|
for (std::vector<bool>::const_iterator it = ait.begin(); it != ait.end(); ++it)
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(*it);
|
EXPECT_TRUE(*it);
|
||||||
}
|
}
|
||||||
--m;
|
--m;
|
||||||
idx+=q;
|
idx+=q;
|
||||||
if(++q == 10)q = 4;
|
if(++q == 10)q = 4;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EXPECT_EQ(t, face.mNumIndices);
|
EXPECT_EQ(t, face.mNumIndices);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < face.mNumIndices; ++i,++idx)
|
for (unsigned int i = 0; i < face.mNumIndices; ++i,++idx)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(idx, face.mIndices[i]);
|
EXPECT_EQ(idx, face.mIndices[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we should have no valid normal vectors now necause we aren't a pure polygon mesh
|
// we should have no valid normal vectors now necause we aren't a pure polygon mesh
|
||||||
EXPECT_TRUE(pcMesh->mNormals == NULL);
|
EXPECT_TRUE(pcMesh->mNormals == NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,184 +1,184 @@
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include "assimp/types.h"
|
#include "assimp/types.h"
|
||||||
#include "assimp/mesh.h"
|
#include "assimp/mesh.h"
|
||||||
|
|
||||||
#include <VertexTriangleAdjacency.h>
|
#include <VertexTriangleAdjacency.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class VTAdjacencyTest : public ::testing::Test
|
class VTAdjacencyTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void checkMesh(const aiMesh& mesh);
|
void checkMesh(const aiMesh& mesh);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(VTAdjacencyTest, largeRandomDataSet)
|
TEST_F(VTAdjacencyTest, largeRandomDataSet)
|
||||||
{
|
{
|
||||||
// build a test mesh with randomized input data
|
// build a test mesh with randomized input data
|
||||||
// *******************************************************************************
|
// *******************************************************************************
|
||||||
aiMesh mesh;
|
aiMesh mesh;
|
||||||
|
|
||||||
mesh.mNumVertices = 500;
|
mesh.mNumVertices = 500;
|
||||||
mesh.mNumFaces = 600;
|
mesh.mNumFaces = 600;
|
||||||
|
|
||||||
mesh.mFaces = new aiFace[600];
|
mesh.mFaces = new aiFace[600];
|
||||||
unsigned int iCurrent = 0;
|
unsigned int iCurrent = 0;
|
||||||
for (unsigned int i = 0; i < 600;++i)
|
for (unsigned int i = 0; i < 600;++i)
|
||||||
{
|
{
|
||||||
aiFace& face = mesh.mFaces[i];
|
aiFace& face = mesh.mFaces[i];
|
||||||
face.mNumIndices = 3;
|
face.mNumIndices = 3;
|
||||||
face.mIndices = new unsigned int[3];
|
face.mIndices = new unsigned int[3];
|
||||||
|
|
||||||
if (499 == iCurrent)iCurrent = 0;
|
if (499 == iCurrent)iCurrent = 0;
|
||||||
face.mIndices[0] = iCurrent++;
|
face.mIndices[0] = iCurrent++;
|
||||||
|
|
||||||
|
|
||||||
while(face.mIndices[0] == ( face.mIndices[1] = (unsigned int)(((float)rand()/RAND_MAX)*499)));
|
while(face.mIndices[0] == ( face.mIndices[1] = (unsigned int)(((float)rand()/RAND_MAX)*499)));
|
||||||
while(face.mIndices[0] == ( face.mIndices[2] = (unsigned int)(((float)rand()/RAND_MAX)*499)) ||
|
while(face.mIndices[0] == ( face.mIndices[2] = (unsigned int)(((float)rand()/RAND_MAX)*499)) ||
|
||||||
face.mIndices[1] == face.mIndices[2]);
|
face.mIndices[1] == face.mIndices[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMesh(mesh);
|
checkMesh(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(VTAdjacencyTest, smallDataSet)
|
TEST_F(VTAdjacencyTest, smallDataSet)
|
||||||
{
|
{
|
||||||
|
|
||||||
// build a test mesh - this one is extremely small
|
// build a test mesh - this one is extremely small
|
||||||
// *******************************************************************************
|
// *******************************************************************************
|
||||||
aiMesh mesh;
|
aiMesh mesh;
|
||||||
|
|
||||||
mesh.mNumVertices = 5;
|
mesh.mNumVertices = 5;
|
||||||
mesh.mNumFaces = 3;
|
mesh.mNumFaces = 3;
|
||||||
|
|
||||||
mesh.mFaces = new aiFace[3];
|
mesh.mFaces = new aiFace[3];
|
||||||
mesh.mFaces[0].mIndices = new unsigned int[3];
|
mesh.mFaces[0].mIndices = new unsigned int[3];
|
||||||
mesh.mFaces[1].mIndices = new unsigned int[3];
|
mesh.mFaces[1].mIndices = new unsigned int[3];
|
||||||
mesh.mFaces[2].mIndices = new unsigned int[3];
|
mesh.mFaces[2].mIndices = new unsigned int[3];
|
||||||
|
|
||||||
mesh.mFaces[0].mIndices[0] = 1;
|
mesh.mFaces[0].mIndices[0] = 1;
|
||||||
mesh.mFaces[0].mIndices[1] = 3;
|
mesh.mFaces[0].mIndices[1] = 3;
|
||||||
mesh.mFaces[0].mIndices[2] = 2;
|
mesh.mFaces[0].mIndices[2] = 2;
|
||||||
|
|
||||||
mesh.mFaces[1].mIndices[0] = 0;
|
mesh.mFaces[1].mIndices[0] = 0;
|
||||||
mesh.mFaces[1].mIndices[1] = 2;
|
mesh.mFaces[1].mIndices[1] = 2;
|
||||||
mesh.mFaces[1].mIndices[2] = 3;
|
mesh.mFaces[1].mIndices[2] = 3;
|
||||||
|
|
||||||
mesh.mFaces[2].mIndices[0] = 3;
|
mesh.mFaces[2].mIndices[0] = 3;
|
||||||
mesh.mFaces[2].mIndices[1] = 0;
|
mesh.mFaces[2].mIndices[1] = 0;
|
||||||
mesh.mFaces[2].mIndices[2] = 4;
|
mesh.mFaces[2].mIndices[2] = 4;
|
||||||
|
|
||||||
checkMesh(mesh);
|
checkMesh(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(VTAdjacencyTest, unreferencedVerticesSet)
|
TEST_F(VTAdjacencyTest, unreferencedVerticesSet)
|
||||||
{
|
{
|
||||||
// build a test mesh which does not reference all vertices
|
// build a test mesh which does not reference all vertices
|
||||||
// *******************************************************************************
|
// *******************************************************************************
|
||||||
aiMesh mesh;
|
aiMesh mesh;
|
||||||
|
|
||||||
mesh.mNumVertices = 500;
|
mesh.mNumVertices = 500;
|
||||||
mesh.mNumFaces = 600;
|
mesh.mNumFaces = 600;
|
||||||
|
|
||||||
mesh.mFaces = new aiFace[600];
|
mesh.mFaces = new aiFace[600];
|
||||||
unsigned int iCurrent = 0;
|
unsigned int iCurrent = 0;
|
||||||
for (unsigned int i = 0; i < 600;++i)
|
for (unsigned int i = 0; i < 600;++i)
|
||||||
{
|
{
|
||||||
aiFace& face = mesh.mFaces[i];
|
aiFace& face = mesh.mFaces[i];
|
||||||
face.mNumIndices = 3;
|
face.mNumIndices = 3;
|
||||||
face.mIndices = new unsigned int[3];
|
face.mIndices = new unsigned int[3];
|
||||||
|
|
||||||
if (499 == iCurrent)iCurrent = 0;
|
if (499 == iCurrent)iCurrent = 0;
|
||||||
face.mIndices[0] = iCurrent++;
|
face.mIndices[0] = iCurrent++;
|
||||||
|
|
||||||
if (499 == iCurrent)iCurrent = 0;
|
if (499 == iCurrent)iCurrent = 0;
|
||||||
face.mIndices[1] = iCurrent++;
|
face.mIndices[1] = iCurrent++;
|
||||||
|
|
||||||
if (499 == iCurrent)iCurrent = 0;
|
if (499 == iCurrent)iCurrent = 0;
|
||||||
face.mIndices[2] = iCurrent++;
|
face.mIndices[2] = iCurrent++;
|
||||||
|
|
||||||
if (rand() > RAND_MAX/2 && face.mIndices[0])
|
if (rand() > RAND_MAX/2 && face.mIndices[0])
|
||||||
{
|
{
|
||||||
face.mIndices[0]--;
|
face.mIndices[0]--;
|
||||||
}
|
}
|
||||||
else if (face.mIndices[1]) face.mIndices[1]--;
|
else if (face.mIndices[1]) face.mIndices[1]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMesh(mesh);
|
checkMesh(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void VTAdjacencyTest::checkMesh(const aiMesh& mesh)
|
void VTAdjacencyTest::checkMesh(const aiMesh& mesh)
|
||||||
{
|
{
|
||||||
VertexTriangleAdjacency adj(mesh.mFaces,mesh.mNumFaces,mesh.mNumVertices,true);
|
VertexTriangleAdjacency adj(mesh.mFaces,mesh.mNumFaces,mesh.mNumVertices,true);
|
||||||
|
|
||||||
unsigned int* const piNum = adj.mLiveTriangles;
|
unsigned int* const piNum = adj.mLiveTriangles;
|
||||||
|
|
||||||
// check the primary adjacency table and check whether all faces
|
// check the primary adjacency table and check whether all faces
|
||||||
// are contained in the list
|
// are contained in the list
|
||||||
unsigned int maxOfs = 0;
|
unsigned int maxOfs = 0;
|
||||||
for (unsigned int i = 0; i < mesh.mNumFaces;++i)
|
for (unsigned int i = 0; i < mesh.mNumFaces;++i)
|
||||||
{
|
{
|
||||||
aiFace& face = mesh.mFaces[i];
|
aiFace& face = mesh.mFaces[i];
|
||||||
for (unsigned int qq = 0; qq < 3 ;++qq)
|
for (unsigned int qq = 0; qq < 3 ;++qq)
|
||||||
{
|
{
|
||||||
const unsigned int idx = face.mIndices[qq];
|
const unsigned int idx = face.mIndices[qq];
|
||||||
const unsigned int num = piNum[idx];
|
const unsigned int num = piNum[idx];
|
||||||
|
|
||||||
// go to this offset
|
// go to this offset
|
||||||
const unsigned int ofs = adj.mOffsetTable[idx];
|
const unsigned int ofs = adj.mOffsetTable[idx];
|
||||||
maxOfs = std::max(ofs+num,maxOfs);
|
maxOfs = std::max(ofs+num,maxOfs);
|
||||||
unsigned int* pi = &adj.mAdjacencyTable[ofs];
|
unsigned int* pi = &adj.mAdjacencyTable[ofs];
|
||||||
|
|
||||||
// and search for us ...
|
// and search for us ...
|
||||||
unsigned int tt = 0;
|
unsigned int tt = 0;
|
||||||
for (; tt < num;++tt,++pi)
|
for (; tt < num;++tt,++pi)
|
||||||
{
|
{
|
||||||
if (i == *pi)
|
if (i == *pi)
|
||||||
{
|
{
|
||||||
// mask our entry in the table. Finally all entries should be masked
|
// mask our entry in the table. Finally all entries should be masked
|
||||||
*pi = 0xffffffff;
|
*pi = 0xffffffff;
|
||||||
|
|
||||||
// there shouldn't be two entries for the same face
|
// there shouldn't be two entries for the same face
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// assert if *this* vertex has not been found in the table
|
// assert if *this* vertex has not been found in the table
|
||||||
EXPECT_LT(tt, num);
|
EXPECT_LT(tt, num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now check whether there are invalid faces
|
// now check whether there are invalid faces
|
||||||
const unsigned int* pi = adj.mAdjacencyTable;
|
const unsigned int* pi = adj.mAdjacencyTable;
|
||||||
for (unsigned int i = 0; i < maxOfs;++i,++pi)
|
for (unsigned int i = 0; i < maxOfs;++i,++pi)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(0xffffffff, *pi);
|
EXPECT_EQ(0xffffffff, *pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the numTrianglesPerVertex table
|
// check the numTrianglesPerVertex table
|
||||||
for (unsigned int i = 0; i < mesh.mNumFaces;++i)
|
for (unsigned int i = 0; i < mesh.mNumFaces;++i)
|
||||||
{
|
{
|
||||||
aiFace& face = mesh.mFaces[i];
|
aiFace& face = mesh.mFaces[i];
|
||||||
for (unsigned int qq = 0; qq < 3 ;++qq)
|
for (unsigned int qq = 0; qq < 3 ;++qq)
|
||||||
{
|
{
|
||||||
const unsigned int idx = face.mIndices[qq];
|
const unsigned int idx = face.mIndices[qq];
|
||||||
|
|
||||||
// we should not reach 0 here ...
|
// we should not reach 0 here ...
|
||||||
EXPECT_NE(0U, piNum[idx]);
|
EXPECT_NE(0U, piNum[idx]);
|
||||||
piNum[idx]--;
|
piNum[idx]--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check whether we reached 0 in all entries
|
// check whether we reached 0 in all entries
|
||||||
for (unsigned int i = 0; i < mesh.mNumVertices;++i)
|
for (unsigned int i = 0; i < mesh.mNumVertices;++i)
|
||||||
{
|
{
|
||||||
EXPECT_FALSE(piNum[i]);
|
EXPECT_FALSE(piNum[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue