Skip to content

Commit

Permalink
#5722: Add unit test checking the ability to load (and convert) an FB…
Browse files Browse the repository at this point in the history
…X model
  • Loading branch information
codereader committed Aug 22, 2021
1 parent 7a40fd7 commit eb87959
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/ModelExport.cpp
Expand Up @@ -292,6 +292,29 @@ TEST_F(ModelExportTest, ConvertLwoToAse)
runConverterCode(_context.getTestProjectPath() + "models/torch.lwo", outputPath);
}

TEST_F(ModelExportTest, ConvertFbxToAse)
{
auto outputPath = _context.getTemporaryDataPath() + "conversiontest.lwo";
auto extension = string::to_upper_copy(os::getExtension(outputPath));
auto inputPath = _context.getTestResourcePath() + "fbx/test_cube.fbx";

EXPECT_FALSE(fs::exists(outputPath)) << outputPath << " already exists";

// Invoke the converter code
GlobalCommandSystem().executeCommand("ConvertModel", cmd::ArgumentList{ inputPath, outputPath, extension });

EXPECT_TRUE(fs::exists(outputPath)) << outputPath << " should have been created";

auto importer = GlobalModelFormatManager().getImporter(extension);
auto exportedModel = importer->loadModelFromPath(outputPath);

EXPECT_TRUE(exportedModel) << "No FBX model has been created";
EXPECT_EQ(exportedModel->getSurfaceCount(), 1);
EXPECT_EQ(exportedModel->getSurface(0).getDefaultMaterial(), "phong1");
EXPECT_EQ(exportedModel->getVertexCount(), 8);
EXPECT_EQ(exportedModel->getPolyCount(), 12);
}

TEST_F(ModelExportTest, ConvertAseToLwo)
{
// Convert the torch to ASE first, then back to LWO
Expand Down
16 changes: 16 additions & 0 deletions test/Models.cpp
Expand Up @@ -437,4 +437,20 @@ TEST_F(AseImportTest, ParseGeomObjectWithoutMaterialRef)
}
}

TEST_F(ModelTest, LoadFbxModel)
{
auto inputPath = _context.getTestResourcePath() + "fbx/test_cube.fbx";

auto importer = GlobalModelFormatManager().getImporter("FBX");
EXPECT_TRUE(importer) << "No FBX importer available";

auto model = importer->loadModelFromPath(inputPath);

EXPECT_TRUE(model) << "No FBX model has been loaded";
EXPECT_EQ(model->getSurfaceCount(), 1);
EXPECT_EQ(model->getSurface(0).getDefaultMaterial(), "phong1");
EXPECT_EQ(model->getVertexCount(), 8);
EXPECT_EQ(model->getPolyCount(), 12);
}

}
Binary file added test/resources/fbx/test_cube.fbx
Binary file not shown.

0 comments on commit eb87959

Please sign in to comment.