reformat unittests.
parent
edc73552cd
commit
68a9fa2df3
|
@ -42,51 +42,50 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// Actually just a dummy, used by the compiler to build the precompiled header.
|
// Actually just a dummy, used by the compiler to build the precompiled header.
|
||||||
|
|
||||||
#include <assimp/version.h>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "ScenePrivate.h"
|
#include "ScenePrivate.h"
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/version.h>
|
||||||
|
|
||||||
#include "revision.h"
|
#include "revision.h"
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
// Legal information string - don't remove this.
|
// Legal information string - don't remove this.
|
||||||
static const char* LEGAL_INFORMATION =
|
static const char *LEGAL_INFORMATION =
|
||||||
|
|
||||||
"Open Asset Import Library (Assimp).\n"
|
"Open Asset Import Library (Assimp).\n"
|
||||||
"A free C/C++ library to import various 3D file formats into applications\n\n"
|
"A free C/C++ library to import various 3D file formats into applications\n\n"
|
||||||
|
|
||||||
"(c) 2006-2020, assimp team\n"
|
"(c) 2006-2020, assimp team\n"
|
||||||
"License under the terms and conditions of the 3-clause BSD license\n"
|
"License under the terms and conditions of the 3-clause BSD license\n"
|
||||||
"http://assimp.org\n"
|
"http://assimp.org\n";
|
||||||
;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get legal string
|
// Get legal string
|
||||||
ASSIMP_API const char* aiGetLegalString () {
|
ASSIMP_API const char *aiGetLegalString() {
|
||||||
return LEGAL_INFORMATION;
|
return LEGAL_INFORMATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get Assimp patch version
|
// Get Assimp patch version
|
||||||
ASSIMP_API unsigned int aiGetVersionPatch() {
|
ASSIMP_API unsigned int aiGetVersionPatch() {
|
||||||
return VER_PATCH;
|
return VER_PATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get Assimp minor version
|
// Get Assimp minor version
|
||||||
ASSIMP_API unsigned int aiGetVersionMinor () {
|
ASSIMP_API unsigned int aiGetVersionMinor() {
|
||||||
return VER_MINOR;
|
return VER_MINOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get Assimp major version
|
// Get Assimp major version
|
||||||
ASSIMP_API unsigned int aiGetVersionMajor () {
|
ASSIMP_API unsigned int aiGetVersionMajor() {
|
||||||
return VER_MAJOR;
|
return VER_MAJOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get flags used for compilation
|
// Get flags used for compilation
|
||||||
ASSIMP_API unsigned int aiGetCompileFlags () {
|
ASSIMP_API unsigned int aiGetCompileFlags() {
|
||||||
|
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
|
|
||||||
|
@ -119,24 +118,9 @@ ASSIMP_API const char *aiGetBranchName() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
ASSIMP_API aiScene::aiScene()
|
ASSIMP_API aiScene::aiScene() :
|
||||||
: mFlags(0)
|
mFlags(0), mRootNode(nullptr), mNumMeshes(0), mMeshes(nullptr), mNumMaterials(0), mMaterials(nullptr), mNumAnimations(0), mAnimations(nullptr), mNumTextures(0), mTextures(nullptr), mNumLights(0), mLights(nullptr), mNumCameras(0), mCameras(nullptr), mMetaData(nullptr), mPrivate(new Assimp::ScenePrivateData()) {
|
||||||
, mRootNode(nullptr)
|
// empty
|
||||||
, mNumMeshes(0)
|
|
||||||
, mMeshes(nullptr)
|
|
||||||
, mNumMaterials(0)
|
|
||||||
, mMaterials(nullptr)
|
|
||||||
, mNumAnimations(0)
|
|
||||||
, mAnimations(nullptr)
|
|
||||||
, mNumTextures(0)
|
|
||||||
, mTextures(nullptr)
|
|
||||||
, mNumLights(0)
|
|
||||||
, mLights(nullptr)
|
|
||||||
, mNumCameras(0)
|
|
||||||
, mCameras(nullptr)
|
|
||||||
, mMetaData(nullptr)
|
|
||||||
, mPrivate(new Assimp::ScenePrivateData()) {
|
|
||||||
// empty
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -148,40 +132,39 @@ ASSIMP_API aiScene::~aiScene() {
|
||||||
// much better to check whether both mNumXXX and mXXX are
|
// much better to check whether both mNumXXX and mXXX are
|
||||||
// valid instead of relying on just one of them.
|
// valid instead of relying on just one of them.
|
||||||
if (mNumMeshes && mMeshes)
|
if (mNumMeshes && mMeshes)
|
||||||
for( unsigned int a = 0; a < mNumMeshes; a++)
|
for (unsigned int a = 0; a < mNumMeshes; a++)
|
||||||
delete mMeshes[a];
|
delete mMeshes[a];
|
||||||
delete [] mMeshes;
|
delete[] mMeshes;
|
||||||
|
|
||||||
if (mNumMaterials && mMaterials) {
|
if (mNumMaterials && mMaterials) {
|
||||||
for (unsigned int a = 0; a < mNumMaterials; ++a ) {
|
for (unsigned int a = 0; a < mNumMaterials; ++a) {
|
||||||
delete mMaterials[ a ];
|
delete mMaterials[a];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete [] mMaterials;
|
delete[] mMaterials;
|
||||||
|
|
||||||
if (mNumAnimations && mAnimations)
|
if (mNumAnimations && mAnimations)
|
||||||
for( unsigned int a = 0; a < mNumAnimations; a++)
|
for (unsigned int a = 0; a < mNumAnimations; a++)
|
||||||
delete mAnimations[a];
|
delete mAnimations[a];
|
||||||
delete [] mAnimations;
|
delete[] mAnimations;
|
||||||
|
|
||||||
if (mNumTextures && mTextures)
|
if (mNumTextures && mTextures)
|
||||||
for( unsigned int a = 0; a < mNumTextures; a++)
|
for (unsigned int a = 0; a < mNumTextures; a++)
|
||||||
delete mTextures[a];
|
delete mTextures[a];
|
||||||
delete [] mTextures;
|
delete[] mTextures;
|
||||||
|
|
||||||
if (mNumLights && mLights)
|
if (mNumLights && mLights)
|
||||||
for( unsigned int a = 0; a < mNumLights; a++)
|
for (unsigned int a = 0; a < mNumLights; a++)
|
||||||
delete mLights[a];
|
delete mLights[a];
|
||||||
delete [] mLights;
|
delete[] mLights;
|
||||||
|
|
||||||
if (mNumCameras && mCameras)
|
if (mNumCameras && mCameras)
|
||||||
for( unsigned int a = 0; a < mNumCameras; a++)
|
for (unsigned int a = 0; a < mNumCameras; a++)
|
||||||
delete mCameras[a];
|
delete mCameras[a];
|
||||||
delete [] mCameras;
|
delete[] mCameras;
|
||||||
|
|
||||||
aiMetadata::Dealloc(mMetaData);
|
aiMetadata::Dealloc(mMetaData);
|
||||||
mMetaData = nullptr;
|
mMetaData = nullptr;
|
||||||
|
|
||||||
delete static_cast<Assimp::ScenePrivateData*>( mPrivate );
|
delete static_cast<Assimp::ScenePrivateData *>(mPrivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -63,134 +61,132 @@ public:
|
||||||
// Test various import settings scenarios.
|
// Test various import settings scenarios.
|
||||||
|
|
||||||
void importSettings() {
|
void importSettings() {
|
||||||
|
|
||||||
/* Verify that animations are *NOT* imported when
|
/* Verify that animations are *NOT* imported when
|
||||||
'Read animations' is disabled. */
|
'Read animations' is disabled. */
|
||||||
load_with_import_setting_bool(
|
load_with_import_setting_bool(
|
||||||
MDL_HL1_FILE_MAN,
|
MDL_HL1_FILE_MAN,
|
||||||
AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS,
|
AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS,
|
||||||
false, // Set config value to false.
|
false, // Set config value to false.
|
||||||
[&](const aiScene *scene) {
|
[&](const aiScene *scene) {
|
||||||
EXPECT_EQ(0u, scene->mNumAnimations);
|
EXPECT_EQ(0u, scene->mNumAnimations);
|
||||||
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS));
|
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS));
|
||||||
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_GROUPS));
|
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_GROUPS));
|
||||||
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH));
|
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH));
|
||||||
|
|
||||||
expect_global_info_eq<int>(scene, {
|
expect_global_info_eq<int>(scene, { { 0, "NumSequences" },
|
||||||
{ 0, "NumSequences" },
|
{ 0, "NumTransitionNodes" } });
|
||||||
{ 0, "NumTransitionNodes" }
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
/* Verify that blend controllers info is *NOT* imported when
|
/* Verify that blend controllers info is *NOT* imported when
|
||||||
'Read blend controllers' is disabled. */
|
'Read blend controllers' is disabled. */
|
||||||
load_with_import_setting_bool(
|
load_with_import_setting_bool(
|
||||||
MDL_HL1_FILE_MAN,
|
MDL_HL1_FILE_MAN,
|
||||||
AI_CONFIG_IMPORT_MDL_HL1_READ_BLEND_CONTROLLERS,
|
AI_CONFIG_IMPORT_MDL_HL1_READ_BLEND_CONTROLLERS,
|
||||||
false, // Set config value to false.
|
false, // Set config value to false.
|
||||||
[&](const aiScene *scene) {
|
[&](const aiScene *scene) {
|
||||||
EXPECT_NE(0u, scene->mNumAnimations);
|
EXPECT_NE(0u, scene->mNumAnimations);
|
||||||
|
|
||||||
const aiNode *sequence_infos = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS);
|
const aiNode *sequence_infos = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS);
|
||||||
EXPECT_NE(nullptr, sequence_infos);
|
EXPECT_NE(nullptr, sequence_infos);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < sequence_infos->mNumChildren; ++i)
|
for (unsigned int i = 0; i < sequence_infos->mNumChildren; ++i)
|
||||||
EXPECT_EQ(nullptr, sequence_infos->mChildren[i]->FindNode(AI_MDL_HL1_NODE_BLEND_CONTROLLERS));
|
EXPECT_EQ(nullptr, sequence_infos->mChildren[i]->FindNode(AI_MDL_HL1_NODE_BLEND_CONTROLLERS));
|
||||||
|
|
||||||
expect_global_info_eq(scene, 0, "NumBlendControllers");
|
expect_global_info_eq(scene, 0, "NumBlendControllers");
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Verify that animation events are *NOT* imported when
|
/* Verify that animation events are *NOT* imported when
|
||||||
'Read animation events' is disabled. */
|
'Read animation events' is disabled. */
|
||||||
load_with_import_setting_bool(
|
load_with_import_setting_bool(
|
||||||
MDL_HL1_FILE_MAN,
|
MDL_HL1_FILE_MAN,
|
||||||
AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATION_EVENTS,
|
AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATION_EVENTS,
|
||||||
false, // Set config value to false.
|
false, // Set config value to false.
|
||||||
[&](const aiScene *scene) {
|
[&](const aiScene *scene) {
|
||||||
EXPECT_NE(0u, scene->mNumAnimations);
|
EXPECT_NE(0u, scene->mNumAnimations);
|
||||||
|
|
||||||
const aiNode *sequence_infos = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS);
|
const aiNode *sequence_infos = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS);
|
||||||
EXPECT_NE(nullptr, sequence_infos);
|
EXPECT_NE(nullptr, sequence_infos);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < sequence_infos->mNumChildren; ++i)
|
for (unsigned int i = 0; i < sequence_infos->mNumChildren; ++i)
|
||||||
EXPECT_EQ(nullptr, sequence_infos->mChildren[i]->FindNode(AI_MDL_HL1_NODE_ANIMATION_EVENTS));
|
EXPECT_EQ(nullptr, sequence_infos->mChildren[i]->FindNode(AI_MDL_HL1_NODE_ANIMATION_EVENTS));
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Verify that sequence transitions info is read when
|
/* Verify that sequence transitions info is read when
|
||||||
'Read sequence transitions' is enabled. */
|
'Read sequence transitions' is enabled. */
|
||||||
load_with_import_setting_bool(
|
load_with_import_setting_bool(
|
||||||
ASSIMP_TEST_MDL_HL1_MODELS_DIR "sequence_transitions.mdl",
|
ASSIMP_TEST_MDL_HL1_MODELS_DIR "sequence_transitions.mdl",
|
||||||
AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS,
|
AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS,
|
||||||
true, // Set config value to true.
|
true, // Set config value to true.
|
||||||
[&](const aiScene *scene) {
|
[&](const aiScene *scene) {
|
||||||
EXPECT_NE(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH));
|
EXPECT_NE(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH));
|
||||||
expect_global_info_eq(scene, 4, "NumTransitionNodes");
|
expect_global_info_eq(scene, 4, "NumTransitionNodes");
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Verify that sequence transitions info is *NOT* read when
|
/* Verify that sequence transitions info is *NOT* read when
|
||||||
'Read sequence transitions' is disabled. */
|
'Read sequence transitions' is disabled. */
|
||||||
load_with_import_setting_bool(
|
load_with_import_setting_bool(
|
||||||
ASSIMP_TEST_MDL_HL1_MODELS_DIR "sequence_transitions.mdl",
|
ASSIMP_TEST_MDL_HL1_MODELS_DIR "sequence_transitions.mdl",
|
||||||
AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS,
|
AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS,
|
||||||
false, // Set config value to false.
|
false, // Set config value to false.
|
||||||
[&](const aiScene *scene) {
|
[&](const aiScene *scene) {
|
||||||
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH));
|
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH));
|
||||||
expect_global_info_eq(scene, 0, "NumTransitionNodes");
|
expect_global_info_eq(scene, 0, "NumTransitionNodes");
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Verify that bone controllers info is *NOT* read when
|
/* Verify that bone controllers info is *NOT* read when
|
||||||
'Read bone controllers' is disabled. */
|
'Read bone controllers' is disabled. */
|
||||||
load_with_import_setting_bool(
|
load_with_import_setting_bool(
|
||||||
MDL_HL1_FILE_MAN,
|
MDL_HL1_FILE_MAN,
|
||||||
AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS,
|
AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS,
|
||||||
false, // Set config value to false.
|
false, // Set config value to false.
|
||||||
[&](const aiScene *scene) {
|
[&](const aiScene *scene) {
|
||||||
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BONE_CONTROLLERS));
|
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BONE_CONTROLLERS));
|
||||||
expect_global_info_eq(scene, 0, "NumBoneControllers");
|
expect_global_info_eq(scene, 0, "NumBoneControllers");
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Verify that attachments info is *NOT* read when
|
/* Verify that attachments info is *NOT* read when
|
||||||
'Read attachments' is disabled. */
|
'Read attachments' is disabled. */
|
||||||
load_with_import_setting_bool(
|
load_with_import_setting_bool(
|
||||||
MDL_HL1_FILE_MAN,
|
MDL_HL1_FILE_MAN,
|
||||||
AI_CONFIG_IMPORT_MDL_HL1_READ_ATTACHMENTS,
|
AI_CONFIG_IMPORT_MDL_HL1_READ_ATTACHMENTS,
|
||||||
false, // Set config value to false.
|
false, // Set config value to false.
|
||||||
[&](const aiScene *scene) {
|
[&](const aiScene *scene) {
|
||||||
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_ATTACHMENTS));
|
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_ATTACHMENTS));
|
||||||
expect_global_info_eq(scene, 0, "NumAttachments");
|
expect_global_info_eq(scene, 0, "NumAttachments");
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Verify that hitboxes info is *NOT* read when
|
/* Verify that hitboxes info is *NOT* read when
|
||||||
'Read hitboxes' is disabled. */
|
'Read hitboxes' is disabled. */
|
||||||
load_with_import_setting_bool(
|
load_with_import_setting_bool(
|
||||||
MDL_HL1_FILE_MAN,
|
MDL_HL1_FILE_MAN,
|
||||||
AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES,
|
AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES,
|
||||||
false, // Set config value to false.
|
false, // Set config value to false.
|
||||||
[&](const aiScene *scene) {
|
[&](const aiScene *scene) {
|
||||||
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_HITBOXES));
|
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_HITBOXES));
|
||||||
expect_global_info_eq(scene, 0, "NumHitboxes");
|
expect_global_info_eq(scene, 0, "NumHitboxes");
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Verify that misc global info is *NOT* read when
|
/* Verify that misc global info is *NOT* read when
|
||||||
'Read misc global info' is disabled. */
|
'Read misc global info' is disabled. */
|
||||||
load_with_import_setting_bool(
|
load_with_import_setting_bool(
|
||||||
MDL_HL1_FILE_MAN,
|
MDL_HL1_FILE_MAN,
|
||||||
AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO,
|
AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO,
|
||||||
false, // Set config value to false.
|
false, // Set config value to false.
|
||||||
[&](const aiScene *scene) {
|
[&](const aiScene *scene) {
|
||||||
aiNode *global_info = get_global_info(scene);
|
aiNode *global_info = get_global_info(scene);
|
||||||
EXPECT_NE(nullptr, global_info);
|
EXPECT_NE(nullptr, global_info);
|
||||||
aiVector3D temp;
|
aiVector3D temp;
|
||||||
EXPECT_FALSE(global_info->mMetaData->Get("EyePosition", temp));
|
EXPECT_FALSE(global_info->mMetaData->Get("EyePosition", temp));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void load_with_import_setting_bool(
|
void load_with_import_setting_bool(
|
||||||
const char *file_path,
|
const char *file_path,
|
||||||
const char *setting_key,
|
const char *setting_key,
|
||||||
bool setting_value,
|
bool setting_value,
|
||||||
std::function<void(const aiScene *)> &&func) {
|
std::function<void(const aiScene *)> &&func) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
importer.SetPropertyBool(setting_key, setting_value);
|
importer.SetPropertyBool(setting_key, setting_value);
|
||||||
const aiScene *scene = importer.ReadFile(file_path, aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(file_path, aiProcess_ValidateDataStructure);
|
||||||
|
@ -204,9 +200,9 @@ private:
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void expect_global_info_eq(
|
static void expect_global_info_eq(
|
||||||
const aiScene *scene,
|
const aiScene *scene,
|
||||||
T expected_value,
|
T expected_value,
|
||||||
const char *key_name) {
|
const char *key_name) {
|
||||||
aiNode *global_info = get_global_info(scene);
|
aiNode *global_info = get_global_info(scene);
|
||||||
EXPECT_NE(nullptr, global_info);
|
EXPECT_NE(nullptr, global_info);
|
||||||
T temp;
|
T temp;
|
||||||
|
@ -216,7 +212,7 @@ private:
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void expect_global_info_eq(const aiScene *scene,
|
static void expect_global_info_eq(const aiScene *scene,
|
||||||
std::initializer_list<std::pair<T, const char *>> p_kv) {
|
std::initializer_list<std::pair<T, const char *>> p_kv) {
|
||||||
aiNode *global_info = get_global_info(scene);
|
aiNode *global_info = get_global_info(scene);
|
||||||
EXPECT_NE(nullptr, global_info);
|
EXPECT_NE(nullptr, global_info);
|
||||||
for (auto it = p_kv.begin(); it != p_kv.end(); ++it) {
|
for (auto it = p_kv.begin(); it != p_kv.end(); ++it) {
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -45,13 +43,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @brief Half-Life 1 MDL loader materials tests.
|
* @brief Half-Life 1 MDL loader materials tests.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "MDL/HalfLife/HL1ImportDefinitions.h"
|
||||||
|
#include "MDLHL1TestFiles.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include "MDLHL1TestFiles.h"
|
|
||||||
#include "MDL/HalfLife/HL1ImportDefinitions.h"
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -45,13 +43,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @brief Half-Life 1 MDL loader nodes tests.
|
* @brief Half-Life 1 MDL loader nodes tests.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "MDL/HalfLife/HL1ImportDefinitions.h"
|
||||||
|
#include "MDLHL1TestFiles.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include "MDLHL1TestFiles.h"
|
|
||||||
#include "MDL/HalfLife/HL1ImportDefinitions.h"
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -117,7 +115,7 @@ public:
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_bodyparts.mdl", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_bodyparts.mdl", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
const std::vector<std::string> expected_bodyparts_names = {
|
const std::vector<std::string> expected_bodyparts_names = {
|
||||||
"Bodypart",
|
"Bodypart",
|
||||||
"Bodypart_1",
|
"Bodypart_1",
|
||||||
|
@ -196,16 +194,16 @@ public:
|
||||||
|
|
||||||
const std::vector<std::vector<std::string>> expected_bodypart_sub_models_names = {
|
const std::vector<std::vector<std::string>> expected_bodypart_sub_models_names = {
|
||||||
{
|
{
|
||||||
"triangle",
|
"triangle",
|
||||||
"triangle_0",
|
"triangle_0",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"triangle_1",
|
"triangle_1",
|
||||||
"triangle_2",
|
"triangle_2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"triangle2",
|
"triangle2",
|
||||||
"triangle2_0",
|
"triangle2_0",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,13 +38,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/Exporter.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,15 +39,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
TEST(utCOBImporter, importDwarfASCII) {
|
TEST(utCOBImporter, importDwarfASCII) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/dwarf_ascii.cob", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/dwarf_ascii.cob", aiProcess_ValidateDataStructure);
|
||||||
|
@ -58,14 +55,12 @@ TEST(utCOBImporter, importDwarfASCII) {
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utCOBImporter, importDwarf) {
|
TEST(utCOBImporter, importDwarf) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/dwarf.cob", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/dwarf.cob", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utCOBImporter, importMoleculeASCII) {
|
TEST(utCOBImporter, importMoleculeASCII) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule_ascii.cob", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule_ascii.cob", aiProcess_ValidateDataStructure);
|
||||||
|
@ -74,35 +69,30 @@ TEST(utCOBImporter, importMoleculeASCII) {
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utCOBImporter, importMolecule) {
|
TEST(utCOBImporter, importMolecule) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule.cob", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule.cob", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utCOBImporter, importSpider43ASCII) {
|
TEST(utCOBImporter, importSpider43ASCII) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_4_3_ascii.cob", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_4_3_ascii.cob", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utCOBImporter, importSpider43) {
|
TEST(utCOBImporter, importSpider43) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_4_3.cob", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_4_3.cob", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utCOBImporter, importSpider66ASCII) {
|
TEST(utCOBImporter, importSpider66ASCII) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_6_6_ascii.cob", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_6_6_ascii.cob", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utCOBImporter, importSpider66) {
|
TEST(utCOBImporter, importSpider66) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_6_6.cob", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_6_6.cob", aiProcess_ValidateDataStructure);
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -50,7 +48,7 @@ using namespace Assimp;
|
||||||
class TestProgressHandler : public ProgressHandler {
|
class TestProgressHandler : public ProgressHandler {
|
||||||
public:
|
public:
|
||||||
TestProgressHandler() :
|
TestProgressHandler() :
|
||||||
ProgressHandler(),
|
ProgressHandler(),
|
||||||
mPercentage(0.f) {
|
mPercentage(0.f) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -47,39 +45,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD2Importer, importFaerie) {
|
TEST(utMD2Importer, importFaerie) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD2/faerie.md2", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD2/faerie.md2", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD2Importer, importSydney) {
|
TEST(utMD2Importer, importSydney) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD2/sydney.md2", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD2/sydney.md2", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD2Importer, importDolphin) {
|
TEST(utMD2Importer, importDolphin) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/dolphin.md2", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/dolphin.md2", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD2Importer, importFlag) {
|
TEST(utMD2Importer, importFlag) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/flag.md2", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/flag.md2", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD2Importer, importHorse) {
|
TEST(utMD2Importer, importHorse) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/horse.md2", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/horse.md2", aiProcess_ValidateDataStructure);
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -47,25 +45,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD3Importer, importWatercan) {
|
TEST(utMD3Importer, importWatercan) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan.md3", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan.md3", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD3Importer, importWatercan_dmg) {
|
TEST(utMD3Importer, importWatercan_dmg) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan_dmg.md3", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan_dmg.md3", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD3Importer, importEuropean_fnt_v2) {
|
TEST(utMD3Importer, importEuropean_fnt_v2) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/q3root/models/mapobjects/kt_kubalwagon/european_fnt_v2.md3", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/q3root/models/mapobjects/kt_kubalwagon/european_fnt_v2.md3", aiProcess_ValidateDataStructure);
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -47,32 +45,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD5Importer, importEmpty) {
|
TEST(utMD5Importer, importEmpty) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD5/invalid/empty.md5mesh", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD5/invalid/empty.md5mesh", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD5Importer, importSimpleCube) {
|
TEST(utMD5Importer, importSimpleCube) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD5/SimpleCube.md5mesh", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD5/SimpleCube.md5mesh", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD5Importer, importBoarMan) {
|
TEST(utMD5Importer, importBoarMan) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD5/BoarMan.md5mesh", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD5/BoarMan.md5mesh", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utMD5Importer, importBob) {
|
TEST(utMD5Importer, importBob) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD5/Bob.md5mesh", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD5/Bob.md5mesh", aiProcess_ValidateDataStructure);
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -65,7 +63,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void importerTest_HL1(Assimp::Importer* const importer) {
|
void importerTest_HL1(Assimp::Importer *const importer) {
|
||||||
const aiScene *scene = importer->ReadFile(MDL_HL1_FILE_MAN, 0);
|
const aiScene *scene = importer->ReadFile(MDL_HL1_FILE_MAN, 0);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,10 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include <assimp/Importer.hpp>
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,13 +39,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include <assimp/scene.h>
|
#include "SceneDiffer.h"
|
||||||
#include <assimp/Importer.hpp>
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/Exporter.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
class utOFFImportExport : public AbstractImportExportBase {
|
class utOFFImportExport : public AbstractImportExportBase {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,12 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -59,6 +57,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(utOgreImportExport, importerTest ) {
|
TEST_F(utOgreImportExport, importerTest) {
|
||||||
EXPECT_TRUE(importerTest());
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,12 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,62 +40,53 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
TEST(utXGLImporter, importBCN_Epileptic) {
|
TEST(utXGLImporter, importBCN_Epileptic) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/BCN_Epileptic.zgl", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/BCN_Epileptic.zgl", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXGLImporter, importCubesWithAlpha) {
|
TEST(utXGLImporter, importCubesWithAlpha) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/cubes_with_alpha.zgl", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/cubes_with_alpha.zgl", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXGLImporter, importSample_official) {
|
TEST(utXGLImporter, importSample_official) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXGLImporter, importSample_official_asxml) {
|
TEST(utXGLImporter, importSample_official_asxml) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official_asxml.xml", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official_asxml.xml", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXGLImporter, importSphereWithMatGloss) {
|
TEST(utXGLImporter, importSphereWithMatGloss) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sphere_with_mat_gloss_10pc.zgl", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sphere_with_mat_gloss_10pc.zgl", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXGLImporter, importSpiderASCII) {
|
TEST(utXGLImporter, importSpiderASCII) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Spider_ascii.zgl", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Spider_ascii.zgl", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXGLImporter, importWuson) {
|
TEST(utXGLImporter, importWuson) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Wuson.zgl", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Wuson.zgl", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXGLImporter, importWusonDXF) {
|
TEST(utXGLImporter, importWusonDXF) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/wuson_dxf.zgl", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/wuson_dxf.zgl", aiProcess_ValidateDataStructure);
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "../../include/assimp/DefaultLogger.hpp"
|
#include "../../include/assimp/DefaultLogger.hpp"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#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_STDOUT | aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE);
|
aiDefaultLogStream_STDOUT | 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();
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,20 +39,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class ut3DSImportExport : public AbstractImportExportBase {
|
class ut3DSImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
bool importerTest() override {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3DS/fels.3ds", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/fels.3ds", aiProcess_ValidateDataStructure);
|
||||||
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
#else
|
#else
|
||||||
|
@ -63,14 +61,13 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( ut3DSImportExport, import3DSFromFileTest ) {
|
TEST_F(ut3DSImportExport, import3DSFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( ut3DSImportExport, import3DSformatdetection) {
|
TEST_F(ut3DSImportExport, import3DSformatdetection) {
|
||||||
::Assimp::Importer importer;
|
::Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/testFormatDetection", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/testFormatDetection", aiProcess_ValidateDataStructure);
|
||||||
|
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -52,17 +52,15 @@ class utAMFImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/AMF/test1.amf", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test1.amf", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utAMFImportExport, importAMFFromFileTest ) {
|
TEST_F(utAMFImportExport, importAMFFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_F(utAMFImportExport, importAMFWithMatFromFileTest) {
|
TEST_F(utAMFImportExport, importAMFWithMatFromFileTest) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test_with_mat.amf", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test_with_mat.amf", aiProcess_ValidateDataStructure);
|
||||||
|
|
|
@ -39,28 +39,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class utASEImportExport : public AbstractImportExportBase {
|
class utASEImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
bool importerTest() override {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen.ASE", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen.ASE", aiProcess_ValidateDataStructure);
|
||||||
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
#else
|
#else
|
||||||
return nullptr == scene;
|
return nullptr == scene;
|
||||||
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER
|
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utASEImportExport, importACFromFileTest ) {
|
TEST_F(utASEImportExport, importACFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,18 +38,17 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "TestModelFactory.h"
|
#include "TestModelFactory.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
#include "PostProcessing/ArmaturePopulate.h"
|
#include "PostProcessing/ArmaturePopulate.h"
|
||||||
|
|
||||||
|
@ -62,18 +59,18 @@ class utArmaturePopulate : public ::testing::Test {
|
||||||
// empty
|
// empty
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utArmaturePopulate, importCheckForArmatureTest) {
|
TEST_F(utArmaturePopulate, importCheckForArmatureTest) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
unsigned int mask = aiProcess_PopulateArmatureData | aiProcess_ValidateDataStructure;
|
unsigned int mask = aiProcess_PopulateArmatureData | aiProcess_ValidateDataStructure;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/huesitos.fbx", mask);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/huesitos.fbx", mask);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1u);
|
EXPECT_EQ(scene->mNumMeshes, 1u);
|
||||||
aiMesh* mesh = scene->mMeshes[0];
|
aiMesh *mesh = scene->mMeshes[0];
|
||||||
EXPECT_EQ(mesh->mNumFaces, 68u);
|
EXPECT_EQ(mesh->mNumFaces, 68u);
|
||||||
EXPECT_EQ(mesh->mNumVertices, 256u);
|
EXPECT_EQ(mesh->mNumVertices, 256u);
|
||||||
EXPECT_GT(mesh->mNumBones, 0u);
|
EXPECT_GT(mesh->mNumBones, 0u);
|
||||||
|
|
||||||
aiBone* exampleBone = mesh->mBones[0];
|
aiBone *exampleBone = mesh->mBones[0];
|
||||||
EXPECT_NE(exampleBone, nullptr);
|
EXPECT_NE(exampleBone, nullptr);
|
||||||
EXPECT_NE(exampleBone->mArmature, nullptr);
|
EXPECT_NE(exampleBone->mArmature, nullptr);
|
||||||
EXPECT_NE(exampleBone->mNode, nullptr);
|
EXPECT_NE(exampleBone->mNode, nullptr);
|
||||||
|
|
|
@ -39,12 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -52,11 +52,11 @@ class utB3DImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/B3D/WusonBlitz.b3d", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/B3D/WusonBlitz.b3d", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utB3DImportExport, importACFromFileTest ) {
|
TEST_F(utB3DImportExport, importACFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,23 +38,23 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class utBVHImportExport : public AbstractImportExportBase {
|
class utBVHImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
bool importerTest() override {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/BVH/01_01.bvh", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BVH/01_01.bvh", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utBVHImportExport, importBlenFromFileTest ) {
|
TEST_F(utBVHImportExport, importBlenFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -43,37 +41,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/cexport.h>
|
#include <assimp/cexport.h>
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
class BlendImportAreaLight : public ::testing::Test {
|
class BlendImportAreaLight : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
void SetUp() override {
|
||||||
virtual void SetUp()
|
|
||||||
{
|
|
||||||
im = new Assimp::Importer();
|
im = new Assimp::Importer();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown()
|
void TearDown() override {
|
||||||
{
|
|
||||||
delete im;
|
delete im;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Assimp::Importer *im;
|
||||||
Assimp::Importer* im;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(BlendImportAreaLight, testImportLight)
|
TEST_F(BlendImportAreaLight, testImportLight) {
|
||||||
{
|
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/AreaLight_269.blend", aiProcess_ValidateDataStructure);
|
||||||
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/AreaLight_269.blend", aiProcess_ValidateDataStructure);
|
ASSERT_TRUE(pTest != nullptr);
|
||||||
ASSERT_TRUE(pTest != NULL);
|
|
||||||
ASSERT_TRUE(pTest->HasLights());
|
ASSERT_TRUE(pTest->HasLights());
|
||||||
|
|
||||||
std::vector< std::pair<std::string, size_t> > lightNames;
|
std::vector<std::pair<std::string, size_t>> lightNames;
|
||||||
|
|
||||||
for (size_t i = 0; i < pTest->mNumLights; i++) {
|
for (size_t i = 0; i < pTest->mNumLights; i++) {
|
||||||
lightNames.push_back(std::make_pair(pTest->mLights[i]->mName.C_Str(), i));
|
lightNames.push_back(std::make_pair(pTest->mLights[i]->mName.C_Str(), i));
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -43,32 +41,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/cexport.h>
|
#include <assimp/cexport.h>
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
class BlendImportMaterials : public ::testing::Test {
|
class BlendImportMaterials : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
void SetUp() override {
|
||||||
virtual void SetUp()
|
|
||||||
{
|
|
||||||
im = new Assimp::Importer();
|
im = new Assimp::Importer();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown()
|
void TearDown() override {
|
||||||
{
|
|
||||||
delete im;
|
delete im;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Assimp::Importer *im;
|
||||||
Assimp::Importer* im;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(BlendImportMaterials, testImportMaterial)
|
TEST_F(BlendImportMaterials, testImportMaterial) {
|
||||||
{
|
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderMaterial_269.blend", aiProcess_ValidateDataStructure);
|
||||||
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderMaterial_269.blend", aiProcess_ValidateDataStructure);
|
|
||||||
ASSERT_TRUE(pTest != NULL);
|
ASSERT_TRUE(pTest != NULL);
|
||||||
ASSERT_TRUE(pTest->HasMaterials());
|
ASSERT_TRUE(pTest->HasMaterials());
|
||||||
|
|
||||||
|
@ -76,15 +69,15 @@ TEST_F(BlendImportMaterials, testImportMaterial)
|
||||||
|
|
||||||
auto alpha = pTest->mMaterials[0];
|
auto alpha = pTest->mMaterials[0];
|
||||||
|
|
||||||
#define ASSERT_PROPERTY_EQ(expected, key, var) \
|
#define ASSERT_PROPERTY_EQ(expected, key, var) \
|
||||||
auto var = expected; \
|
auto var = expected; \
|
||||||
ASSERT_EQ(aiReturn_SUCCESS, alpha->Get("$mat.blend." key, 0, 0, var)); \
|
ASSERT_EQ(aiReturn_SUCCESS, alpha->Get("$mat.blend." key, 0, 0, var)); \
|
||||||
ASSERT_EQ(expected, var);
|
ASSERT_EQ(expected, var);
|
||||||
|
|
||||||
#define ASSERT_PROPERTY_FLOAT_EQ(expected, key, var) \
|
#define ASSERT_PROPERTY_FLOAT_EQ(expected, key, var) \
|
||||||
auto var = expected; \
|
auto var = expected; \
|
||||||
ASSERT_EQ(aiReturn_SUCCESS, alpha->Get("$mat.blend." key, 0, 0, var)); \
|
ASSERT_EQ(aiReturn_SUCCESS, alpha->Get("$mat.blend." key, 0, 0, var)); \
|
||||||
ASSERT_FLOAT_EQ(expected, var);
|
ASSERT_FLOAT_EQ(expected, var);
|
||||||
|
|
||||||
ASSERT_PROPERTY_EQ(aiColor3D(0.1f, 0.2f, 0.3f), "diffuse.color", diffuseColor);
|
ASSERT_PROPERTY_EQ(aiColor3D(0.1f, 0.2f, 0.3f), "diffuse.color", diffuseColor);
|
||||||
ASSERT_PROPERTY_EQ(0.4f, "diffuse.intensity", diffuseIntensity);
|
ASSERT_PROPERTY_EQ(0.4f, "diffuse.intensity", diffuseIntensity);
|
||||||
|
@ -126,9 +119,8 @@ TEST_F(BlendImportMaterials, testImportMaterial)
|
||||||
ASSERT_PROPERTY_FLOAT_EQ(0.87f, "mirror.glossAnisotropic", mirrorGlossAnisotropic);
|
ASSERT_PROPERTY_FLOAT_EQ(0.87f, "mirror.glossAnisotropic", mirrorGlossAnisotropic);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlendImportMaterials, testImportMaterialwith2texturesAnd2TexCoordMappings)
|
TEST_F(BlendImportMaterials, testImportMaterialwith2texturesAnd2TexCoordMappings) {
|
||||||
{
|
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/plane_2_textures_2_texcoords_279.blend", aiProcess_ValidateDataStructure);
|
||||||
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/plane_2_textures_2_texcoords_279.blend", aiProcess_ValidateDataStructure);
|
|
||||||
ASSERT_TRUE(pTest != NULL);
|
ASSERT_TRUE(pTest != NULL);
|
||||||
|
|
||||||
// material has 2 diffuse textures
|
// material has 2 diffuse textures
|
||||||
|
|
|
@ -40,11 +40,11 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -52,182 +52,160 @@ class utBlenderImporterExporter : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/BLEND/box.blend", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/box.blend", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utBlenderImporterExporter, importBlenFromFileTest ) {
|
TEST_F(utBlenderImporterExporter, importBlenFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, import4cubes) {
|
||||||
TEST( utBlenderImporter, import4cubes ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/4Cubes4Mats_248.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/4Cubes4Mats_248.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, import269_regress1) {
|
||||||
TEST( utBlenderImporter, import269_regress1 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/blender_269_regress1.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/blender_269_regress1.blend", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importBlenderDefault248) {
|
||||||
TEST( utBlenderImporter, importBlenderDefault248 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_248.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_248.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importBlenderDefault250) {
|
||||||
TEST( utBlenderImporter, importBlenderDefault250 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importBlenderDefault250Compressed) {
|
||||||
TEST( utBlenderImporter, importBlenderDefault250Compressed ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250_Compressed.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250_Compressed.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importBlenderDefault262) {
|
||||||
TEST( utBlenderImporter, importBlenderDefault262 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_262.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_262.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importBlenderDefault269) {
|
||||||
TEST( utBlenderImporter, importBlenderDefault269 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_269.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_269.blend", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importBlenderDefault271) {
|
||||||
TEST( utBlenderImporter, importBlenderDefault271 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_271.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_271.blend", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importCubeHierarchy_248) {
|
||||||
TEST( utBlenderImporter, importCubeHierarchy_248 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/CubeHierarchy_248.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/CubeHierarchy_248.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importHuman) {
|
||||||
TEST( utBlenderImporter, importHuman ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/HUMAN.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/HUMAN.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importMirroredCube_252) {
|
||||||
TEST( utBlenderImporter, importMirroredCube_252 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/MirroredCube_252.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/MirroredCube_252.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importNoisyTexturedCube_VoronoiGlob_248) {
|
||||||
TEST( utBlenderImporter, importNoisyTexturedCube_VoronoiGlob_248 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/NoisyTexturedCube_VoronoiGlob_248.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/NoisyTexturedCube_VoronoiGlob_248.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importSmoothVsSolidCube_248) {
|
||||||
TEST( utBlenderImporter, importSmoothVsSolidCube_248 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SmoothVsSolidCube_248.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SmoothVsSolidCube_248.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importSuzanne_248) {
|
||||||
TEST( utBlenderImporter, importSuzanne_248 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/Suzanne_248.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/Suzanne_248.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importSuzanneSubdiv_252) {
|
||||||
TEST( utBlenderImporter, importSuzanneSubdiv_252 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SuzanneSubdiv_252.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SuzanneSubdiv_252.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importTexturedCube_ImageGlob_248) {
|
||||||
TEST( utBlenderImporter, importTexturedCube_ImageGlob_248 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedCube_ImageGlob_248.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedCube_ImageGlob_248.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importTexturedPlane_ImageUv_248) {
|
||||||
TEST( utBlenderImporter, importTexturedPlane_ImageUv_248 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUv_248.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUv_248.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importTexturedPlane_ImageUvPacked_248) {
|
||||||
TEST( utBlenderImporter, importTexturedPlane_ImageUvPacked_248 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUvPacked_248.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUvPacked_248.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importTorusLightsCams_250_compressed) {
|
||||||
TEST( utBlenderImporter, importTorusLightsCams_250_compressed ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TorusLightsCams_250_compressed.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TorusLightsCams_250_compressed.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, import_yxa_1) {
|
||||||
TEST( utBlenderImporter, import_yxa_1 ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/yxa_1.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/yxa_1.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importBob) {
|
||||||
TEST( utBlenderImporter, importBob ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/Bob.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/Bob.blend", aiProcess_ValidateDataStructure);
|
||||||
// FIXME: this is probably not right, loading this should succeed
|
// FIXME: this is probably not right, loading this should succeed
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utBlenderImporter, importFleurOptonl) {
|
||||||
TEST( utBlenderImporter, importFleurOptonl ) {
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/fleurOptonl.blend", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/fleurOptonl.blend", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
|
|
|
@ -40,8 +40,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "Blender/BlenderIntermediate.h"
|
#include "Blender/BlenderIntermediate.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/camera.h>
|
#include <assimp/camera.h>
|
||||||
#include <assimp/light.h>
|
#include <assimp/light.h>
|
||||||
#include <assimp/mesh.h>
|
#include <assimp/mesh.h>
|
||||||
|
@ -61,25 +61,20 @@ class BlenderIntermediateTest : public ::testing::Test {
|
||||||
// A comparator in C++ is used for ordering and must implement strict weak ordering,
|
// A comparator in C++ is used for ordering and must implement strict weak ordering,
|
||||||
// which means it must return false for equal values.
|
// which means it must return false for equal values.
|
||||||
// The C++ standard defines and expects this behavior: true if lhs < rhs, false otherwise.
|
// The C++ standard defines and expects this behavior: true if lhs < rhs, false otherwise.
|
||||||
TEST_F( BlenderIntermediateTest,ConversionData_ObjectCompareTest ) {
|
TEST_F(BlenderIntermediateTest, ConversionData_ObjectCompareTest) {
|
||||||
Object obj1, obj2;
|
Object obj1, obj2;
|
||||||
strncpy( obj1.id.name, NAME_1, sizeof(NAME_1) );
|
strncpy(obj1.id.name, NAME_1, sizeof(NAME_1));
|
||||||
strncpy( obj2.id.name, NAME_2, sizeof(NAME_2) );
|
strncpy(obj2.id.name, NAME_2, sizeof(NAME_2));
|
||||||
|
|
||||||
Blender::ObjectCompare cmp_true_because_first_is_smaller_than_second;
|
Blender::ObjectCompare cmp_true_because_first_is_smaller_than_second;
|
||||||
bool res( cmp_true_because_first_is_smaller_than_second( &obj1, &obj2 ) );
|
bool res(cmp_true_because_first_is_smaller_than_second(&obj1, &obj2));
|
||||||
EXPECT_TRUE( res );
|
EXPECT_TRUE(res);
|
||||||
|
|
||||||
Blender::ObjectCompare cmp_false_because_equal;
|
Blender::ObjectCompare cmp_false_because_equal;
|
||||||
res = cmp_false_because_equal( &obj1, &obj1 );
|
res = cmp_false_because_equal(&obj1, &obj1);
|
||||||
EXPECT_FALSE( res );
|
EXPECT_FALSE(res);
|
||||||
|
|
||||||
Blender::ObjectCompare cmp_false_because_first_is_greater_than_second;
|
Blender::ObjectCompare cmp_false_because_first_is_greater_than_second;
|
||||||
res = cmp_false_because_first_is_greater_than_second( &obj2, &obj1 );
|
res = cmp_false_because_first_is_greater_than_second(&obj2, &obj1);
|
||||||
EXPECT_FALSE( res );
|
EXPECT_FALSE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,31 +40,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/cexport.h>
|
#include <assimp/cexport.h>
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace ::Assimp;
|
using namespace ::Assimp;
|
||||||
|
|
||||||
class BlenderWorkTest : public ::testing::Test {
|
class BlenderWorkTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp()
|
virtual void SetUp() {
|
||||||
{
|
|
||||||
im = new Assimp::Importer();
|
im = new Assimp::Importer();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown()
|
virtual void TearDown() {
|
||||||
{
|
|
||||||
delete im;
|
delete im;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Assimp::Importer *im;
|
||||||
Assimp::Importer* im;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(BlenderWorkTest,work_279) {
|
TEST_F(BlenderWorkTest, work_279) {
|
||||||
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/test_279.blend", aiProcess_ValidateDataStructure);
|
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/test_279.blend", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_TRUE(pTest != NULL);
|
ASSERT_TRUE(pTest != NULL);
|
||||||
|
|
||||||
// material has 2 diffuse textures
|
// material has 2 diffuse textures
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,11 +38,11 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -52,11 +50,11 @@ class utCSMImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/CSM/ThomasFechten.csm", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/CSM/ThomasFechten.csm", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utCSMImportExport, importBlenFromFileTest ) {
|
TEST_F(utCSMImportExport, importBlenFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -43,19 +41,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/cexport.h>
|
#include <assimp/cexport.h>
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
class ColladaExportCamera : public ::testing::Test {
|
class ColladaExportCamera : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
void SetUp() override{
|
void SetUp() override {
|
||||||
ex = new Assimp::Exporter();
|
ex = new Assimp::Exporter();
|
||||||
im = new Assimp::Importer();
|
im = new Assimp::Importer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
|
@ -66,53 +63,52 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Assimp::Exporter* ex;
|
Assimp::Exporter *ex;
|
||||||
Assimp::Importer* im;
|
Assimp::Importer *im;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(ColladaExportCamera, testExportCamera) {
|
TEST_F(ColladaExportCamera, testExportCamera) {
|
||||||
const char* file = "cameraExp.dae";
|
const char *file = "cameraExp.dae";
|
||||||
|
|
||||||
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure);
|
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE( nullptr, pTest );
|
ASSERT_NE(nullptr, pTest);
|
||||||
ASSERT_TRUE(pTest->HasCameras());
|
ASSERT_TRUE(pTest->HasCameras());
|
||||||
|
|
||||||
|
EXPECT_EQ(AI_SUCCESS, ex->Export(pTest, "collada", file));
|
||||||
EXPECT_EQ( AI_SUCCESS, ex->Export(pTest,"collada",file));
|
const unsigned int origNumCams(pTest->mNumCameras);
|
||||||
const unsigned int origNumCams( pTest->mNumCameras );
|
std::unique_ptr<float[]> origFOV(new float[origNumCams]);
|
||||||
std::unique_ptr<float[]> origFOV( new float[ origNumCams ] );
|
std::unique_ptr<float[]> orifClipPlaneNear(new float[origNumCams]);
|
||||||
std::unique_ptr<float[]> orifClipPlaneNear( new float[ origNumCams ] );
|
std::unique_ptr<float[]> orifClipPlaneFar(new float[origNumCams]);
|
||||||
std::unique_ptr<float[]> orifClipPlaneFar( new float[ origNumCams ] );
|
std::unique_ptr<aiString[]> names(new aiString[origNumCams]);
|
||||||
std::unique_ptr<aiString[]> names( new aiString[ origNumCams ] );
|
std::unique_ptr<aiVector3D[]> pos(new aiVector3D[origNumCams]);
|
||||||
std::unique_ptr<aiVector3D[]> pos( new aiVector3D[ origNumCams ] );
|
|
||||||
for (size_t i = 0; i < origNumCams; i++) {
|
for (size_t i = 0; i < origNumCams; i++) {
|
||||||
const aiCamera *orig = pTest->mCameras[ i ];
|
const aiCamera *orig = pTest->mCameras[i];
|
||||||
ASSERT_NE(nullptr, orig );
|
ASSERT_NE(nullptr, orig);
|
||||||
|
|
||||||
origFOV[ i ] = orig->mHorizontalFOV;
|
origFOV[i] = orig->mHorizontalFOV;
|
||||||
orifClipPlaneNear[ i ] = orig->mClipPlaneNear;
|
orifClipPlaneNear[i] = orig->mClipPlaneNear;
|
||||||
orifClipPlaneFar[ i ] = orig->mClipPlaneFar;
|
orifClipPlaneFar[i] = orig->mClipPlaneFar;
|
||||||
names[ i ] = orig->mName;
|
names[i] = orig->mName;
|
||||||
pos[ i ] = orig->mPosition;
|
pos[i] = orig->mPosition;
|
||||||
}
|
}
|
||||||
const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
|
const aiScene *imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
|
||||||
|
|
||||||
ASSERT_NE(nullptr, imported );
|
ASSERT_NE(nullptr, imported);
|
||||||
|
|
||||||
EXPECT_TRUE( imported->HasCameras() );
|
EXPECT_TRUE(imported->HasCameras());
|
||||||
EXPECT_EQ( origNumCams, imported->mNumCameras );
|
EXPECT_EQ(origNumCams, imported->mNumCameras);
|
||||||
|
|
||||||
for(size_t i=0; i< imported->mNumCameras;i++){
|
for (size_t i = 0; i < imported->mNumCameras; i++) {
|
||||||
const aiCamera *read = imported->mCameras[ i ];
|
const aiCamera *read = imported->mCameras[i];
|
||||||
|
|
||||||
EXPECT_TRUE( names[ i ] == read->mName );
|
EXPECT_TRUE(names[i] == read->mName);
|
||||||
EXPECT_NEAR( origFOV[ i ],read->mHorizontalFOV, 0.0001f );
|
EXPECT_NEAR(origFOV[i], read->mHorizontalFOV, 0.0001f);
|
||||||
EXPECT_FLOAT_EQ( orifClipPlaneNear[ i ], read->mClipPlaneNear);
|
EXPECT_FLOAT_EQ(orifClipPlaneNear[i], read->mClipPlaneNear);
|
||||||
EXPECT_FLOAT_EQ( orifClipPlaneFar[ i ], read->mClipPlaneFar);
|
EXPECT_FLOAT_EQ(orifClipPlaneFar[i], read->mClipPlaneFar);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ( pos[ i ].x,read->mPosition.x);
|
EXPECT_FLOAT_EQ(pos[i].x, read->mPosition.x);
|
||||||
EXPECT_FLOAT_EQ( pos[ i ].y,read->mPosition.y);
|
EXPECT_FLOAT_EQ(pos[i].y, read->mPosition.y);
|
||||||
EXPECT_FLOAT_EQ( pos[ i ].z,read->mPosition.z);
|
EXPECT_FLOAT_EQ(pos[i].z, read->mPosition.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -44,69 +42,66 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <assimp/cexport.h>
|
#include <assimp/cexport.h>
|
||||||
#include <assimp/commonMetaData.h>
|
#include <assimp/commonMetaData.h>
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
class ColladaExportLight : public ::testing::Test {
|
class ColladaExportLight : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp()
|
void SetUp() override {
|
||||||
{
|
|
||||||
ex = new Assimp::Exporter();
|
ex = new Assimp::Exporter();
|
||||||
im = new Assimp::Importer();
|
im = new Assimp::Importer();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown()
|
void TearDown() override {
|
||||||
{
|
|
||||||
delete ex;
|
delete ex;
|
||||||
delete im;
|
delete im;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Assimp::Exporter* ex;
|
Assimp::Exporter *ex;
|
||||||
Assimp::Importer* im;
|
Assimp::Importer *im;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ColladaExportLight, testExportLight)
|
TEST_F(ColladaExportLight, testExportLight) {
|
||||||
{
|
const char *file = "lightsExp.dae";
|
||||||
const char* file = "lightsExp.dae";
|
|
||||||
|
|
||||||
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/lights.dae", aiProcess_ValidateDataStructure);
|
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/lights.dae", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(pTest, nullptr);
|
ASSERT_NE(pTest, nullptr);
|
||||||
ASSERT_TRUE(pTest->HasLights());
|
ASSERT_TRUE(pTest->HasLights());
|
||||||
|
|
||||||
const unsigned int origNumLights( pTest->mNumLights );
|
const unsigned int origNumLights(pTest->mNumLights);
|
||||||
std::unique_ptr<aiLight[]> origLights( new aiLight[ origNumLights ] );
|
std::unique_ptr<aiLight[]> origLights(new aiLight[origNumLights]);
|
||||||
std::vector<std::string> origNames;
|
std::vector<std::string> origNames;
|
||||||
for (size_t i = 0; i < origNumLights; i++) {
|
for (size_t i = 0; i < origNumLights; i++) {
|
||||||
origNames.push_back( pTest->mLights[ i ]->mName.C_Str() );
|
origNames.push_back(pTest->mLights[i]->mName.C_Str());
|
||||||
origLights[ i ] = *(pTest->mLights[ i ]);
|
origLights[i] = *(pTest->mLights[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Common metadata
|
// Common metadata
|
||||||
// Confirm was loaded by the Collada importer
|
// Confirm was loaded by the Collada importer
|
||||||
aiString origImporter;
|
aiString origImporter;
|
||||||
EXPECT_TRUE(pTest->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, origImporter)) << "No importer format metadata";
|
EXPECT_TRUE(pTest->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, origImporter)) << "No importer format metadata";
|
||||||
EXPECT_STREQ("Collada Importer", origImporter.C_Str());
|
EXPECT_STREQ("Collada Importer", origImporter.C_Str());
|
||||||
|
|
||||||
aiString origGenerator;
|
aiString origGenerator;
|
||||||
EXPECT_TRUE(pTest->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, origGenerator)) << "No generator metadata";
|
EXPECT_TRUE(pTest->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, origGenerator)) << "No generator metadata";
|
||||||
EXPECT_EQ(strncmp(origGenerator.C_Str(), "Blender", 7), 0) << "AI_METADATA_SOURCE_GENERATOR was: " << origGenerator.C_Str();
|
EXPECT_EQ(strncmp(origGenerator.C_Str(), "Blender", 7), 0) << "AI_METADATA_SOURCE_GENERATOR was: " << origGenerator.C_Str();
|
||||||
|
|
||||||
aiString origCopyright;
|
aiString origCopyright;
|
||||||
EXPECT_TRUE(pTest->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, origCopyright)) << "No copyright metadata";
|
EXPECT_TRUE(pTest->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, origCopyright)) << "No copyright metadata";
|
||||||
EXPECT_STREQ("BSD", origCopyright.C_Str());
|
EXPECT_STREQ("BSD", origCopyright.C_Str());
|
||||||
|
|
||||||
aiString origCreated;
|
aiString origCreated;
|
||||||
EXPECT_TRUE(pTest->mMetaData->Get("Created", origCreated)) << "No created metadata";
|
EXPECT_TRUE(pTest->mMetaData->Get("Created", origCreated)) << "No created metadata";
|
||||||
EXPECT_STREQ("2015-05-17T21:55:44", origCreated.C_Str());
|
EXPECT_STREQ("2015-05-17T21:55:44", origCreated.C_Str());
|
||||||
|
|
||||||
aiString origModified;
|
aiString origModified;
|
||||||
EXPECT_TRUE(pTest->mMetaData->Get("Modified", origModified)) << "No modified metadata";
|
EXPECT_TRUE(pTest->mMetaData->Get("Modified", origModified)) << "No modified metadata";
|
||||||
EXPECT_STREQ("2015-05-17T21:55:44", origModified.C_Str());
|
EXPECT_STREQ("2015-05-17T21:55:44", origModified.C_Str());
|
||||||
|
|
||||||
EXPECT_EQ(AI_SUCCESS, ex->Export(pTest, "collada", file));
|
EXPECT_EQ(AI_SUCCESS, ex->Export(pTest, "collada", file));
|
||||||
|
@ -114,7 +109,7 @@ TEST_F(ColladaExportLight, testExportLight)
|
||||||
// Drop the pointer as about to become invalid
|
// Drop the pointer as about to become invalid
|
||||||
pTest = nullptr;
|
pTest = nullptr;
|
||||||
|
|
||||||
const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
|
const aiScene *imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
|
||||||
|
|
||||||
ASSERT_TRUE(imported != NULL);
|
ASSERT_TRUE(imported != NULL);
|
||||||
|
|
||||||
|
@ -124,48 +119,48 @@ TEST_F(ColladaExportLight, testExportLight)
|
||||||
EXPECT_STREQ(origImporter.C_Str(), readImporter.C_Str()) << "Assimp Importer Format changed";
|
EXPECT_STREQ(origImporter.C_Str(), readImporter.C_Str()) << "Assimp Importer Format changed";
|
||||||
|
|
||||||
aiString readGenerator;
|
aiString readGenerator;
|
||||||
EXPECT_TRUE(imported->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, readGenerator)) << "No generator metadata";
|
EXPECT_TRUE(imported->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, readGenerator)) << "No generator metadata";
|
||||||
EXPECT_STREQ(origGenerator.C_Str(), readGenerator.C_Str()) << "Generator changed";
|
EXPECT_STREQ(origGenerator.C_Str(), readGenerator.C_Str()) << "Generator changed";
|
||||||
|
|
||||||
aiString readCopyright;
|
aiString readCopyright;
|
||||||
EXPECT_TRUE(imported->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, readCopyright)) << "No copyright metadata";
|
EXPECT_TRUE(imported->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, readCopyright)) << "No copyright metadata";
|
||||||
EXPECT_STREQ(origCopyright.C_Str(), readCopyright.C_Str()) << "Copyright changed";
|
EXPECT_STREQ(origCopyright.C_Str(), readCopyright.C_Str()) << "Copyright changed";
|
||||||
|
|
||||||
aiString readCreated;
|
aiString readCreated;
|
||||||
EXPECT_TRUE(imported->mMetaData->Get("Created", readCreated)) << "No created metadata";
|
EXPECT_TRUE(imported->mMetaData->Get("Created", readCreated)) << "No created metadata";
|
||||||
EXPECT_STREQ(origCreated.C_Str(), readCreated.C_Str()) << "Created date changed";
|
EXPECT_STREQ(origCreated.C_Str(), readCreated.C_Str()) << "Created date changed";
|
||||||
|
|
||||||
aiString readModified;
|
aiString readModified;
|
||||||
EXPECT_TRUE(imported->mMetaData->Get("Modified", readModified)) << "No modified metadata";
|
EXPECT_TRUE(imported->mMetaData->Get("Modified", readModified)) << "No modified metadata";
|
||||||
EXPECT_STRNE(origModified.C_Str(), readModified.C_Str()) << "Modified date did not change";
|
EXPECT_STRNE(origModified.C_Str(), readModified.C_Str()) << "Modified date did not change";
|
||||||
EXPECT_GT(readModified.length, ai_uint32(18)) << "Modified date too short";
|
EXPECT_GT(readModified.length, ai_uint32(18)) << "Modified date too short";
|
||||||
|
|
||||||
// Lights
|
// Lights
|
||||||
EXPECT_TRUE(imported->HasLights());
|
EXPECT_TRUE(imported->HasLights());
|
||||||
EXPECT_EQ(origNumLights, imported->mNumLights);
|
EXPECT_EQ(origNumLights, imported->mNumLights);
|
||||||
for(size_t i=0; i < origNumLights; i++) {
|
for (size_t i = 0; i < origNumLights; i++) {
|
||||||
const aiLight *orig = &origLights[ i ];
|
const aiLight *orig = &origLights[i];
|
||||||
const aiLight *read = imported->mLights[i];
|
const aiLight *read = imported->mLights[i];
|
||||||
EXPECT_EQ( 0,strncmp(origNames[ i ].c_str(),read->mName.C_Str(), origNames[ i ].size() ) );
|
EXPECT_EQ(0, strncmp(origNames[i].c_str(), read->mName.C_Str(), origNames[i].size()));
|
||||||
EXPECT_EQ( orig->mType,read->mType);
|
EXPECT_EQ(orig->mType, read->mType);
|
||||||
EXPECT_FLOAT_EQ(orig->mAttenuationConstant,read->mAttenuationConstant);
|
EXPECT_FLOAT_EQ(orig->mAttenuationConstant, read->mAttenuationConstant);
|
||||||
EXPECT_FLOAT_EQ(orig->mAttenuationLinear,read->mAttenuationLinear);
|
EXPECT_FLOAT_EQ(orig->mAttenuationLinear, read->mAttenuationLinear);
|
||||||
EXPECT_NEAR(orig->mAttenuationQuadratic,read->mAttenuationQuadratic, 0.001f);
|
EXPECT_NEAR(orig->mAttenuationQuadratic, read->mAttenuationQuadratic, 0.001f);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(orig->mColorAmbient.r,read->mColorAmbient.r);
|
EXPECT_FLOAT_EQ(orig->mColorAmbient.r, read->mColorAmbient.r);
|
||||||
EXPECT_FLOAT_EQ(orig->mColorAmbient.g,read->mColorAmbient.g);
|
EXPECT_FLOAT_EQ(orig->mColorAmbient.g, read->mColorAmbient.g);
|
||||||
EXPECT_FLOAT_EQ(orig->mColorAmbient.b,read->mColorAmbient.b);
|
EXPECT_FLOAT_EQ(orig->mColorAmbient.b, read->mColorAmbient.b);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(orig->mColorDiffuse.r,read->mColorDiffuse.r);
|
EXPECT_FLOAT_EQ(orig->mColorDiffuse.r, read->mColorDiffuse.r);
|
||||||
EXPECT_FLOAT_EQ(orig->mColorDiffuse.g,read->mColorDiffuse.g);
|
EXPECT_FLOAT_EQ(orig->mColorDiffuse.g, read->mColorDiffuse.g);
|
||||||
EXPECT_FLOAT_EQ(orig->mColorDiffuse.b,read->mColorDiffuse.b);
|
EXPECT_FLOAT_EQ(orig->mColorDiffuse.b, read->mColorDiffuse.b);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(orig->mColorSpecular.r,read->mColorSpecular.r);
|
EXPECT_FLOAT_EQ(orig->mColorSpecular.r, read->mColorSpecular.r);
|
||||||
EXPECT_FLOAT_EQ(orig->mColorSpecular.g,read->mColorSpecular.g);
|
EXPECT_FLOAT_EQ(orig->mColorSpecular.g, read->mColorSpecular.g);
|
||||||
EXPECT_FLOAT_EQ(orig->mColorSpecular.b,read->mColorSpecular.b);
|
EXPECT_FLOAT_EQ(orig->mColorSpecular.b, read->mColorSpecular.b);
|
||||||
|
|
||||||
EXPECT_NEAR(orig->mAngleInnerCone,read->mAngleInnerCone,0.001);
|
EXPECT_NEAR(orig->mAngleInnerCone, read->mAngleInnerCone, 0.001);
|
||||||
EXPECT_NEAR(orig->mAngleOuterCone,read->mAngleOuterCone,0.001);
|
EXPECT_NEAR(orig->mAngleOuterCone, read->mAngleOuterCone, 0.001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -52,79 +50,79 @@ using namespace Assimp;
|
||||||
|
|
||||||
class utColladaImportExport : public AbstractImportExportBase {
|
class utColladaImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.dae", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.dae", aiProcess_ValidateDataStructure);
|
||||||
if (scene == nullptr)
|
if (scene == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Expected number of items
|
// Expected number of items
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1u);
|
EXPECT_EQ(scene->mNumMeshes, 1u);
|
||||||
EXPECT_EQ(scene->mNumMaterials, 1u);
|
EXPECT_EQ(scene->mNumMaterials, 1u);
|
||||||
EXPECT_EQ(scene->mNumAnimations, 0u);
|
EXPECT_EQ(scene->mNumAnimations, 0u);
|
||||||
EXPECT_EQ(scene->mNumTextures, 0u);
|
EXPECT_EQ(scene->mNumTextures, 0u);
|
||||||
EXPECT_EQ(scene->mNumLights, 1u);
|
EXPECT_EQ(scene->mNumLights, 1u);
|
||||||
EXPECT_EQ(scene->mNumCameras, 1u);
|
EXPECT_EQ(scene->mNumCameras, 1u);
|
||||||
|
|
||||||
// Expected common metadata
|
// Expected common metadata
|
||||||
aiString value;
|
aiString value;
|
||||||
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, value)) << "No importer format metadata";
|
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, value)) << "No importer format metadata";
|
||||||
EXPECT_STREQ("Collada Importer", value.C_Str());
|
EXPECT_STREQ("Collada Importer", value.C_Str());
|
||||||
|
|
||||||
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT_VERSION, value)) << "No format version metadata";
|
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT_VERSION, value)) << "No format version metadata";
|
||||||
EXPECT_STREQ("1.4.1", value.C_Str());
|
EXPECT_STREQ("1.4.1", value.C_Str());
|
||||||
|
|
||||||
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, value)) << "No generator metadata";
|
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, value)) << "No generator metadata";
|
||||||
EXPECT_EQ(strncmp(value.C_Str(), "Maya 8.0", 8), 0) << "AI_METADATA_SOURCE_GENERATOR was: " << value.C_Str();
|
EXPECT_EQ(strncmp(value.C_Str(), "Maya 8.0", 8), 0) << "AI_METADATA_SOURCE_GENERATOR was: " << value.C_Str();
|
||||||
|
|
||||||
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, value)) << "No copyright metadata";
|
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, value)) << "No copyright metadata";
|
||||||
EXPECT_EQ(strncmp(value.C_Str(), "Copyright 2006", 14), 0) << "AI_METADATA_SOURCE_COPYRIGHT was: " << value.C_Str();
|
EXPECT_EQ(strncmp(value.C_Str(), "Copyright 2006", 14), 0) << "AI_METADATA_SOURCE_COPYRIGHT was: " << value.C_Str();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(utColladaImportExport, importBlenFromFileTest) {
|
TEST_F(utColladaImportExport, importBlenFromFileTest) {
|
||||||
EXPECT_TRUE(importerTest());
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
class utColladaZaeImportExport : public AbstractImportExportBase {
|
class utColladaZaeImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
{
|
{
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.zae", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.zae", aiProcess_ValidateDataStructure);
|
||||||
if (scene == nullptr)
|
if (scene == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Expected number of items
|
// Expected number of items
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1u);
|
EXPECT_EQ(scene->mNumMeshes, 1u);
|
||||||
EXPECT_EQ(scene->mNumMaterials, 1u);
|
EXPECT_EQ(scene->mNumMaterials, 1u);
|
||||||
EXPECT_EQ(scene->mNumAnimations, 0u);
|
EXPECT_EQ(scene->mNumAnimations, 0u);
|
||||||
EXPECT_EQ(scene->mNumTextures, 1u);
|
EXPECT_EQ(scene->mNumTextures, 1u);
|
||||||
EXPECT_EQ(scene->mNumLights, 1u);
|
EXPECT_EQ(scene->mNumLights, 1u);
|
||||||
EXPECT_EQ(scene->mNumCameras, 1u);
|
EXPECT_EQ(scene->mNumCameras, 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck_nomanifest.zae", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck_nomanifest.zae", aiProcess_ValidateDataStructure);
|
||||||
if (scene == nullptr)
|
if (scene == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Expected number of items
|
// Expected number of items
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1u);
|
EXPECT_EQ(scene->mNumMeshes, 1u);
|
||||||
EXPECT_EQ(scene->mNumMaterials, 1u);
|
EXPECT_EQ(scene->mNumMaterials, 1u);
|
||||||
EXPECT_EQ(scene->mNumAnimations, 0u);
|
EXPECT_EQ(scene->mNumAnimations, 0u);
|
||||||
EXPECT_EQ(scene->mNumTextures, 1u);
|
EXPECT_EQ(scene->mNumTextures, 1u);
|
||||||
EXPECT_EQ(scene->mNumLights, 1u);
|
EXPECT_EQ(scene->mNumLights, 1u);
|
||||||
EXPECT_EQ(scene->mNumCameras, 1u);
|
EXPECT_EQ(scene->mNumCameras, 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(utColladaZaeImportExport, importBlenFromFileTest) {
|
TEST_F(utColladaZaeImportExport, importBlenFromFileTest) {
|
||||||
EXPECT_TRUE(importerTest());
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,13 +38,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/Exporter.hpp>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
#include "3MF/D3MFExporter.h"
|
#include "3MF/D3MFExporter.h"
|
||||||
|
|
||||||
|
@ -55,23 +53,23 @@ public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_EQ( 1u, scene->mNumMeshes );
|
EXPECT_EQ(1u, scene->mNumMeshes);
|
||||||
aiMesh *mesh = scene->mMeshes[ 0 ];
|
aiMesh *mesh = scene->mMeshes[0];
|
||||||
EXPECT_NE( nullptr, mesh );
|
EXPECT_NE(nullptr, mesh);
|
||||||
EXPECT_EQ( 12u, mesh->mNumFaces );
|
EXPECT_EQ(12u, mesh->mNumFaces);
|
||||||
EXPECT_EQ( 8u, mesh->mNumVertices );
|
EXPECT_EQ(8u, mesh->mNumVertices);
|
||||||
|
|
||||||
return ( nullptr != scene );
|
return (nullptr != scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
virtual bool exporterTest() {
|
virtual bool exporterTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", 0 );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", 0);
|
||||||
|
|
||||||
Assimp::Exporter exporter;
|
Assimp::Exporter exporter;
|
||||||
return AI_SUCCESS == exporter.Export( scene, "3mf", "test.3mf" );
|
return AI_SUCCESS == exporter.Export(scene, "3mf", "test.3mf");
|
||||||
}
|
}
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
};
|
};
|
||||||
|
@ -82,16 +80,16 @@ TEST_F(utD3MFImporterExporter, import3MFFromFileTest) {
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
TEST_F( utD3MFImporterExporter, export3MFtoMemTest ) {
|
TEST_F(utD3MFImporterExporter, export3MFtoMemTest) {
|
||||||
EXPECT_TRUE( exporterTest() );
|
EXPECT_TRUE(exporterTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utD3MFImporterExporter, roundtrip3MFtoMemTest ) {
|
TEST_F(utD3MFImporterExporter, roundtrip3MFtoMemTest) {
|
||||||
EXPECT_TRUE( exporterTest() );
|
EXPECT_TRUE(exporterTest());
|
||||||
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( "test.3mf", 0 );
|
const aiScene *scene = importer.ReadFile("test.3mf", 0);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,32 +39,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class utDXFImporterExporter : public AbstractImportExportBase {
|
class utDXFImporterExporter : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
bool importerTest() override {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/DXF/PinkEggFromLW.dxf", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/DXF/PinkEggFromLW.dxf", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utDXFImporterExporter, importDXFFromFileTest ) {
|
TEST_F(utDXFImporterExporter, importDXFFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utDXFImporterExporter, importerWithoutExtensionTest ) {
|
TEST_F(utDXFImporterExporter, importerWithoutExtensionTest) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/DXF/lineTest", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/DXF/lineTest", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utDXFImporterExporter, issue2229) {
|
TEST_F(utDXFImporterExporter, issue2229) {
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,16 +39,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/commonMetaData.h>
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
#include <assimp/commonMetaData.h>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -58,26 +56,25 @@ class utFBXImporterExporter : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/spider.fbx", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/spider.fbx", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utFBXImporterExporter, importXFromFileTest ) {
|
TEST_F(utFBXImporterExporter, importXFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utFBXImporterExporter, importBareBoxWithoutColorsAndTextureCoords ) {
|
TEST_F(utFBXImporterExporter, importBareBoxWithoutColorsAndTextureCoords) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/box.fbx", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/box.fbx", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1u);
|
EXPECT_EQ(scene->mNumMeshes, 1u);
|
||||||
aiMesh* mesh = scene->mMeshes[0];
|
aiMesh *mesh = scene->mMeshes[0];
|
||||||
EXPECT_EQ(mesh->mNumFaces, 12u);
|
EXPECT_EQ(mesh->mNumFaces, 12u);
|
||||||
EXPECT_EQ(mesh->mNumVertices, 36u);
|
EXPECT_EQ(mesh->mNumVertices, 36u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F(utFBXImporterExporter, importCubesWithNoNames) {
|
TEST_F(utFBXImporterExporter, importCubesWithNoNames) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/cubes_nonames.fbx", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/cubes_nonames.fbx", aiProcess_ValidateDataStructure);
|
||||||
|
@ -149,7 +146,7 @@ TEST_F(utFBXImporterExporter, importCubesComplexTransform) {
|
||||||
|
|
||||||
auto parent = child1;
|
auto parent = child1;
|
||||||
const size_t chain_length = 8u;
|
const size_t chain_length = 8u;
|
||||||
const char* chainStr[chain_length] = {
|
const char *chainStr[chain_length] = {
|
||||||
"Cube1_$AssimpFbx$_Translation",
|
"Cube1_$AssimpFbx$_Translation",
|
||||||
"Cube1_$AssimpFbx$_RotationPivot",
|
"Cube1_$AssimpFbx$_RotationPivot",
|
||||||
"Cube1_$AssimpFbx$_RotationPivotInverse",
|
"Cube1_$AssimpFbx$_RotationPivotInverse",
|
||||||
|
@ -178,33 +175,33 @@ TEST_F(utFBXImporterExporter, importCloseToIdentityTransforms) {
|
||||||
ASSERT_TRUE(scene);
|
ASSERT_TRUE(scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utFBXImporterExporter, importPhongMaterial ) {
|
TEST_F(utFBXImporterExporter, importPhongMaterial) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/phong_cube.fbx", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/phong_cube.fbx", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ( 1u, scene->mNumMaterials );
|
EXPECT_EQ(1u, scene->mNumMaterials);
|
||||||
const aiMaterial *mat = scene->mMaterials[0];
|
const aiMaterial *mat = scene->mMaterials[0];
|
||||||
EXPECT_NE( nullptr, mat );
|
EXPECT_NE(nullptr, mat);
|
||||||
float f;
|
float f;
|
||||||
aiColor3D c;
|
aiColor3D c;
|
||||||
|
|
||||||
// phong_cube.fbx has all properties defined
|
// phong_cube.fbx has all properties defined
|
||||||
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_DIFFUSE, c), aiReturn_SUCCESS );
|
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_DIFFUSE, c), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ( c, aiColor3D(0.5, 0.25, 0.25) );
|
EXPECT_EQ(c, aiColor3D(0.5, 0.25, 0.25));
|
||||||
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_SPECULAR, c), aiReturn_SUCCESS );
|
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_SPECULAR, c), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ( c, aiColor3D(0.25, 0.25, 0.5) );
|
EXPECT_EQ(c, aiColor3D(0.25, 0.25, 0.5));
|
||||||
EXPECT_EQ( mat->Get(AI_MATKEY_SHININESS_STRENGTH, f), aiReturn_SUCCESS );
|
EXPECT_EQ(mat->Get(AI_MATKEY_SHININESS_STRENGTH, f), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ( f, 0.5f );
|
EXPECT_EQ(f, 0.5f);
|
||||||
EXPECT_EQ( mat->Get(AI_MATKEY_SHININESS, f), aiReturn_SUCCESS );
|
EXPECT_EQ(mat->Get(AI_MATKEY_SHININESS, f), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ( f, 10.0f );
|
EXPECT_EQ(f, 10.0f);
|
||||||
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_AMBIENT, c), aiReturn_SUCCESS );
|
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_AMBIENT, c), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ( c, aiColor3D(0.125, 0.25, 0.25) );
|
EXPECT_EQ(c, aiColor3D(0.125, 0.25, 0.25));
|
||||||
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_EMISSIVE, c), aiReturn_SUCCESS );
|
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_EMISSIVE, c), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ( c, aiColor3D(0.25, 0.125, 0.25) );
|
EXPECT_EQ(c, aiColor3D(0.25, 0.125, 0.25));
|
||||||
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_TRANSPARENT, c), aiReturn_SUCCESS );
|
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_TRANSPARENT, c), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ( c, aiColor3D(0.75, 0.5, 0.25) );
|
EXPECT_EQ(c, aiColor3D(0.75, 0.5, 0.25));
|
||||||
EXPECT_EQ( mat->Get(AI_MATKEY_OPACITY, f), aiReturn_SUCCESS );
|
EXPECT_EQ(mat->Get(AI_MATKEY_OPACITY, f), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ( f, 0.5f );
|
EXPECT_EQ(f, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
|
TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
|
||||||
|
@ -288,7 +285,7 @@ TEST_F(utFBXImporterExporter, importOrphantEmbeddedTextureTest) {
|
||||||
TEST_F(utFBXImporterExporter, sceneMetadata) {
|
TEST_F(utFBXImporterExporter, sceneMetadata) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/global_settings.fbx",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/global_settings.fbx",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(scene, nullptr);
|
ASSERT_NE(scene, nullptr);
|
||||||
ASSERT_NE(scene->mMetaData, nullptr);
|
ASSERT_NE(scene->mMetaData, nullptr);
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,10 +47,8 @@ using namespace Assimp;
|
||||||
|
|
||||||
class FindDegeneratesProcessTest : public ::testing::Test {
|
class FindDegeneratesProcessTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
FindDegeneratesProcessTest()
|
FindDegeneratesProcessTest() :
|
||||||
: Test()
|
Test(), mMesh(nullptr), mProcess(nullptr) {
|
||||||
, mMesh( nullptr )
|
|
||||||
, mProcess( nullptr ) {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +57,8 @@ protected:
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
aiMesh* mMesh;
|
aiMesh *mMesh;
|
||||||
FindDegeneratesProcess* mProcess;
|
FindDegeneratesProcess *mProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
void FindDegeneratesProcessTest::SetUp() {
|
void FindDegeneratesProcessTest::SetUp() {
|
||||||
|
@ -70,24 +68,24 @@ void FindDegeneratesProcessTest::SetUp() {
|
||||||
mMesh->mNumFaces = 1000;
|
mMesh->mNumFaces = 1000;
|
||||||
mMesh->mFaces = new aiFace[1000];
|
mMesh->mFaces = new aiFace[1000];
|
||||||
|
|
||||||
mMesh->mNumVertices = 5000*2;
|
mMesh->mNumVertices = 5000 * 2;
|
||||||
mMesh->mVertices = new aiVector3D[5000*2];
|
mMesh->mVertices = new aiVector3D[5000 * 2];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 5000; ++i) {
|
for (unsigned int i = 0; i < 5000; ++i) {
|
||||||
mMesh->mVertices[i] = mMesh->mVertices[i+5000] = aiVector3D((float)i);
|
mMesh->mVertices[i] = mMesh->mVertices[i + 5000] = aiVector3D((float)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
mMesh->mPrimitiveTypes = aiPrimitiveType_LINE | aiPrimitiveType_POINT |
|
mMesh->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 = mMesh->mFaces[i];
|
aiFace &f = mMesh->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) {
|
||||||
|
@ -96,12 +94,11 @@ void FindDegeneratesProcessTest::SetUp() {
|
||||||
}
|
}
|
||||||
// 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)
|
||||||
|
@ -122,7 +119,7 @@ TEST_F(FindDegeneratesProcessTest, testDegeneratesDetection) {
|
||||||
|
|
||||||
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 = mMesh->mFaces[i];
|
aiFace &f = mMesh->mFaces[i];
|
||||||
out += f.mNumIndices;
|
out += f.mNumIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +127,9 @@ TEST_F(FindDegeneratesProcessTest, testDegeneratesDetection) {
|
||||||
EXPECT_EQ(10000U, mMesh->mNumVertices);
|
EXPECT_EQ(10000U, mMesh->mNumVertices);
|
||||||
EXPECT_EQ(out, mMesh->mNumUVComponents[0]);
|
EXPECT_EQ(out, mMesh->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),
|
||||||
mMesh->mPrimitiveTypes);
|
mMesh->mPrimitiveTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FindDegeneratesProcessTest, testDegeneratesRemoval) {
|
TEST_F(FindDegeneratesProcessTest, testDegeneratesRemoval) {
|
||||||
|
@ -148,5 +145,5 @@ TEST_F(FindDegeneratesProcessTest, testDegeneratesRemovalWithAreaCheck) {
|
||||||
mProcess->EnableInstantRemoval(true);
|
mProcess->EnableInstantRemoval(true);
|
||||||
mProcess->ExecuteOnMesh(mMesh);
|
mProcess->ExecuteOnMesh(mMesh);
|
||||||
|
|
||||||
EXPECT_EQ(mMesh->mNumUVComponents[1]-100, mMesh->mNumFaces);
|
EXPECT_EQ(mMesh->mNumUVComponents[1] - 100, mMesh->mNumFaces);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,8 @@ using namespace Assimp;
|
||||||
|
|
||||||
class utFindInvalidDataProcess : public ::testing::Test {
|
class utFindInvalidDataProcess : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
utFindInvalidDataProcess()
|
utFindInvalidDataProcess() :
|
||||||
: Test()
|
Test(), mMesh(nullptr), mProcess(nullptr) {
|
||||||
, mMesh(nullptr)
|
|
||||||
, mProcess(nullptr) {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,13 +58,13 @@ protected:
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
aiMesh* mMesh;
|
aiMesh *mMesh;
|
||||||
FindInvalidDataProcess* mProcess;
|
FindInvalidDataProcess *mProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void utFindInvalidDataProcess::SetUp() {
|
void utFindInvalidDataProcess::SetUp() {
|
||||||
ASSERT_TRUE( AI_MAX_NUMBER_OF_TEXTURECOORDS >= 3);
|
ASSERT_TRUE(AI_MAX_NUMBER_OF_TEXTURECOORDS >= 3);
|
||||||
|
|
||||||
mProcess = new FindInvalidDataProcess();
|
mProcess = new FindInvalidDataProcess();
|
||||||
mMesh = new aiMesh();
|
mMesh = new aiMesh();
|
||||||
|
@ -92,7 +90,7 @@ void utFindInvalidDataProcess::SetUp() {
|
||||||
mMesh->mBitangents[i] = aiVector3D((float)i);
|
mMesh->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) {
|
||||||
mMesh->mTextureCoords[a] = new aiVector3D[1000];
|
mMesh->mTextureCoords[a] = new aiVector3D[1000];
|
||||||
for (unsigned int i = 0; i < 1000; ++i) {
|
for (unsigned int i = 0; i < 1000; ++i) {
|
||||||
mMesh->mTextureCoords[a][i] = aiVector3D((float)i);
|
mMesh->mTextureCoords[a][i] = aiVector3D((float)i);
|
||||||
|
@ -108,10 +106,10 @@ void utFindInvalidDataProcess::TearDown() {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(utFindInvalidDataProcess, testStepNegativeResult) {
|
TEST_F(utFindInvalidDataProcess, testStepNegativeResult) {
|
||||||
::memset(mMesh->mNormals, 0, mMesh->mNumVertices*sizeof(aiVector3D) );
|
::memset(mMesh->mNormals, 0, mMesh->mNumVertices * sizeof(aiVector3D));
|
||||||
::memset(mMesh->mBitangents, 0, mMesh->mNumVertices*sizeof(aiVector3D) );
|
::memset(mMesh->mBitangents, 0, mMesh->mNumVertices * sizeof(aiVector3D));
|
||||||
|
|
||||||
mMesh->mTextureCoords[2][455] = aiVector3D( std::numeric_limits<float>::quiet_NaN() );
|
mMesh->mTextureCoords[2][455] = aiVector3D(std::numeric_limits<float>::quiet_NaN());
|
||||||
|
|
||||||
mProcess->ProcessMesh(mMesh);
|
mProcess->ProcessMesh(mMesh);
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,8 @@ using namespace Assimp;
|
||||||
|
|
||||||
class utGenBoundingBoxesProcess : public ::testing::Test {
|
class utGenBoundingBoxesProcess : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
utGenBoundingBoxesProcess()
|
utGenBoundingBoxesProcess() :
|
||||||
: Test()
|
Test(), mProcess(nullptr), mMesh(nullptr), mScene(nullptr) {
|
||||||
, mProcess(nullptr)
|
|
||||||
, mMesh(nullptr)
|
|
||||||
, mScene(nullptr) {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +63,7 @@ public:
|
||||||
}
|
}
|
||||||
mScene = new aiScene();
|
mScene = new aiScene();
|
||||||
mScene->mNumMeshes = 1;
|
mScene->mNumMeshes = 1;
|
||||||
mScene->mMeshes = new aiMesh*[1];
|
mScene->mMeshes = new aiMesh *[1];
|
||||||
mScene->mMeshes[0] = mMesh;
|
mScene->mMeshes[0] = mMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,13 +75,13 @@ public:
|
||||||
protected:
|
protected:
|
||||||
GenBoundingBoxesProcess *mProcess;
|
GenBoundingBoxesProcess *mProcess;
|
||||||
aiMesh *mMesh;
|
aiMesh *mMesh;
|
||||||
aiScene* mScene;
|
aiScene *mScene;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(utGenBoundingBoxesProcess, executeTest) {
|
TEST_F(utGenBoundingBoxesProcess, executeTest) {
|
||||||
mProcess->Execute(mScene);
|
mProcess->Execute(mScene);
|
||||||
|
|
||||||
aiMesh* mesh = mScene->mMeshes[0];
|
aiMesh *mesh = mScene->mMeshes[0];
|
||||||
EXPECT_NE(nullptr, mesh);
|
EXPECT_NE(nullptr, mesh);
|
||||||
EXPECT_EQ(0, mesh->mAABB.mMin.x);
|
EXPECT_EQ(0, mesh->mAABB.mMin.x);
|
||||||
EXPECT_EQ(0, mesh->mAABB.mMin.y);
|
EXPECT_EQ(0, mesh->mAABB.mMin.y);
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -47,20 +45,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
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;
|
||||||
|
@ -72,21 +68,19 @@ void GenNormalsTest::SetUp()
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,4 +39,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
|
@ -49,10 +49,8 @@ using namespace Assimp;
|
||||||
|
|
||||||
class utJoinVertices : public ::testing::Test {
|
class utJoinVertices : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
utJoinVertices()
|
utJoinVertices() :
|
||||||
: Test()
|
Test(), piProcess(nullptr), pcMesh(nullptr) {
|
||||||
, piProcess(nullptr)
|
|
||||||
, pcMesh(nullptr) {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +59,8 @@ protected:
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
JoinVerticesProcess* piProcess;
|
JoinVerticesProcess *piProcess;
|
||||||
aiMesh* pcMesh;
|
aiMesh *pcMesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -75,20 +73,20 @@ void utJoinVertices::SetUp() {
|
||||||
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++;
|
||||||
}
|
}
|
||||||
|
@ -118,21 +116,21 @@ void utJoinVertices::TearDown() {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(utJoinVertices, testProcess) {
|
TEST_F(utJoinVertices, 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( nullptr != pcMesh->mNormals);
|
ASSERT_TRUE(nullptr != pcMesh->mNormals);
|
||||||
ASSERT_TRUE( nullptr != pcMesh->mTangents);
|
ASSERT_TRUE(nullptr != pcMesh->mTangents);
|
||||||
ASSERT_TRUE( nullptr != pcMesh->mBitangents);
|
ASSERT_TRUE(nullptr != pcMesh->mBitangents);
|
||||||
ASSERT_TRUE( nullptr != pcMesh->mTextureCoords[0]);
|
ASSERT_TRUE(nullptr != 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);
|
||||||
|
@ -140,5 +138,5 @@ TEST_F(utJoinVertices, testProcess) {
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,20 +38,19 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
class utLWOImportExport : public AbstractImportExportBase {
|
class utLWOImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/boxuv.lwo", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/boxuv.lwo", aiProcess_ValidateDataStructure);
|
||||||
|
|
||||||
EXPECT_EQ(1u, scene->mNumMeshes);
|
EXPECT_EQ(1u, scene->mNumMeshes);
|
||||||
EXPECT_NE(nullptr, scene->mMeshes[0]);
|
EXPECT_NE(nullptr, scene->mMeshes[0]);
|
||||||
|
@ -68,8 +65,8 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utLWOImportExport, importLWObox_uv ) {
|
TEST_F(utLWOImportExport, importLWObox_uv) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utLWOImportExport, importLWOformatdetection) {
|
TEST_F(utLWOImportExport, importLWOformatdetection) {
|
||||||
|
@ -78,4 +75,3 @@ TEST_F(utLWOImportExport, importLWOformatdetection) {
|
||||||
|
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,26 +38,25 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
class utLWSImportExport : public AbstractImportExportBase {
|
class utLWSImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/LWS/move_x.lws", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x.lws", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utLWSImportExport, importLWSFromFileTest ) {
|
TEST_F(utLWSImportExport, importLWSFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utLWSImportExport, importLWSmove_x_post_linear) {
|
TEST_F(utLWSImportExport, importLWSmove_x_post_linear) {
|
||||||
|
@ -139,4 +136,3 @@ TEST_F(utLWSImportExport, importLWSmove_xz_spline) {
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_spline.lws", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_spline.lws", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,18 +40,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "PostProcessing/LimitBoneWeightsProcess.h"
|
#include "PostProcessing/LimitBoneWeightsProcess.h"
|
||||||
|
#include <assimp/scene.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:
|
||||||
LimitBoneWeightsTest()
|
LimitBoneWeightsTest() :
|
||||||
: Test()
|
Test(), mProcess(nullptr), mMesh(nullptr) {
|
||||||
, mProcess(nullptr)
|
|
||||||
, mMesh(nullptr) {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,14 +73,14 @@ void LimitBoneWeightsTest::SetUp() {
|
||||||
mMesh->mNumVertices = 500;
|
mMesh->mNumVertices = 500;
|
||||||
mMesh->mVertices = new aiVector3D[500]; // uninit.
|
mMesh->mVertices = new aiVector3D[500]; // uninit.
|
||||||
mMesh->mNumBones = 30;
|
mMesh->mNumBones = 30;
|
||||||
mMesh->mBones = new aiBone*[30];
|
mMesh->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 = mMesh->mBones[i] = new aiBone();
|
aiBone *pc = mMesh->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) {
|
if (500 == iCur) {
|
||||||
iCur = 0;
|
iCur = 0;
|
||||||
|
@ -105,26 +103,26 @@ TEST_F(LimitBoneWeightsTest, testProcess) {
|
||||||
|
|
||||||
// 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[mMesh->mNumVertices];
|
VertexWeightList *asWeights = new VertexWeightList[mMesh->mNumVertices];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mMesh->mNumVertices; ++i) {
|
for (unsigned int i = 0; i < mMesh->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 < mMesh->mNumBones;++i) {
|
for (unsigned int i = 0; i < mMesh->mNumBones; ++i) {
|
||||||
aiBone& pcBone = **(mMesh->mBones+i);
|
aiBone &pcBone = **(mMesh->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 < mMesh->mNumVertices;++i) {
|
for (unsigned int i = 0; i < mMesh->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 iter = asWeights[i].begin(); iter != asWeights[i].end();++iter) {
|
for (VertexWeightList::const_iterator iter = asWeights[i].begin(); iter != asWeights[i].end(); ++iter) {
|
||||||
fSum += (*iter).mWeight;
|
fSum += (*iter).mWeight;
|
||||||
}
|
}
|
||||||
EXPECT_GE(fSum, 0.95F);
|
EXPECT_GE(fSum, 0.95F);
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp tea
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
@ -41,12 +40,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ class utM3DImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure);
|
||||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
#else
|
#else
|
||||||
|
@ -63,6 +62,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utM3DImportExport, importM3DFromFileTest ) {
|
TEST_F(utM3DImportExport, importM3DFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
|
|
||||||
//const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MDC/spider.mdc", 0);
|
//const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MDC/spider.mdc", 0);
|
||||||
static_cast<void>( importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MDC/spider.mdc", 0) );
|
static_cast<void>(importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MDC/spider.mdc", 0));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,8 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "Material/MaterialSystem.h"
|
#include "Material/MaterialSystem.h"
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
using namespace ::std;
|
using namespace ::std;
|
||||||
using namespace ::Assimp;
|
using namespace ::Assimp;
|
||||||
|
@ -54,67 +52,65 @@ public:
|
||||||
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;
|
||||||
this->pcMat->AddProperty(&clr,1,"testKey5");
|
clr.g = 3.0f;
|
||||||
|
clr.b = 4.0f;
|
||||||
|
clr.a = 5.0f;
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,13 +118,12 @@ TEST_F(MaterialSystemTest, testColorProperty)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(MaterialSystemTest, testMaterialNameAccess) {
|
TEST_F(MaterialSystemTest, testMaterialNameAccess) {
|
||||||
aiMaterial *mat = new aiMaterial();
|
aiMaterial *mat = new aiMaterial();
|
||||||
|
@ -136,7 +131,7 @@ TEST_F(MaterialSystemTest, testMaterialNameAccess) {
|
||||||
|
|
||||||
aiString name = mat->GetName();
|
aiString name = mat->GetName();
|
||||||
const int retValue(strncmp(name.C_Str(), AI_DEFAULT_MATERIAL_NAME, name.length));
|
const int retValue(strncmp(name.C_Str(), AI_DEFAULT_MATERIAL_NAME, name.length));
|
||||||
EXPECT_EQ(0, retValue );
|
EXPECT_EQ(0, retValue);
|
||||||
|
|
||||||
delete mat;
|
delete mat;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -50,27 +48,23 @@ class utMatrix3x3Test : public ::testing::Test {
|
||||||
// empty
|
// empty
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utMatrix3x3Test, FromToMatrixTest ) {
|
TEST_F(utMatrix3x3Test, FromToMatrixTest) {
|
||||||
aiVector3D res;
|
aiVector3D res;
|
||||||
aiMatrix3x3 trafo;
|
aiMatrix3x3 trafo;
|
||||||
|
|
||||||
const double PRECISION = 0.000001;
|
const double PRECISION = 0.000001;
|
||||||
|
|
||||||
// axes test
|
// axes test
|
||||||
aiVector3D axes[] =
|
aiVector3D axes[] = { aiVector3D(1, 0, 0), aiVector3D(0, 1, 0), aiVector3D(0, 0, 1) };
|
||||||
{ aiVector3D(1, 0, 0)
|
|
||||||
, aiVector3D(0, 1, 0)
|
|
||||||
, aiVector3D(0, 0, 1)
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
for (int j = 0; j < 3; ++j) {
|
for (int j = 0; j < 3; ++j) {
|
||||||
aiMatrix3x3::FromToMatrix( axes[i], axes[j], trafo );
|
aiMatrix3x3::FromToMatrix(axes[i], axes[j], trafo);
|
||||||
res = trafo * axes[i];
|
res = trafo * axes[i];
|
||||||
|
|
||||||
ASSERT_NEAR( axes[j].x, res.x, PRECISION );
|
ASSERT_NEAR(axes[j].x, res.x, PRECISION);
|
||||||
ASSERT_NEAR( axes[j].y, res.y, PRECISION );
|
ASSERT_NEAR(axes[j].y, res.y, PRECISION);
|
||||||
ASSERT_NEAR( axes[j].z, res.z, PRECISION );
|
ASSERT_NEAR(axes[j].z, res.z, PRECISION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,22 +74,14 @@ TEST_F( utMatrix3x3Test, FromToMatrixTest ) {
|
||||||
aiVector3D from, to;
|
aiVector3D from, to;
|
||||||
|
|
||||||
for (int i = 0; i < NUM_SAMPLES; ++i) {
|
for (int i = 0; i < NUM_SAMPLES; ++i) {
|
||||||
from = aiVector3D
|
from = aiVector3D(1.f * rand() / RAND_MAX, 1.f * rand() / RAND_MAX, 1.f * rand() / RAND_MAX).Normalize();
|
||||||
( 1.f * rand() / RAND_MAX
|
to = aiVector3D(1.f * rand() / RAND_MAX, 1.f * rand() / RAND_MAX, 1.f * rand() / RAND_MAX).Normalize();
|
||||||
, 1.f * rand() / RAND_MAX
|
|
||||||
, 1.f * rand() / RAND_MAX
|
|
||||||
).Normalize();
|
|
||||||
to = aiVector3D
|
|
||||||
( 1.f * rand() / RAND_MAX
|
|
||||||
, 1.f * rand() / RAND_MAX
|
|
||||||
, 1.f * rand() / RAND_MAX
|
|
||||||
).Normalize();
|
|
||||||
|
|
||||||
aiMatrix3x3::FromToMatrix( from, to, trafo );
|
aiMatrix3x3::FromToMatrix(from, to, trafo);
|
||||||
res = trafo * from;
|
res = trafo * from;
|
||||||
|
|
||||||
ASSERT_NEAR( to.x, res.x, PRECISION );
|
ASSERT_NEAR(to.x, res.x, PRECISION);
|
||||||
ASSERT_NEAR( to.y, res.y, PRECISION );
|
ASSERT_NEAR(to.y, res.y, PRECISION);
|
||||||
ASSERT_NEAR( to.z, res.z, PRECISION );
|
ASSERT_NEAR(to.z, res.z, PRECISION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -46,50 +44,49 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class utMatrix4x4 : public ::testing::Test {
|
class utMatrix4x4 : public ::testing::Test {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utMatrix4x4, badIndexOperatorTest ) {
|
TEST_F(utMatrix4x4, badIndexOperatorTest) {
|
||||||
aiMatrix4x4 m;
|
aiMatrix4x4 m;
|
||||||
ai_real *a0 = m[ 4 ];
|
ai_real *a0 = m[4];
|
||||||
EXPECT_EQ( NULL, a0 );
|
EXPECT_EQ(NULL, a0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utMatrix4x4, indexOperatorTest ) {
|
TEST_F(utMatrix4x4, indexOperatorTest) {
|
||||||
aiMatrix4x4 m;
|
aiMatrix4x4 m;
|
||||||
ai_real *a0 = m[ 0 ];
|
ai_real *a0 = m[0];
|
||||||
EXPECT_FLOAT_EQ( 1.0, *a0 );
|
EXPECT_FLOAT_EQ(1.0, *a0);
|
||||||
ai_real *a1 = a0+1;
|
ai_real *a1 = a0 + 1;
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a1 );
|
EXPECT_FLOAT_EQ(0.0, *a1);
|
||||||
ai_real *a2 = a0 + 2;
|
ai_real *a2 = a0 + 2;
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a2 );
|
EXPECT_FLOAT_EQ(0.0, *a2);
|
||||||
ai_real *a3 = a0 + 3;
|
ai_real *a3 = a0 + 3;
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a3 );
|
EXPECT_FLOAT_EQ(0.0, *a3);
|
||||||
|
|
||||||
ai_real *a4 = m[ 1 ];
|
ai_real *a4 = m[1];
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a4 );
|
EXPECT_FLOAT_EQ(0.0, *a4);
|
||||||
ai_real *a5 = a4 + 1;
|
ai_real *a5 = a4 + 1;
|
||||||
EXPECT_FLOAT_EQ( 1.0, *a5 );
|
EXPECT_FLOAT_EQ(1.0, *a5);
|
||||||
ai_real *a6 = a4 + 2;
|
ai_real *a6 = a4 + 2;
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a6 );
|
EXPECT_FLOAT_EQ(0.0, *a6);
|
||||||
ai_real *a7 = a4 + 3;
|
ai_real *a7 = a4 + 3;
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a7 );
|
EXPECT_FLOAT_EQ(0.0, *a7);
|
||||||
|
|
||||||
ai_real *a8 = m[ 2 ];
|
ai_real *a8 = m[2];
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a8 );
|
EXPECT_FLOAT_EQ(0.0, *a8);
|
||||||
ai_real *a9 = a8 + 1;
|
ai_real *a9 = a8 + 1;
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a9 );
|
EXPECT_FLOAT_EQ(0.0, *a9);
|
||||||
ai_real *a10 = a8 + 2;
|
ai_real *a10 = a8 + 2;
|
||||||
EXPECT_FLOAT_EQ( 1.0, *a10 );
|
EXPECT_FLOAT_EQ(1.0, *a10);
|
||||||
ai_real *a11 = a8 + 3;
|
ai_real *a11 = a8 + 3;
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a11 );
|
EXPECT_FLOAT_EQ(0.0, *a11);
|
||||||
|
|
||||||
ai_real *a12 = m[ 3 ];
|
ai_real *a12 = m[3];
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a12 );
|
EXPECT_FLOAT_EQ(0.0, *a12);
|
||||||
ai_real *a13 = a12 + 1;
|
ai_real *a13 = a12 + 1;
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a13 );
|
EXPECT_FLOAT_EQ(0.0, *a13);
|
||||||
ai_real *a14 = a12 + 2;
|
ai_real *a14 = a12 + 2;
|
||||||
EXPECT_FLOAT_EQ( 0.0, *a14 );
|
EXPECT_FLOAT_EQ(0.0, *a14);
|
||||||
ai_real *a15 = a12 + 3;
|
ai_real *a15 = a12 + 3;
|
||||||
EXPECT_FLOAT_EQ( 1.0, *a15 );
|
EXPECT_FLOAT_EQ(1.0, *a15);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,9 +38,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "Obj/ObjTools.h"
|
|
||||||
#include "Obj/ObjFileParser.h"
|
#include "Obj/ObjFileParser.h"
|
||||||
|
#include "Obj/ObjTools.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
using namespace ::Assimp;
|
using namespace ::Assimp;
|
||||||
|
|
||||||
|
@ -52,16 +50,17 @@ class utObjTools : public ::testing::Test {
|
||||||
|
|
||||||
class TestObjFileParser : public ObjFileParser {
|
class TestObjFileParser : public ObjFileParser {
|
||||||
public:
|
public:
|
||||||
TestObjFileParser() : ObjFileParser(){
|
TestObjFileParser() :
|
||||||
|
ObjFileParser() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
~TestObjFileParser() {
|
~TestObjFileParser() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
void testCopyNextWord( char *pBuffer, size_t length ) {
|
void testCopyNextWord(char *pBuffer, size_t length) {
|
||||||
copyNextWord( pBuffer, length );
|
copyNextWord(pBuffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t testGetNumComponentsInDataDefinition() {
|
size_t testGetNumComponentsInDataDefinition() {
|
||||||
|
@ -69,49 +68,49 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utObjTools, skipDataLine_OneLine_Success ) {
|
TEST_F(utObjTools, skipDataLine_OneLine_Success) {
|
||||||
std::vector<char> buffer;
|
std::vector<char> buffer;
|
||||||
std::string data( "v -0.5 -0.5 0.5\nend" );
|
std::string data("v -0.5 -0.5 0.5\nend");
|
||||||
buffer.resize( data.size() );
|
buffer.resize(data.size());
|
||||||
::memcpy( &buffer[ 0 ], &data[ 0 ], data.size() );
|
::memcpy(&buffer[0], &data[0], data.size());
|
||||||
std::vector<char>::iterator itBegin( buffer.begin() ), itEnd( buffer.end() );
|
std::vector<char>::iterator itBegin(buffer.begin()), itEnd(buffer.end());
|
||||||
unsigned int line = 0;
|
unsigned int line = 0;
|
||||||
std::vector<char>::iterator current = skipLine<std::vector<char>::iterator>( itBegin, itEnd, line );
|
std::vector<char>::iterator current = skipLine<std::vector<char>::iterator>(itBegin, itEnd, line);
|
||||||
EXPECT_EQ( 'e', *current );
|
EXPECT_EQ('e', *current);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utObjTools, skipDataLine_TwoLines_Success ) {
|
TEST_F(utObjTools, skipDataLine_TwoLines_Success) {
|
||||||
TestObjFileParser test_parser;
|
TestObjFileParser test_parser;
|
||||||
std::string data( "vn -2.061493116917992e-15 -0.9009688496589661 \\\n-0.4338837265968323" );
|
std::string data("vn -2.061493116917992e-15 -0.9009688496589661 \\\n-0.4338837265968323");
|
||||||
std::vector<char> buffer;
|
std::vector<char> buffer;
|
||||||
buffer.resize( data.size() );
|
buffer.resize(data.size());
|
||||||
::memcpy( &buffer[ 0 ], &data[ 0 ], data.size() );
|
::memcpy(&buffer[0], &data[0], data.size());
|
||||||
test_parser.setBuffer( buffer );
|
test_parser.setBuffer(buffer);
|
||||||
static const size_t Size = 4096UL;
|
static const size_t Size = 4096UL;
|
||||||
char data_buffer[ Size ];
|
char data_buffer[Size];
|
||||||
|
|
||||||
test_parser.testCopyNextWord( data_buffer, Size );
|
|
||||||
EXPECT_EQ( 0, strncmp( data_buffer, "vn", 2 ) );
|
|
||||||
|
|
||||||
test_parser.testCopyNextWord( data_buffer, Size );
|
test_parser.testCopyNextWord(data_buffer, Size);
|
||||||
EXPECT_EQ( data_buffer[0], '-' );
|
EXPECT_EQ(0, strncmp(data_buffer, "vn", 2));
|
||||||
|
|
||||||
test_parser.testCopyNextWord( data_buffer, Size );
|
test_parser.testCopyNextWord(data_buffer, Size);
|
||||||
EXPECT_EQ( data_buffer[0], '-' );
|
EXPECT_EQ(data_buffer[0], '-');
|
||||||
|
|
||||||
test_parser.testCopyNextWord( data_buffer, Size );
|
test_parser.testCopyNextWord(data_buffer, Size);
|
||||||
EXPECT_EQ( data_buffer[ 0 ], '-' );
|
EXPECT_EQ(data_buffer[0], '-');
|
||||||
|
|
||||||
|
test_parser.testCopyNextWord(data_buffer, Size);
|
||||||
|
EXPECT_EQ(data_buffer[0], '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utObjTools, countComponents_TwoLines_Success ) {
|
TEST_F(utObjTools, countComponents_TwoLines_Success) {
|
||||||
TestObjFileParser test_parser;
|
TestObjFileParser test_parser;
|
||||||
std::string data( "-2.061493116917992e-15 -0.9009688496589661 \\\n-0.4338837265968323" );
|
std::string data("-2.061493116917992e-15 -0.9009688496589661 \\\n-0.4338837265968323");
|
||||||
std::vector<char> buffer;
|
std::vector<char> buffer;
|
||||||
buffer.resize( data.size() + 1 );
|
buffer.resize(data.size() + 1);
|
||||||
::memcpy( &buffer[ 0 ], &data[ 0 ], data.size() );
|
::memcpy(&buffer[0], &data[0], data.size());
|
||||||
buffer[ buffer.size() - 1 ] = '\0';
|
buffer[buffer.size() - 1] = '\0';
|
||||||
test_parser.setBuffer( buffer );
|
test_parser.setBuffer(buffer);
|
||||||
|
|
||||||
size_t numComps = test_parser.testGetNumComponentsInDataDefinition();
|
size_t numComps = test_parser.testGetNumComponentsInDataDefinition();
|
||||||
EXPECT_EQ( 3U, numComps );
|
EXPECT_EQ(3U, numComps);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,32 +39,30 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
class utOpenGEXImportExport : public AbstractImportExportBase {
|
class utOpenGEXImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0 );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utOpenGEXImportExport, importLWSFromFileTest ) {
|
TEST_F(utOpenGEXImportExport, importLWSFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utOpenGEXImportExport, Importissue1262_NoCrash ) {
|
TEST_F(utOpenGEXImportExport, Importissue1262_NoCrash) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OpenGEX/light_issue1262.ogex", 0 );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/light_issue1262.ogex", 0);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utOpenGEXImportExport, Importissue1340_EmptyCameraObject) {
|
TEST_F(utOpenGEXImportExport, Importissue1340_EmptyCameraObject) {
|
||||||
|
|
|
@ -5,7 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,11 +40,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/Exporter.hpp>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace ::Assimp;
|
using namespace ::Assimp;
|
||||||
|
|
||||||
|
@ -53,15 +52,15 @@ class utPLYImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_EQ( 1u, scene->mNumMeshes );
|
EXPECT_EQ(1u, scene->mNumMeshes);
|
||||||
EXPECT_NE( nullptr, scene->mMeshes[0] );
|
EXPECT_NE(nullptr, scene->mMeshes[0]);
|
||||||
if (nullptr == scene->mMeshes[0]) {
|
if (nullptr == scene->mMeshes[0]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
EXPECT_EQ( 8u, scene->mMeshes[0]->mNumVertices );
|
EXPECT_EQ(8u, scene->mMeshes[0]->mNumVertices);
|
||||||
EXPECT_EQ( 6u, scene->mMeshes[0]->mNumFaces );
|
EXPECT_EQ(6u, scene->mMeshes[0]->mNumFaces);
|
||||||
|
|
||||||
return (nullptr != scene);
|
return (nullptr != scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,13 +77,13 @@ public:
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utPLYImportExport, importTest_Success ) {
|
TEST_F(utPLYImportExport, importTest_Success) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
TEST_F(utPLYImportExport, exportTest_Success ) {
|
TEST_F(utPLYImportExport, exportTest_Success) {
|
||||||
EXPECT_TRUE(exporterTest());
|
EXPECT_TRUE(exporterTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,10 +125,10 @@ TEST_F(utPLYImportExport, importBinaryPLY) {
|
||||||
EXPECT_EQ(12u, scene->mMeshes[0]->mNumFaces);
|
EXPECT_EQ(12u, scene->mMeshes[0]->mNumFaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utPLYImportExport, vertexColorTest ) {
|
TEST_F(utPLYImportExport, vertexColorTest) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/PLY/float-color.ply", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/float-color.ply", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(1u, scene->mMeshes[0]->mNumFaces);
|
EXPECT_EQ(1u, scene->mMeshes[0]->mNumFaces);
|
||||||
EXPECT_EQ(aiPrimitiveType_TRIANGLE, scene->mMeshes[0]->mPrimitiveTypes);
|
EXPECT_EQ(aiPrimitiveType_TRIANGLE, scene->mMeshes[0]->mPrimitiveTypes);
|
||||||
EXPECT_EQ(true, scene->mMeshes[0]->HasVertexColors(0));
|
EXPECT_EQ(true, scene->mMeshes[0]->HasVertexColors(0));
|
||||||
|
@ -157,27 +156,27 @@ TEST_F(utPLYImportExport, pointcloudTest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *test_file =
|
static const char *test_file =
|
||||||
"ply\n"
|
"ply\n"
|
||||||
"format ascii 1.0\n"
|
"format ascii 1.0\n"
|
||||||
"element vertex 4\n"
|
"element vertex 4\n"
|
||||||
"property float x\n"
|
"property float x\n"
|
||||||
"property float y\n"
|
"property float y\n"
|
||||||
"property float z\n"
|
"property float z\n"
|
||||||
"property uchar red\n"
|
"property uchar red\n"
|
||||||
"property uchar green\n"
|
"property uchar green\n"
|
||||||
"property uchar blue\n"
|
"property uchar blue\n"
|
||||||
"property float nx\n"
|
"property float nx\n"
|
||||||
"property float ny\n"
|
"property float ny\n"
|
||||||
"property float nz\n"
|
"property float nz\n"
|
||||||
"end_header\n"
|
"end_header\n"
|
||||||
"0.0 0.0 0.0 255 255 255 0.0 1.0 0.0\n"
|
"0.0 0.0 0.0 255 255 255 0.0 1.0 0.0\n"
|
||||||
"0.0 0.0 1.0 255 0 255 0.0 0.0 1.0\n"
|
"0.0 0.0 1.0 255 0 255 0.0 0.0 1.0\n"
|
||||||
"0.0 1.0 0.0 255 255 0 1.0 0.0 0.0\n"
|
"0.0 1.0 0.0 255 255 0 1.0 0.0 0.0\n"
|
||||||
"0.0 1.0 1.0 0 255 255 1.0 1.0 0.0\n";
|
"0.0 1.0 1.0 0 255 255 1.0 1.0 0.0\n";
|
||||||
|
|
||||||
TEST_F( utPLYImportExport, parseErrorTest ) {
|
TEST_F(utPLYImportExport, parseErrorTest) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
//Could not use aiProcess_ValidateDataStructure since it's missing faces.
|
//Could not use aiProcess_ValidateDataStructure since it's missing faces.
|
||||||
const aiScene *scene = importer.ReadFileFromMemory( test_file, strlen( test_file ), 0);
|
const aiScene *scene = importer.ReadFileFromMemory(test_file, strlen(test_file), 0);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,19 +40,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "PostProcessing/PretransformVertices.h"
|
#include "PostProcessing/PretransformVertices.h"
|
||||||
|
#include <assimp/scene.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:
|
||||||
PretransformVerticesTest()
|
PretransformVerticesTest() :
|
||||||
: Test()
|
Test(), mScene(nullptr), mProcess(nullptr) {
|
||||||
, mScene(nullptr)
|
|
||||||
, mProcess(nullptr) {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,20 +63,20 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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) {
|
||||||
|
@ -96,35 +91,35 @@ void PretransformVerticesTest::SetUp() {
|
||||||
mScene = new aiScene();
|
mScene = new aiScene();
|
||||||
|
|
||||||
// add 5 empty materials
|
// add 5 empty materials
|
||||||
mScene->mMaterials = new aiMaterial*[mScene->mNumMaterials = 5];
|
mScene->mMaterials = new aiMaterial *[mScene->mNumMaterials = 5];
|
||||||
for (unsigned int i = 0; i < 5;++i) {
|
for (unsigned int i = 0; i < 5; ++i) {
|
||||||
mScene->mMaterials[i] = new aiMaterial();
|
mScene->mMaterials[i] = new aiMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
// add 25 test meshes
|
// add 25 test meshes
|
||||||
mScene->mMeshes = new aiMesh*[mScene->mNumMeshes = 25];
|
mScene->mMeshes = new aiMesh *[mScene->mNumMeshes = 25];
|
||||||
for ( unsigned int i = 0; i < 25; ++i) {
|
for (unsigned int i = 0; i < 25; ++i) {
|
||||||
aiMesh* mesh = mScene->mMeshes[ i ] = new aiMesh();
|
aiMesh *mesh = mScene->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];
|
||||||
for ( unsigned int normalIdx=0; normalIdx<mesh->mNumVertices; ++normalIdx ) {
|
for (unsigned int normalIdx = 0; normalIdx < mesh->mNumVertices; ++normalIdx) {
|
||||||
mesh->mNormals[ normalIdx ].x = 1.0f;
|
mesh->mNormals[normalIdx].x = 1.0f;
|
||||||
mesh->mNormals[ normalIdx ].y = 1.0f;
|
mesh->mNormals[normalIdx].y = 1.0f;
|
||||||
mesh->mNormals[ normalIdx ].z = 1.0f;
|
mesh->mNormals[normalIdx].z = 1.0f;
|
||||||
mesh->mNormals[ normalIdx ].Normalize();
|
mesh->mNormals[normalIdx].Normalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -44,8 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -53,11 +51,11 @@ class utQ3DImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/Q3D/earth.q3o", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Q3D/earth.q3o", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(utQ3DImportExport, importTest) {
|
TEST_F(utQ3DImportExport, importTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -44,54 +42,50 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <assimp/RemoveComments.h>
|
#include <assimp/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";
|
|
||||||
|
|
||||||
const size_t len( ::strlen( szTest ) + 1 );
|
const size_t len(::strlen(szTest) + 1);
|
||||||
char* szTest2 = new char[ len ];
|
char *szTest2 = new char[len];
|
||||||
::strncpy( szTest2, szTest, len );
|
::strncpy(szTest2, szTest, len);
|
||||||
|
|
||||||
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 */ */";
|
||||||
|
|
||||||
const size_t len( ::strlen( szTest ) + 1 );
|
const size_t len(::strlen(szTest) + 1);
|
||||||
char* szTest2 = new char[ len ];
|
char *szTest2 = new char[len];
|
||||||
::strncpy( szTest2, szTest, len );
|
::strncpy(szTest2, szTest, len);
|
||||||
|
|
||||||
CommentRemover::RemoveMultiLineComments("/*","*/",szTest2,' ');
|
CommentRemover::RemoveMultiLineComments("/*", "*/", szTest2, ' ');
|
||||||
EXPECT_STREQ(szTestResult, szTest2);
|
EXPECT_STREQ(szTestResult, szTest2);
|
||||||
|
|
||||||
delete[] szTest2;
|
delete[] szTest2;
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,9 +40,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "PostProcessing/RemoveVCProcess.h"
|
|
||||||
#include "Material/MaterialSystem.h"
|
#include "Material/MaterialSystem.h"
|
||||||
|
#include "PostProcessing/RemoveVCProcess.h"
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
@ -55,19 +53,18 @@ public:
|
||||||
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();
|
||||||
|
|
||||||
|
@ -82,23 +79,23 @@ void RemoveVCProcessTest::SetUp()
|
||||||
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();
|
||||||
|
|
||||||
|
@ -107,19 +104,17 @@ void RemoveVCProcessTest::SetUp()
|
||||||
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_EQ( 0, check[0] );
|
EXPECT_EQ(0, check[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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);
|
||||||
|
|
||||||
|
@ -129,8 +124,7 @@ TEST_F(RemoveVCProcessTest, testMeshRemove)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testAnimRemove)
|
TEST_F(RemoveVCProcessTest, testAnimRemove) {
|
||||||
{
|
|
||||||
piProcess->SetDeleteFlags(aiComponent_ANIMATIONS);
|
piProcess->SetDeleteFlags(aiComponent_ANIMATIONS);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
|
@ -140,21 +134,19 @@ TEST_F(RemoveVCProcessTest, testAnimRemove)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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);
|
||||||
|
|
||||||
|
@ -164,8 +156,7 @@ TEST_F(RemoveVCProcessTest, testTextureRemove)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testCameraRemove)
|
TEST_F(RemoveVCProcessTest, testCameraRemove) {
|
||||||
{
|
|
||||||
piProcess->SetDeleteFlags(aiComponent_CAMERAS);
|
piProcess->SetDeleteFlags(aiComponent_CAMERAS);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
|
@ -175,8 +166,7 @@ TEST_F(RemoveVCProcessTest, testCameraRemove)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(RemoveVCProcessTest, testLightRemove)
|
TEST_F(RemoveVCProcessTest, testLightRemove) {
|
||||||
{
|
|
||||||
piProcess->SetDeleteFlags(aiComponent_LIGHTS);
|
piProcess->SetDeleteFlags(aiComponent_LIGHTS);
|
||||||
piProcess->Execute(pScene);
|
piProcess->Execute(pScene);
|
||||||
|
|
||||||
|
@ -186,37 +176,34 @@ TEST_F(RemoveVCProcessTest, testLightRemove)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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);
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,9 +40,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "PostProcessing/RemoveRedundantMaterials.h"
|
|
||||||
#include "Material/MaterialSystem.h"
|
#include "Material/MaterialSystem.h"
|
||||||
|
#include "PostProcessing/RemoveRedundantMaterials.h"
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
@ -55,19 +53,18 @@ public:
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RemoveRedundantMatsProcess* piProcess;
|
RemoveRedundantMatsProcess *piProcess;
|
||||||
aiScene* pcScene1;
|
aiScene *pcScene1;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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);
|
||||||
|
@ -75,42 +72,40 @@ aiMaterial* getUniqueMaterial1()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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();
|
||||||
|
@ -118,8 +113,8 @@ void RemoveRedundantMatsTest::SetUp()
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
@ -130,57 +125,53 @@ void RemoveRedundantMatsTest::SetUp()
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,8 +38,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "PostProcessing/RemoveVCProcess.h"
|
#include "PostProcessing/RemoveVCProcess.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/mesh.h>
|
#include <assimp/mesh.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
@ -52,27 +50,27 @@ class utRevmoveVCProcess : public ::testing::Test {
|
||||||
// empty
|
// empty
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utRevmoveVCProcess, createTest ) {
|
TEST_F(utRevmoveVCProcess, createTest) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
try {
|
try {
|
||||||
RemoveVCProcess *process = new RemoveVCProcess;
|
RemoveVCProcess *process = new RemoveVCProcess;
|
||||||
delete process;
|
delete process;
|
||||||
} catch ( ... ) {
|
} catch (...) {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
EXPECT_TRUE( ok );
|
EXPECT_TRUE(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utRevmoveVCProcess, issue1266_ProcessMeshTest_NoCrash ) {
|
TEST_F(utRevmoveVCProcess, issue1266_ProcessMeshTest_NoCrash) {
|
||||||
aiScene *scene = new aiScene;
|
aiScene *scene = new aiScene;
|
||||||
scene->mNumMeshes = 1;
|
scene->mNumMeshes = 1;
|
||||||
scene->mMeshes = new aiMesh*[ 1 ];
|
scene->mMeshes = new aiMesh *[1];
|
||||||
|
|
||||||
aiMesh *mesh = new aiMesh;
|
aiMesh *mesh = new aiMesh;
|
||||||
mesh->mNumVertices = 1;
|
mesh->mNumVertices = 1;
|
||||||
mesh->mColors[ 0 ] = new aiColor4D[ 2 ];
|
mesh->mColors[0] = new aiColor4D[2];
|
||||||
scene->mMeshes[ 0 ] = mesh;
|
scene->mMeshes[0] = mesh;
|
||||||
std::unique_ptr<RemoveVCProcess> process(new RemoveVCProcess);
|
std::unique_ptr<RemoveVCProcess> process(new RemoveVCProcess);
|
||||||
process->Execute( scene );
|
process->Execute(scene);
|
||||||
delete scene;
|
delete scene;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -44,8 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "SIB/SIBImporter.h"
|
#include "SIB/SIBImporter.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
|
||||||
|
@ -55,21 +53,21 @@ class utSIBImporter : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SIB/heffalump.sib", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/SIB/heffalump.sib", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utSIBImporter, createTest ) {
|
TEST_F(utSIBImporter, createTest) {
|
||||||
bool ok( true );
|
bool ok(true);
|
||||||
try {
|
try {
|
||||||
SIBImporter myImporter;
|
SIBImporter myImporter;
|
||||||
} catch ( ... ) {
|
} catch (...) {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
EXPECT_TRUE( ok );
|
EXPECT_TRUE(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utSIBImporter, importTest ) {
|
TEST_F(utSIBImporter, importTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,10 +40,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include "SMD/SMDLoader.h"
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SMD/SMDLoader.h"
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace ::Assimp;
|
using namespace ::Assimp;
|
||||||
|
|
||||||
|
@ -53,28 +51,27 @@ class utSMDImporter : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/triangle.smd", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/SMD/triangle.smd", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utSMDImporter, createTest ) {
|
TEST_F(utSMDImporter, createTest) {
|
||||||
bool ok( true );
|
bool ok(true);
|
||||||
try {
|
try {
|
||||||
SMDImporter myImporter;
|
SMDImporter myImporter;
|
||||||
}
|
} catch (...) {
|
||||||
catch ( ... ) {
|
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
EXPECT_TRUE( ok );
|
EXPECT_TRUE(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utSMDImporter, importTest ) {
|
TEST_F(utSMDImporter, importTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utSMDImporter, issue_899_Texture_garbage_at_end_of_string_Test ) {
|
TEST_F(utSMDImporter, issue_899_Texture_garbage_at_end_of_string_Test) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/holy_grailref.smd", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/SMD/holy_grailref.smd", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,14 +39,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/Exporter.hpp>
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -58,25 +56,24 @@ class utSTLImporterExporter : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utSTLImporterExporter, importSTLFromFileTest ) {
|
TEST_F(utSTLImporterExporter, importSTLFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F(utSTLImporterExporter, test_multiple) {
|
TEST_F(utSTLImporterExporter, test_multiple) {
|
||||||
// import same file twice, each with its own importer
|
// import same file twice, each with its own importer
|
||||||
// must work both times and not crash
|
// must work both times and not crash
|
||||||
Assimp::Importer importer1;
|
Assimp::Importer importer1;
|
||||||
const aiScene *scene1 = importer1.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure );
|
const aiScene *scene1 = importer1.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene1);
|
EXPECT_NE(nullptr, scene1);
|
||||||
|
|
||||||
Assimp::Importer importer2;
|
Assimp::Importer importer2;
|
||||||
const aiScene *scene2 = importer2.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure );
|
const aiScene *scene2 = importer2.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene2);
|
EXPECT_NE(nullptr, scene2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,10 +84,10 @@ TEST_F(utSTLImporterExporter, importSTLformatdetection) {
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utSTLImporterExporter, test_with_two_solids ) {
|
TEST_F(utSTLImporterExporter, test_with_two_solids) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_two_solids.stl", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_two_solids.stl", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utSTLImporterExporter, test_with_empty_solid) {
|
TEST_F(utSTLImporterExporter, test_with_empty_solid) {
|
||||||
|
@ -110,7 +107,7 @@ TEST_F(utSTLImporterExporter, exporterTest) {
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure);
|
||||||
|
|
||||||
Assimp::Exporter mAiExporter;
|
Assimp::Exporter mAiExporter;
|
||||||
mAiExporter.Export( scene, "stl", "spiderExport.stl" );
|
mAiExporter.Export(scene, "stl", "spiderExport.stl");
|
||||||
|
|
||||||
const aiScene *scene2 = importer.ReadFile("spiderExport.stl", aiProcess_ValidateDataStructure);
|
const aiScene *scene2 = importer.ReadFile("spiderExport.stl", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene2);
|
EXPECT_NE(nullptr, scene2);
|
||||||
|
@ -133,11 +130,11 @@ TEST_F(utSTLImporterExporter, test_export_pointclouds) {
|
||||||
aiScene scene;
|
aiScene scene;
|
||||||
scene.mRootNode = new aiNode();
|
scene.mRootNode = new aiNode();
|
||||||
|
|
||||||
scene.mMeshes = new aiMesh*[1];
|
scene.mMeshes = new aiMesh *[1];
|
||||||
scene.mMeshes[0] = nullptr;
|
scene.mMeshes[0] = nullptr;
|
||||||
scene.mNumMeshes = 1;
|
scene.mNumMeshes = 1;
|
||||||
|
|
||||||
scene.mMaterials = new aiMaterial*[1];
|
scene.mMaterials = new aiMaterial *[1];
|
||||||
scene.mMaterials[0] = nullptr;
|
scene.mMaterials[0] = nullptr;
|
||||||
scene.mNumMaterials = 1;
|
scene.mNumMaterials = 1;
|
||||||
|
|
||||||
|
@ -155,7 +152,7 @@ TEST_F(utSTLImporterExporter, test_export_pointclouds) {
|
||||||
size_t numValidPoints = points.size();
|
size_t numValidPoints = points.size();
|
||||||
|
|
||||||
pMesh->mVertices = new aiVector3D[numValidPoints];
|
pMesh->mVertices = new aiVector3D[numValidPoints];
|
||||||
pMesh->mNumVertices = static_cast<unsigned int>( numValidPoints );
|
pMesh->mNumVertices = static_cast<unsigned int>(numValidPoints);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (XYZ &p : points) {
|
for (XYZ &p : points) {
|
||||||
|
@ -166,7 +163,7 @@ TEST_F(utSTLImporterExporter, test_export_pointclouds) {
|
||||||
Assimp::Exporter mAiExporter;
|
Assimp::Exporter mAiExporter;
|
||||||
ExportProperties *properties = new ExportProperties;
|
ExportProperties *properties = new ExportProperties;
|
||||||
properties->SetPropertyBool(AI_CONFIG_EXPORT_POINT_CLOUDS, true);
|
properties->SetPropertyBool(AI_CONFIG_EXPORT_POINT_CLOUDS, true);
|
||||||
mAiExporter.Export(&scene, "stl", "testExport.stl", 0, properties );
|
mAiExporter.Export(&scene, "stl", "testExport.stl", 0, properties);
|
||||||
|
|
||||||
delete properties;
|
delete properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,9 +38,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "PostProcessing/ScaleProcess.h"
|
#include "PostProcessing/ScaleProcess.h"
|
||||||
#include "TestModelFactory.h"
|
#include "TestModelFactory.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace UnitTest {
|
namespace UnitTest {
|
||||||
|
@ -51,22 +49,22 @@ class utScaleProcess : public ::testing::Test {
|
||||||
// empty
|
// empty
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utScaleProcess, createTest ) {
|
TEST_F(utScaleProcess, createTest) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
try {
|
try {
|
||||||
ScaleProcess process;
|
ScaleProcess process;
|
||||||
} catch ( ... ) {
|
} catch (...) {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
EXPECT_TRUE( ok );
|
EXPECT_TRUE(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utScaleProcess, accessScaleTest ) {
|
TEST_F(utScaleProcess, accessScaleTest) {
|
||||||
ScaleProcess process;
|
ScaleProcess process;
|
||||||
EXPECT_FLOAT_EQ( AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT, process.getScale() );
|
EXPECT_FLOAT_EQ(AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT, process.getScale());
|
||||||
|
|
||||||
process.setScale( 2.0f );
|
process.setScale(2.0f);
|
||||||
EXPECT_FLOAT_EQ( 2.0f, process.getScale() );
|
EXPECT_FLOAT_EQ(2.0f, process.getScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace UnitTest
|
} // Namespace UnitTest
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -51,29 +49,29 @@ class utSceneCombiner : public ::testing::Test {
|
||||||
// empty
|
// empty
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utSceneCombiner, MergeMeshes_ValidNames_Test ) {
|
TEST_F(utSceneCombiner, MergeMeshes_ValidNames_Test) {
|
||||||
std::vector<aiMesh*> merge_list;
|
std::vector<aiMesh *> merge_list;
|
||||||
aiMesh *mesh1 = new aiMesh;
|
aiMesh *mesh1 = new aiMesh;
|
||||||
mesh1->mName.Set( "mesh_1" );
|
mesh1->mName.Set("mesh_1");
|
||||||
merge_list.push_back( mesh1 );
|
merge_list.push_back(mesh1);
|
||||||
|
|
||||||
aiMesh *mesh2 = new aiMesh;
|
aiMesh *mesh2 = new aiMesh;
|
||||||
mesh2->mName.Set( "mesh_2" );
|
mesh2->mName.Set("mesh_2");
|
||||||
merge_list.push_back( mesh2 );
|
merge_list.push_back(mesh2);
|
||||||
|
|
||||||
aiMesh *mesh3 = new aiMesh;
|
aiMesh *mesh3 = new aiMesh;
|
||||||
mesh3->mName.Set( "mesh_3" );
|
mesh3->mName.Set("mesh_3");
|
||||||
merge_list.push_back( mesh3 );
|
merge_list.push_back(mesh3);
|
||||||
|
|
||||||
std::unique_ptr<aiMesh> out;
|
std::unique_ptr<aiMesh> out;
|
||||||
aiMesh* ptr = nullptr;
|
aiMesh *ptr = nullptr;
|
||||||
SceneCombiner::MergeMeshes( &ptr, 0, merge_list.begin(), merge_list.end() );
|
SceneCombiner::MergeMeshes(&ptr, 0, merge_list.begin(), merge_list.end());
|
||||||
out.reset(ptr);
|
out.reset(ptr);
|
||||||
std::string outName = out->mName.C_Str();
|
std::string outName = out->mName.C_Str();
|
||||||
EXPECT_EQ( "mesh_1.mesh_2.mesh_3", outName );
|
EXPECT_EQ("mesh_1.mesh_2.mesh_3", outName);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utSceneCombiner, CopySceneWithNullptr_AI_NO_EXCEPTion ) {
|
TEST_F(utSceneCombiner, CopySceneWithNullptr_AI_NO_EXCEPTion) {
|
||||||
EXPECT_NO_THROW( SceneCombiner::CopyScene( nullptr, nullptr ) );
|
EXPECT_NO_THROW(SceneCombiner::CopyScene(nullptr, nullptr));
|
||||||
EXPECT_NO_THROW( SceneCombiner::CopySceneFlat( nullptr, nullptr ) );
|
EXPECT_NO_THROW(SceneCombiner::CopySceneFlat(nullptr, nullptr));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,20 +40,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include "Common/ScenePreprocessor.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 "Common/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:
|
||||||
ScenePreprocessorTest()
|
ScenePreprocessorTest() :
|
||||||
: Test()
|
Test(), mScenePreprocessor(nullptr), mScene(nullptr) {
|
||||||
, mScenePreprocessor(nullptr)
|
|
||||||
, mScene(nullptr) {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +60,9 @@ protected:
|
||||||
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) { mScenePreprocessor->ProcessAnimation(anim); }
|
void ProcessAnimation(aiAnimation *anim) { mScenePreprocessor->ProcessAnimation(anim); }
|
||||||
void ProcessMesh(aiMesh* mesh) { mScenePreprocessor->ProcessMesh(mesh); }
|
void ProcessMesh(aiMesh *mesh) { mScenePreprocessor->ProcessMesh(mesh); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScenePreprocessor *mScenePreprocessor;
|
ScenePreprocessor *mScenePreprocessor;
|
||||||
|
@ -97,9 +93,9 @@ void ScenePreprocessorTest::TearDown() {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
mScenePreprocessor->ProcessMesh(p);
|
mScenePreprocessor->ProcessMesh(p);
|
||||||
|
@ -110,7 +106,7 @@ void ScenePreprocessorTest::CheckIfOnly(aiMesh* p, unsigned int num, unsigned in
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// 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];
|
||||||
|
|
||||||
|
@ -118,26 +114,26 @@ TEST_F(ScenePreprocessorTest, testMeshPreprocessingPos) {
|
||||||
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;
|
||||||
|
@ -146,24 +142,24 @@ TEST_F(ScenePreprocessorTest, testMeshPreprocessingPos) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
@ -171,14 +167,14 @@ aiAnimation* MakeDummyAnimation() {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
@ -189,14 +185,13 @@ TEST_F(ScenePreprocessorTest, testAnimationPreprocessingPos) {
|
||||||
|
|
||||||
// ... 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,20 +40,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "Common/ScenePreprocessor.h"
|
#include "Common/ScenePreprocessor.h"
|
||||||
#include "PostProcessing/SortByPTypeProcess.h"
|
#include "PostProcessing/SortByPTypeProcess.h"
|
||||||
|
#include <assimp/scene.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:
|
||||||
SortByPTypeProcessTest()
|
SortByPTypeProcessTest() :
|
||||||
: Test()
|
Test(), mProcess1(nullptr), mScene(nullptr) {
|
||||||
, mProcess1(nullptr)
|
|
||||||
, mScene(nullptr) {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,23 +59,23 @@ protected:
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SortByPTypeProcess* mProcess1;
|
SortByPTypeProcess *mProcess1;
|
||||||
aiScene* mScene;
|
aiScene *mScene;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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] = {
|
||||||
|
@ -91,8 +86,8 @@ static unsigned int result[10] = {
|
||||||
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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -102,22 +97,22 @@ void SortByPTypeProcessTest::SetUp() {
|
||||||
mScene = new aiScene();
|
mScene = new aiScene();
|
||||||
|
|
||||||
mScene->mNumMeshes = 10;
|
mScene->mNumMeshes = 10;
|
||||||
mScene->mMeshes = new aiMesh*[10];
|
mScene->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 = mScene->mMeshes[i] = new aiMesh();
|
aiMesh *mesh = mScene->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;
|
||||||
|
@ -130,22 +125,22 @@ void SortByPTypeProcessTest::SetUp() {
|
||||||
}
|
}
|
||||||
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];
|
||||||
|
@ -155,13 +150,13 @@ void SortByPTypeProcessTest::SetUp() {
|
||||||
|
|
||||||
mScene->mRootNode = new aiNode();
|
mScene->mRootNode = new aiNode();
|
||||||
mScene->mRootNode->mNumChildren = 5;
|
mScene->mRootNode->mNumChildren = 5;
|
||||||
mScene->mRootNode->mChildren = new aiNode*[5];
|
mScene->mRootNode->mChildren = new aiNode *[5];
|
||||||
for (unsigned int i = 0; i< 5;++i ) {
|
for (unsigned int i = 0; i < 5; ++i) {
|
||||||
aiNode* node = mScene->mRootNode->mChildren[i] = new aiNode();
|
aiNode *node = mScene->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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,22 +170,22 @@ void SortByPTypeProcessTest::TearDown() {
|
||||||
TEST_F(SortByPTypeProcessTest, SortByPTypeStep) {
|
TEST_F(SortByPTypeProcessTest, SortByPTypeStep) {
|
||||||
ScenePreprocessor s(mScene);
|
ScenePreprocessor s(mScene);
|
||||||
s.ProcessScene();
|
s.ProcessScene();
|
||||||
for (unsigned int m = 0; m< 10;++m)
|
for (unsigned int m = 0; m < 10; ++m)
|
||||||
EXPECT_EQ(result[m], mScene->mMeshes[m]->mPrimitiveTypes);
|
EXPECT_EQ(result[m], mScene->mMeshes[m]->mPrimitiveTypes);
|
||||||
|
|
||||||
mProcess1->Execute(mScene);
|
mProcess1->Execute(mScene);
|
||||||
|
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
for (unsigned int m = 0,real = 0; m< 10;++m) {
|
for (unsigned int m = 0, real = 0; m < 10; ++m) {
|
||||||
for (unsigned int n = 0; n < 4;++n) {
|
for (unsigned int n = 0; n < 4; ++n) {
|
||||||
idx = num[m][n];
|
idx = num[m][n];
|
||||||
if (idx) {
|
if (idx) {
|
||||||
EXPECT_TRUE(real < mScene->mNumMeshes);
|
EXPECT_TRUE(real < mScene->mNumMeshes);
|
||||||
|
|
||||||
aiMesh* mesh = mScene->mMeshes[real];
|
aiMesh *mesh = mScene->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);
|
||||||
|
@ -198,9 +193,9 @@ TEST_F(SortByPTypeProcessTest, SortByPTypeStep) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,8 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "PostProcessing/SplitLargeMeshes.h"
|
#include "PostProcessing/SplitLargeMeshes.h"
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
@ -54,64 +52,56 @@ public:
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
SplitLargeMeshesProcess_Triangle *piProcessTriangle;
|
||||||
SplitLargeMeshesProcess_Triangle* piProcessTriangle;
|
SplitLargeMeshesProcess_Vertex *piProcessVertex;
|
||||||
SplitLargeMeshesProcess_Vertex* piProcessVertex;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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;
|
|
||||||
|
|
||||||
aiMesh *pcMesh1 = new aiMesh();
|
aiMesh *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;
|
|
||||||
for (unsigned int i = 0; i < pcMesh1->mNumFaces;++i)
|
|
||||||
{
|
|
||||||
aiFace& face = pcMesh1->mFaces[i];
|
|
||||||
face.mNumIndices = 3;
|
|
||||||
face.mIndices = new unsigned int[3];
|
|
||||||
face.mIndices[0] = qq++;
|
|
||||||
face.mIndices[1] = qq++;
|
|
||||||
face.mIndices[2] = qq++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
unsigned int qq = 0;
|
||||||
|
for (unsigned int i = 0; i < pcMesh1->mNumFaces; ++i) {
|
||||||
|
aiFace &face = pcMesh1->mFaces[i];
|
||||||
|
face.mNumIndices = 3;
|
||||||
|
face.mIndices = new unsigned int[3];
|
||||||
|
face.mIndices[0] = qq++;
|
||||||
|
face.mIndices[1] = qq++;
|
||||||
|
face.mIndices[2] = qq++;
|
||||||
|
}
|
||||||
|
|
||||||
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(),
|
||||||
iter != end; ++iter)
|
end = avOut.end();
|
||||||
{
|
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);
|
||||||
|
@ -123,9 +113,8 @@ TEST_F(SplitLargeMeshesTest, testVertexSplit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(SplitLargeMeshesTest, testTriangleSplit)
|
TEST_F(SplitLargeMeshesTest, testTriangleSplit) {
|
||||||
{
|
std::vector<std::pair<aiMesh *, unsigned int>> avOut;
|
||||||
std::vector< std::pair<aiMesh*, unsigned int> > avOut;
|
|
||||||
|
|
||||||
// generate many, many faces with randomized indices for
|
// generate many, many faces with randomized indices for
|
||||||
// the second mesh
|
// the second mesh
|
||||||
|
@ -137,9 +126,8 @@ TEST_F(SplitLargeMeshesTest, testTriangleSplit)
|
||||||
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);
|
||||||
|
@ -149,13 +137,13 @@ TEST_F(SplitLargeMeshesTest, testTriangleSplit)
|
||||||
|
|
||||||
// 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(),
|
||||||
iter != end; ++iter)
|
end = avOut.end();
|
||||||
{
|
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);
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -44,7 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "PostProcessing/TriangulateProcess.h"
|
#include "PostProcessing/TriangulateProcess.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -54,8 +53,8 @@ public:
|
||||||
virtual void TearDown();
|
virtual void TearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
aiMesh* pcMesh;
|
aiMesh *pcMesh;
|
||||||
TriangulateProcess* piProcess;
|
TriangulateProcess *piProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
void TriangulateProcessTest::SetUp() {
|
void TriangulateProcessTest::SetUp() {
|
||||||
|
@ -67,27 +66,27 @@ void TriangulateProcessTest::SetUp() {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,17 +99,17 @@ void TriangulateProcessTest::TearDown() {
|
||||||
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& curFace = pcMesh->mFaces[m];
|
aiFace &curFace = pcMesh->mFaces[m];
|
||||||
EXPECT_EQ(3U, curFace.mNumIndices);
|
EXPECT_EQ(3U, curFace.mNumIndices);
|
||||||
|
|
||||||
for (unsigned int qqq = 0; qqq < curFace.mNumIndices; ++qqq) {
|
for (unsigned int qqq = 0; qqq < curFace.mNumIndices; ++qqq) {
|
||||||
|
@ -121,14 +120,14 @@ TEST_F(TriangulateProcessTest, testTriangulation) {
|
||||||
EXPECT_TRUE(*it);
|
EXPECT_TRUE(*it);
|
||||||
}
|
}
|
||||||
--m;
|
--m;
|
||||||
idx+=q;
|
idx += q;
|
||||||
if ( ++q == 10 ) {
|
if (++q == 10) {
|
||||||
q = 4;
|
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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,4 +136,3 @@ TEST_F(TriangulateProcessTest, testTriangulation) {
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -48,23 +47,23 @@ class utVector3 : public ::testing::Test {
|
||||||
|
|
||||||
TEST_F(utVector3, CreationTest) {
|
TEST_F(utVector3, CreationTest) {
|
||||||
aiVector3D v0;
|
aiVector3D v0;
|
||||||
aiVector3D v1( 1.0f, 2.0f, 3.0f );
|
aiVector3D v1(1.0f, 2.0f, 3.0f);
|
||||||
EXPECT_FLOAT_EQ (1.0f, v1[ 0 ] );
|
EXPECT_FLOAT_EQ(1.0f, v1[0]);
|
||||||
EXPECT_FLOAT_EQ( 2.0f, v1[ 1 ] );
|
EXPECT_FLOAT_EQ(2.0f, v1[1]);
|
||||||
EXPECT_FLOAT_EQ( 3.0f, v1[ 2 ] );
|
EXPECT_FLOAT_EQ(3.0f, v1[2]);
|
||||||
aiVector3D v2( 1 );
|
aiVector3D v2(1);
|
||||||
EXPECT_FLOAT_EQ( 1.0f, v2[ 0 ] );
|
EXPECT_FLOAT_EQ(1.0f, v2[0]);
|
||||||
EXPECT_FLOAT_EQ( 1.0f, v2[ 1 ] );
|
EXPECT_FLOAT_EQ(1.0f, v2[1]);
|
||||||
EXPECT_FLOAT_EQ( 1.0f, v2[ 2 ] );
|
EXPECT_FLOAT_EQ(1.0f, v2[2]);
|
||||||
aiVector3D v3( v1 );
|
aiVector3D v3(v1);
|
||||||
EXPECT_FLOAT_EQ( v1[ 0 ], v3[ 0 ] );
|
EXPECT_FLOAT_EQ(v1[0], v3[0]);
|
||||||
EXPECT_FLOAT_EQ( v1[ 1 ], v3[ 1 ] );
|
EXPECT_FLOAT_EQ(v1[1], v3[1]);
|
||||||
EXPECT_FLOAT_EQ( v1[ 2 ], v3[ 2 ] );
|
EXPECT_FLOAT_EQ(v1[2], v3[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utVector3, BracketOpTest ) {
|
TEST_F(utVector3, BracketOpTest) {
|
||||||
aiVector3D v(1.0f, 2.0f, 3.0f);
|
aiVector3D v(1.0f, 2.0f, 3.0f);
|
||||||
EXPECT_FLOAT_EQ( 1.0f, v[ 0 ] );
|
EXPECT_FLOAT_EQ(1.0f, v[0]);
|
||||||
EXPECT_FLOAT_EQ( 2.0f, v[ 1 ] );
|
EXPECT_FLOAT_EQ(2.0f, v[1]);
|
||||||
EXPECT_FLOAT_EQ( 3.0f, v[ 2 ] );
|
EXPECT_FLOAT_EQ(3.0f, v[2]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -42,8 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/types.h>
|
|
||||||
#include <assimp/mesh.h>
|
#include <assimp/mesh.h>
|
||||||
|
#include <assimp/types.h>
|
||||||
|
|
||||||
#include "Common/VertexTriangleAdjacency.h"
|
#include "Common/VertexTriangleAdjacency.h"
|
||||||
|
|
||||||
|
@ -52,12 +50,11 @@ 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;
|
||||||
|
@ -67,27 +64,26 @@ TEST_F(VTAdjacencyTest, largeRandomDataSet)
|
||||||
|
|
||||||
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
|
||||||
// *******************************************************************************
|
// *******************************************************************************
|
||||||
|
@ -120,8 +116,7 @@ TEST_F(VTAdjacencyTest, smallDataSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
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;
|
||||||
|
@ -131,60 +126,53 @@ TEST_F(VTAdjacencyTest, unreferencedVerticesSet)
|
||||||
|
|
||||||
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])
|
||||||
else if (face.mIndices[1]) 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;
|
||||||
|
|
||||||
|
@ -198,18 +186,15 @@ void VTAdjacencyTest::checkMesh(const aiMesh& mesh)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 ...
|
||||||
|
@ -219,8 +204,7 @@ void VTAdjacencyTest::checkMesh(const aiMesh& mesh)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,12 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -54,11 +52,11 @@ class utX3DImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utX3DImportExport, importX3DFromFileTest ) {
|
TEST_F(utX3DImportExport, importX3DFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,12 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "SceneDiffer.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -54,84 +52,74 @@ class utXImporterExporter : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X/test.x", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test.x", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utXImporterExporter, importXFromFileTest ) {
|
TEST_F(utXImporterExporter, importXFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utXImporterExporter, heap_overflow_in_tokenizer ) {
|
TEST_F(utXImporterExporter, heap_overflow_in_tokenizer) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
EXPECT_NO_THROW( importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X/OV_GetNextToken", 0 ) );
|
EXPECT_NO_THROW(importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/OV_GetNextToken", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, importAnimTest) {
|
TEST(utXImporter, importAnimTest) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, importBCNEpileptic) {
|
TEST(utXImporter, importBCNEpileptic) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/BCN_Epileptic.X", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/BCN_Epileptic.X", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, importFromTrueSpaceBin32) {
|
TEST(utXImporter, importFromTrueSpaceBin32) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/fromtruespace_bin32.x", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/fromtruespace_bin32.x", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, import_kwxport_test_cubewithvcolors) {
|
TEST(utXImporter, import_kwxport_test_cubewithvcolors) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/kwxport_test_cubewithvcolors.x", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/kwxport_test_cubewithvcolors.x", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, importTestCubeBinary) {
|
TEST(utXImporter, importTestCubeBinary) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_binary.x", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_binary.x", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, importTestCubeCompressed) {
|
TEST(utXImporter, importTestCubeCompressed) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_compressed.x", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_compressed.x", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, importTestCubeText) {
|
TEST(utXImporter, importTestCubeText) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_text.x", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_text.x", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, importTestWuson) {
|
TEST(utXImporter, importTestWuson) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/Testwuson.X", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/Testwuson.X", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, TestFormatDetection) {
|
TEST(utXImporter, TestFormatDetection) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/TestFormatDetection", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/TestFormatDetection", aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(nullptr, scene);
|
ASSERT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(utXImporter, importDwarf) {
|
TEST(utXImporter, importDwarf) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/X/dwarf.x", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/X/dwarf.x", aiProcess_ValidateDataStructure);
|
||||||
|
|
|
@ -38,14 +38,14 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/commonMetaData.h>
|
||||||
#include <assimp/Exporter.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/commonMetaData.h>
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
@ -57,14 +57,14 @@ class utglTF2ImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( scene, nullptr );
|
EXPECT_NE(scene, nullptr);
|
||||||
if (!scene) {
|
if (!scene) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE( scene->HasMaterials() );
|
EXPECT_TRUE(scene->HasMaterials());
|
||||||
if (!scene->HasMaterials()) {
|
if (!scene->HasMaterials()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -72,19 +72,19 @@ public:
|
||||||
|
|
||||||
aiString path;
|
aiString path;
|
||||||
aiTextureMapMode modes[2];
|
aiTextureMapMode modes[2];
|
||||||
EXPECT_EQ( aiReturn_SUCCESS, material->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr,
|
EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr,
|
||||||
nullptr, nullptr, modes) );
|
nullptr, nullptr, modes));
|
||||||
EXPECT_STREQ( path.C_Str(), "CesiumLogoFlat.png" );
|
EXPECT_STREQ(path.C_Str(), "CesiumLogoFlat.png");
|
||||||
EXPECT_EQ( modes[0], aiTextureMapMode_Mirror );
|
EXPECT_EQ(modes[0], aiTextureMapMode_Mirror);
|
||||||
EXPECT_EQ( modes[1], aiTextureMapMode_Clamp );
|
EXPECT_EQ(modes[1], aiTextureMapMode_Clamp);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool binaryImporterTest() {
|
virtual bool binaryImporterTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/2CylinderEngine-glTF-Binary/2CylinderEngine.glb",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/2CylinderEngine-glTF-Binary/2CylinderEngine.glb",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,23 +92,22 @@ public:
|
||||||
virtual bool exporterTest() {
|
virtual bool exporterTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
Assimp::Exporter exporter;
|
Assimp::Exporter exporter;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
|
||||||
aiProcess_ValidateDataStructure );
|
aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "gltf2", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured_out.gltf" ) );
|
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "gltf2", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured_out.gltf"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utglTF2ImportExport, importglTF2FromFileTest ) {
|
TEST_F(utglTF2ImportExport, importglTF2FromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utglTF2ImportExport, importBinaryglTF2FromFileTest ) {
|
TEST_F(utglTF2ImportExport, importBinaryglTF2FromFileTest) {
|
||||||
EXPECT_TRUE( binaryImporterTest() );
|
EXPECT_TRUE(binaryImporterTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
@ -116,7 +115,7 @@ TEST_F(utglTF2ImportExport, importglTF2AndExportToOBJ) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
Assimp::Exporter exporter;
|
Assimp::Exporter exporter;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured_out.obj"));
|
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured_out.obj"));
|
||||||
}
|
}
|
||||||
|
@ -125,7 +124,7 @@ TEST_F(utglTF2ImportExport, importglTF2EmbeddedAndExportToOBJ) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
Assimp::Exporter exporter;
|
Assimp::Exporter exporter;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-Embedded/BoxTextured.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-Embedded/BoxTextured.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-Embedded/BoxTextured_out.obj"));
|
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-Embedded/BoxTextured_out.obj"));
|
||||||
}
|
}
|
||||||
|
@ -151,8 +150,8 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesWithoutIndices) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 8u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 8u);
|
||||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
|
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2u);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i*2u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i * 2u);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], i*2u + 1u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], i * 2u + 1u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +162,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesLoopWithoutIndices) {
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
||||||
|
|
||||||
std::array<unsigned int, 5> l1 = {{ 0u, 1u, 2u, 3u, 0u }};
|
std::array<unsigned int, 5> l1 = { { 0u, 1u, 2u, 3u, 0u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
|
||||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
|
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2u);
|
||||||
|
@ -194,13 +193,13 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStripWithoutIndices
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
||||||
std::array<unsigned int, 3> f1 = {{ 0u, 1u, 2u }};
|
std::array<unsigned int, 3> f1 = { { 0u, 1u, 2u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
|
||||||
for (unsigned int i = 0; i < 3; ++i) {
|
for (unsigned int i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<unsigned int, 3> f2 = {{ 2u, 1u, 3u }};
|
std::array<unsigned int, 3> f2 = { { 2u, 1u, 3u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||||
|
@ -214,13 +213,13 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFanWithoutIndices)
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
||||||
std::array<unsigned int, 3> f1 = {{ 0u, 1u, 2u }};
|
std::array<unsigned int, 3> f1 = { { 0u, 1u, 2u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<unsigned int, 3> f2 = {{ 0u, 2u, 3u }};
|
std::array<unsigned int, 3> f2 = { { 0u, 2u, 3u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||||
|
@ -234,13 +233,13 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesWithoutIndices) {
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 6u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 6u);
|
||||||
std::array<unsigned int, 3> f1 = {{ 0u, 1u, 2u }};
|
std::array<unsigned int, 3> f1 = { { 0u, 1u, 2u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<unsigned int, 3> f2 = {{ 3u, 4u, 5u }};
|
std::array<unsigned int, 3> f2 = { { 3u, 4u, 5u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||||
|
@ -265,10 +264,9 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) {
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
||||||
std::array<unsigned int, 5> l1 = {{ 0u, 3u, 2u, 1u, 0u }};
|
std::array<unsigned int, 5> l1 = { { 0u, 3u, 2u, 1u, 0u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
|
||||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
|
||||||
{
|
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]);
|
||||||
}
|
}
|
||||||
|
@ -280,12 +278,11 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) {
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
||||||
std::array<unsigned int, 5> l1 = {{ 0, 3u, 2u, 1u, 0u }};
|
std::array<unsigned int, 5> l1 = { { 0, 3u, 2u, 1u, 0u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
|
||||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
|
||||||
{
|
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i+1]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +292,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineStrip) {
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf", aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
||||||
std::array<unsigned int, 5> l1 = {{ 0u, 3u, 2u, 1u, 0u }};
|
std::array<unsigned int, 5> l1 = { { 0u, 3u, 2u, 1u, 0u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
|
||||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
|
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
||||||
|
@ -310,13 +307,13 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) {
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
||||||
std::array<unsigned int, 3> f1 = {{ 0u, 3u, 1u }};
|
std::array<unsigned int, 3> f1 = { { 0u, 3u, 1u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<unsigned int, 3> f2 = {{ 1u, 3u, 2u }};
|
std::array<unsigned int, 3> f2 = { { 1u, 3u, 2u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||||
|
@ -330,23 +327,23 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFan) {
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
|
||||||
std::array<unsigned int, 3> f1 = {{ 0u, 3u, 2u }};
|
std::array<unsigned int, 3> f1 = { { 0u, 3u, 2u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u );
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<unsigned int, 3> f2 = {{ 0u, 2u, 1u }};
|
std::array<unsigned int, 3> f2 = { { 0u, 2u, 1u } };
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u );
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> ReadFile(const char* name) {
|
std::vector<char> ReadFile(const char *name) {
|
||||||
std::vector<char> ret;
|
std::vector<char> ret;
|
||||||
|
|
||||||
FILE* p = ::fopen(name, "r");
|
FILE *p = ::fopen(name, "r");
|
||||||
if (nullptr == p) {
|
if (nullptr == p) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -372,24 +369,24 @@ TEST_F(utglTF2ImportExport, importglTF2FromMemory) {
|
||||||
EXPECT_EQ( nullptr, Scene );*/
|
EXPECT_EQ( nullptr, Scene );*/
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utglTF2ImportExport, bug_import_simple_skin ) {
|
TEST_F(utglTF2ImportExport, bug_import_simple_skin) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/simple_skin.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/simple_skin.gltf",
|
||||||
aiProcess_ValidateDataStructure );
|
aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utglTF2ImportExport, import_cameras) {
|
TEST_F(utglTF2ImportExport, import_cameras) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/cameras/Cameras.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/cameras/Cameras.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utglTF2ImportExport, incorrect_vertex_arrays) {
|
TEST_F(utglTF2ImportExport, incorrect_vertex_arrays) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/IncorrectVertexArrays/Cube.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/IncorrectVertexArrays/Cube.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 36u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 36u);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 12u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 12u);
|
||||||
|
@ -409,23 +406,23 @@ TEST_F(utglTF2ImportExport, incorrect_vertex_arrays) {
|
||||||
EXPECT_EQ(scene->mMeshes[7]->mNumFaces, 17u);
|
EXPECT_EQ(scene->mMeshes[7]->mNumFaces, 17u);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utglTF2ImportExport, texture_transform_test ) {
|
TEST_F(utglTF2ImportExport, texture_transform_test) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/textureTransform/TextureTransformTest.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/textureTransform/TextureTransformTest.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) {
|
TEST_F(utglTF2ImportExport, exportglTF2FromFileTest) {
|
||||||
EXPECT_TRUE( exporterTest() );
|
EXPECT_TRUE(exporterTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( utglTF2ImportExport, crash_in_anim_mesh_destructor ) {
|
TEST_F(utglTF2ImportExport, crash_in_anim_mesh_destructor) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Sample-Models/AnimatedMorphCube-glTF/AnimatedMorphCube.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Sample-Models/AnimatedMorphCube-glTF/AnimatedMorphCube.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE( nullptr, scene );
|
ASSERT_NE(nullptr, scene);
|
||||||
Assimp::Exporter exporter;
|
Assimp::Exporter exporter;
|
||||||
ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Sample-Models/AnimatedMorphCube-glTF/AnimatedMorphCube_out.glTF"));
|
ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Sample-Models/AnimatedMorphCube-glTF/AnimatedMorphCube_out.glTF"));
|
||||||
}
|
}
|
||||||
|
@ -433,7 +430,7 @@ TEST_F( utglTF2ImportExport, crash_in_anim_mesh_destructor ) {
|
||||||
TEST_F(utglTF2ImportExport, error_string_preserved) {
|
TEST_F(utglTF2ImportExport, error_string_preserved) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/MissingBin/BoxTextured.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/MissingBin/BoxTextured.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
ASSERT_EQ(nullptr, scene);
|
ASSERT_EQ(nullptr, scene);
|
||||||
std::string error = importer.GetErrorString();
|
std::string error = importer.GetErrorString();
|
||||||
ASSERT_NE(error.find("BoxTextured0.bin"), std::string::npos) << "Error string should contain an error about missing .bin file";
|
ASSERT_NE(error.find("BoxTextured0.bin"), std::string::npos) << "Error string should contain an error about missing .bin file";
|
||||||
|
@ -444,7 +441,7 @@ TEST_F(utglTF2ImportExport, error_string_preserved) {
|
||||||
TEST_F(utglTF2ImportExport, sceneMetadata) {
|
TEST_F(utglTF2ImportExport, sceneMetadata) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(scene, nullptr);
|
ASSERT_NE(scene, nullptr);
|
||||||
ASSERT_NE(scene->mMetaData, nullptr);
|
ASSERT_NE(scene->mMetaData, nullptr);
|
||||||
{
|
{
|
||||||
|
@ -470,7 +467,7 @@ TEST_F(utglTF2ImportExport, sceneMetadata) {
|
||||||
TEST_F(utglTF2ImportExport, texcoords) {
|
TEST_F(utglTF2ImportExport, texcoords) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTexcoords-glTF/boxTexcoords.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTexcoords-glTF/boxTexcoords.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
ASSERT_NE(scene, nullptr);
|
ASSERT_NE(scene, nullptr);
|
||||||
|
|
||||||
ASSERT_TRUE(scene->HasMaterials());
|
ASSERT_TRUE(scene->HasMaterials());
|
||||||
|
@ -479,7 +476,7 @@ TEST_F(utglTF2ImportExport, texcoords) {
|
||||||
aiString path;
|
aiString path;
|
||||||
aiTextureMapMode modes[2];
|
aiTextureMapMode modes[2];
|
||||||
EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr,
|
EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr,
|
||||||
nullptr, nullptr, modes));
|
nullptr, nullptr, modes));
|
||||||
EXPECT_STREQ(path.C_Str(), "texture.png");
|
EXPECT_STREQ(path.C_Str(), "texture.png");
|
||||||
|
|
||||||
int uvIndex = -1;
|
int uvIndex = -1;
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -40,14 +38,14 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "UnitTestPCH.h"
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/commonMetaData.h>
|
#include <assimp/commonMetaData.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -55,19 +53,19 @@ class utglTFImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
virtual bool importerTest() {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF/TwoBoxes/TwoBoxes.gltf", aiProcess_ValidateDataStructure );
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF/TwoBoxes/TwoBoxes.gltf", aiProcess_ValidateDataStructure);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F( utglTFImportExport, importglTFFromFileTest ) {
|
TEST_F(utglTFImportExport, importglTFFromFileTest) {
|
||||||
EXPECT_TRUE( importerTest() );
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utglTFImportExport, incorrect_vertex_arrays) {
|
TEST_F(utglTFImportExport, incorrect_vertex_arrays) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF/IncorrectVertexArrays/Cube_v1.gltf",
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF/IncorrectVertexArrays/Cube_v1.gltf",
|
||||||
aiProcess_ValidateDataStructure);
|
aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 36u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 36u);
|
||||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 12u);
|
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 12u);
|
||||||
|
|
Loading…
Reference in New Issue