2015-05-17 19:25:47 +00:00
|
|
|
/*
|
|
|
|
* ColladaCameraExporter.cpp
|
|
|
|
*
|
|
|
|
* Created on: May 17, 2015
|
|
|
|
* Author: wise
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "UnitTestPCH.h"
|
|
|
|
|
|
|
|
#include <assimp/cexport.h>
|
|
|
|
#include <assimp/Exporter.hpp>
|
|
|
|
#include <assimp/Importer.hpp>
|
|
|
|
#include <assimp/scene.h>
|
|
|
|
|
|
|
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
|
|
|
|
|
|
|
class ColladaExportCamera : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
ex = new Assimp::Exporter();
|
|
|
|
im = new Assimp::Importer();
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
}
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
virtual void TearDown()
|
|
|
|
{
|
|
|
|
delete ex;
|
|
|
|
delete im;
|
|
|
|
}
|
2015-05-17 19:25:47 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
Assimp::Exporter* ex;
|
|
|
|
Assimp::Importer* im;
|
2015-05-17 19:25:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
TEST_F(ColladaExportCamera, testExportCamera)
|
|
|
|
{
|
2015-05-19 04:26:05 +00:00
|
|
|
const char* file = "cameraExp.dae";
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-06-30 13:26:58 +00:00
|
|
|
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae",0);
|
2015-05-19 04:26:05 +00:00
|
|
|
ASSERT_TRUE(pTest!=NULL);
|
|
|
|
ASSERT_TRUE(pTest->HasCameras());
|
2015-05-17 19:25:47 +00:00
|
|
|
|
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
const aiScene* imported = im->ReadFile(file,0);
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
ASSERT_TRUE(imported!=NULL);
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
EXPECT_TRUE(imported->HasCameras());
|
|
|
|
EXPECT_EQ(pTest->mNumCameras,imported->mNumCameras);
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
for(size_t i=0; i< pTest->mNumCameras;i++){
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
const aiCamera *orig = pTest->mCameras[i];
|
|
|
|
const aiCamera *read = imported->mCameras[i];
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
EXPECT_TRUE(orig->mName==read->mName);
|
|
|
|
EXPECT_FLOAT_EQ(orig->mHorizontalFOV,read->mHorizontalFOV);
|
|
|
|
EXPECT_FLOAT_EQ(orig->mClipPlaneNear,read->mClipPlaneNear);
|
|
|
|
EXPECT_FLOAT_EQ(orig->mClipPlaneFar,read->mClipPlaneFar);
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-05-19 04:26:05 +00:00
|
|
|
EXPECT_FLOAT_EQ(orig->mPosition.x,read->mPosition.x);
|
|
|
|
EXPECT_FLOAT_EQ(orig->mPosition.y,read->mPosition.y);
|
|
|
|
EXPECT_FLOAT_EQ(orig->mPosition.z,read->mPosition.z);
|
|
|
|
}
|
2015-05-17 19:25:47 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|