FBX: add test case

pull/2410/head
kimkulling 2019-04-08 17:37:40 +02:00
parent 189bb2a233
commit cbd8b032e7
5 changed files with 528 additions and 27 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
ply
format ascii 1.0
comment Created by Open Asset Import Library - http://assimp.sf.net (v4.1.4208963464)
comment Created by Open Asset Import Library - http://assimp.sf.net (v4.1.412856994)
element vertex 8
property float x
property float y

View File

@ -52,18 +52,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class ColladaExportCamera : public ::testing::Test {
public:
virtual void SetUp()
{
void SetUp() override{
ex = new Assimp::Exporter();
im = new Assimp::Importer();
}
virtual void TearDown()
{
void TearDown() {
delete ex;
ex = nullptr;
delete im;
im = nullptr;
}
protected:
@ -71,16 +70,15 @@ protected:
Assimp::Importer* im;
};
TEST_F(ColladaExportCamera, testExportCamera)
{
TEST_F(ColladaExportCamera, testExportCamera) {
const char* file = "cameraExp.dae";
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest!=NULL);
ASSERT_NE( nullptr, pTest );
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 );
std::unique_ptr<float[]> origFOV( new float[ origNumCams ] );
std::unique_ptr<float[]> orifClipPlaneNear( new float[ origNumCams ] );
@ -89,7 +87,7 @@ TEST_F(ColladaExportCamera, testExportCamera)
std::unique_ptr<aiVector3D[]> pos( new aiVector3D[ origNumCams ] );
for (size_t i = 0; i < origNumCams; i++) {
const aiCamera *orig = pTest->mCameras[ i ];
ASSERT_TRUE( orig != nullptr );
ASSERT_NE(nullptr, orig );
origFOV[ i ] = orig->mHorizontalFOV;
orifClipPlaneNear[ i ] = orig->mClipPlaneNear;
@ -99,7 +97,7 @@ TEST_F(ColladaExportCamera, testExportCamera)
}
const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_TRUE(imported!=NULL);
ASSERT_NE(nullptr, imported );
EXPECT_TRUE( imported->HasCameras() );
EXPECT_EQ( origNumCams, imported->mNumCameras );
@ -119,5 +117,3 @@ TEST_F(ColladaExportCamera, testExportCamera)
}
#endif // ASSIMP_BUILD_NO_EXPORT

View File

@ -114,3 +114,18 @@ TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
scene->mMetaData->Get("UnitScaleFactor", factor);
EXPECT_DOUBLE_EQ(500.0, factor);
}
TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {
// see https://github.com/assimp/assimp/issues/1957
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/embedded_ascii/box.FBX", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(1, scene->mNumMaterials);
aiMaterial *mat = scene->mMaterials[0];
ASSERT_NE(nullptr, mat);
aiString path;
aiTextureMapMode modes[2];
EXPECT_EQ(aiReturn_SUCCESS, mat->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes));
}