2015-05-17 19:25:47 +00:00
|
|
|
/*
|
2015-12-02 13:54:29 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2019-01-30 08:41:39 +00:00
|
|
|
Copyright (c) 2006-2019, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2017-05-09 17:57:36 +00:00
|
|
|
|
2015-12-02 13:54:29 +00:00
|
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the following
|
|
|
|
conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the assimp team, nor the names of its
|
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
|
|
|
written permission of the assimp team.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-17 19:25:47 +00:00
|
|
|
#include "UnitTestPCH.h"
|
|
|
|
|
|
|
|
#include <assimp/cexport.h>
|
|
|
|
#include <assimp/Exporter.hpp>
|
|
|
|
#include <assimp/Importer.hpp>
|
|
|
|
#include <assimp/scene.h>
|
2017-11-21 16:04:22 +00:00
|
|
|
#include <assimp/postprocess.h>
|
2015-05-17 19:25:47 +00:00
|
|
|
|
|
|
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
|
|
|
|
|
|
|
class ColladaExportCamera : public ::testing::Test {
|
|
|
|
public:
|
2019-04-08 15:37:40 +00:00
|
|
|
void SetUp() override{
|
2015-05-19 04:26:05 +00:00
|
|
|
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
|
|
|
|
2019-04-08 15:37:40 +00:00
|
|
|
void TearDown() {
|
2015-05-19 04:26:05 +00:00
|
|
|
delete ex;
|
2019-04-08 15:37:40 +00:00
|
|
|
ex = nullptr;
|
2015-05-19 04:26:05 +00:00
|
|
|
delete im;
|
2019-04-08 15:37:40 +00:00
|
|
|
im = nullptr;
|
2015-05-19 04:26:05 +00:00
|
|
|
}
|
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
|
|
|
};
|
|
|
|
|
2019-04-08 15:37:40 +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
|
|
|
|
2017-11-21 16:04:22 +00:00
|
|
|
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure);
|
2019-04-08 15:37:40 +00:00
|
|
|
ASSERT_NE( nullptr, pTest );
|
2015-05-19 04:26:05 +00:00
|
|
|
ASSERT_TRUE(pTest->HasCameras());
|
2015-05-17 19:25:47 +00:00
|
|
|
|
|
|
|
|
2019-04-08 15:37:40 +00:00
|
|
|
EXPECT_EQ( AI_SUCCESS, ex->Export(pTest,"collada",file));
|
2015-11-01 12:48:55 +00:00
|
|
|
const unsigned int origNumCams( pTest->mNumCameras );
|
2016-07-04 20:15:23 +00:00
|
|
|
std::unique_ptr<float[]> origFOV( new float[ origNumCams ] );
|
|
|
|
std::unique_ptr<float[]> orifClipPlaneNear( new float[ origNumCams ] );
|
|
|
|
std::unique_ptr<float[]> orifClipPlaneFar( new float[ origNumCams ] );
|
|
|
|
std::unique_ptr<aiString[]> names( new aiString[ origNumCams ] );
|
|
|
|
std::unique_ptr<aiVector3D[]> pos( new aiVector3D[ origNumCams ] );
|
2015-11-01 12:48:55 +00:00
|
|
|
for (size_t i = 0; i < origNumCams; i++) {
|
|
|
|
const aiCamera *orig = pTest->mCameras[ i ];
|
2019-04-08 15:37:40 +00:00
|
|
|
ASSERT_NE(nullptr, orig );
|
2016-07-04 18:19:24 +00:00
|
|
|
|
2016-07-04 20:15:23 +00:00
|
|
|
origFOV[ i ] = orig->mHorizontalFOV;
|
|
|
|
orifClipPlaneNear[ i ] = orig->mClipPlaneNear;
|
|
|
|
orifClipPlaneFar[ i ] = orig->mClipPlaneFar;
|
|
|
|
names[ i ] = orig->mName;
|
|
|
|
pos[ i ] = orig->mPosition;
|
2015-11-01 12:48:55 +00:00
|
|
|
}
|
2017-11-21 16:04:22 +00:00
|
|
|
const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2019-04-08 15:37:40 +00:00
|
|
|
ASSERT_NE(nullptr, imported );
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-11-01 12:48:55 +00:00
|
|
|
EXPECT_TRUE( imported->HasCameras() );
|
|
|
|
EXPECT_EQ( origNumCams, imported->mNumCameras );
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-11-01 12:48:55 +00:00
|
|
|
for(size_t i=0; i< imported->mNumCameras;i++){
|
|
|
|
const aiCamera *read = imported->mCameras[ i ];
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-11-01 12:48:55 +00:00
|
|
|
EXPECT_TRUE( names[ i ] == read->mName );
|
2015-11-02 20:09:26 +00:00
|
|
|
EXPECT_NEAR( origFOV[ i ],read->mHorizontalFOV, 0.0001f );
|
2015-11-01 12:48:55 +00:00
|
|
|
EXPECT_FLOAT_EQ( orifClipPlaneNear[ i ], read->mClipPlaneNear);
|
|
|
|
EXPECT_FLOAT_EQ( orifClipPlaneFar[ i ], read->mClipPlaneFar);
|
2015-05-17 19:25:47 +00:00
|
|
|
|
2015-11-01 12:48:55 +00:00
|
|
|
EXPECT_FLOAT_EQ( pos[ i ].x,read->mPosition.x);
|
|
|
|
EXPECT_FLOAT_EQ( pos[ i ].y,read->mPosition.y);
|
|
|
|
EXPECT_FLOAT_EQ( pos[ i ].z,read->mPosition.z);
|
2015-05-19 04:26:05 +00:00
|
|
|
}
|
2015-05-17 19:25:47 +00:00
|
|
|
}
|
|
|
|
|
2016-07-04 18:19:24 +00:00
|
|
|
#endif // ASSIMP_BUILD_NO_EXPORT
|