Merge pull request #2410 from assimp/fbx_embedded_ascii

FBX: add test case
pull/2419/head^2
Kim Kulling 2019-04-11 12:40:13 +02:00 committed by GitHub
commit 5bf096ab6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 528 additions and 27 deletions

View File

@ -77,19 +77,19 @@ namespace Assimp {
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000L #define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000L
FBXConverter::FBXConverter(aiScene* out, const Document& doc) FBXConverter::FBXConverter(aiScene* out, const Document& doc)
: defaultMaterialIndex() : defaultMaterialIndex()
, lights() , lights()
, cameras() , cameras()
, textures() , textures()
, materials_converted() , materials_converted()
, textures_converted() , textures_converted()
, meshes_converted() , meshes_converted()
, node_anim_chain_bits() , node_anim_chain_bits()
, mNodeNameInstances() , mNodeNameInstances()
, mNodeNames() , mNodeNames()
, anim_fps() , anim_fps()
, out(out) , out(out)
, doc(doc) { , doc(doc) {
// animations need to be converted first since this will // animations need to be converted first since this will
// populate the node_anim_chain_bits map, which is needed // populate the node_anim_chain_bits map, which is needed
// to determine which nodes need to be generated. // to determine which nodes need to be generated.

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
ply ply
format ascii 1.0 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 element vertex 8
property float x property float x
property float y 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 { class ColladaExportCamera : public ::testing::Test {
public: public:
void SetUp() override{
virtual void SetUp()
{
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;
ex = nullptr;
delete im; delete im;
im = nullptr;
} }
protected: protected:
@ -71,16 +70,15 @@ protected:
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_TRUE(pTest!=NULL); 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 ] );
@ -89,7 +87,7 @@ TEST_F(ColladaExportCamera, testExportCamera)
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_TRUE( orig != nullptr ); ASSERT_NE(nullptr, orig );
origFOV[ i ] = orig->mHorizontalFOV; origFOV[ i ] = orig->mHorizontalFOV;
orifClipPlaneNear[ i ] = orig->mClipPlaneNear; orifClipPlaneNear[ i ] = orig->mClipPlaneNear;
@ -99,7 +97,7 @@ TEST_F(ColladaExportCamera, testExportCamera)
} }
const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure); const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_TRUE(imported!=NULL); ASSERT_NE(nullptr, imported );
EXPECT_TRUE( imported->HasCameras() ); EXPECT_TRUE( imported->HasCameras() );
EXPECT_EQ( origNumCams, imported->mNumCameras ); EXPECT_EQ( origNumCams, imported->mNumCameras );
@ -119,5 +117,3 @@ TEST_F(ColladaExportCamera, testExportCamera)
} }
#endif // ASSIMP_BUILD_NO_EXPORT #endif // ASSIMP_BUILD_NO_EXPORT

View File

@ -114,3 +114,18 @@ TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
scene->mMetaData->Get("UnitScaleFactor", factor); scene->mMetaData->Get("UnitScaleFactor", factor);
EXPECT_DOUBLE_EQ(500.0, 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));
}