From f6869e314fd3c055f3f11dd74fdfdac8abc0be12 Mon Sep 17 00:00:00 2001 From: Onur Berk Tore Date: Sat, 2 Jul 2022 23:22:35 +0300 Subject: [PATCH] Feature: Inits units tests for fbx and glTF2 AssimpLoader_TEST.cc updated to include basic unit tests for fbx and glb mesh files. New mesh files uploaded. Signed-off-by: Onur Berk Tore --- graphics/src/AssimpLoader_TEST.cc | 69 ++++++++++++++++++++++++++++++ test/data/box.fbx | Bin 0 -> 26428 bytes test/data/box.glb | Bin 0 -> 1892 bytes 3 files changed, 69 insertions(+) create mode 100644 test/data/box.fbx create mode 100644 test/data/box.glb diff --git a/graphics/src/AssimpLoader_TEST.cc b/graphics/src/AssimpLoader_TEST.cc index b0862b050..911c3727d 100644 --- a/graphics/src/AssimpLoader_TEST.cc +++ b/graphics/src/AssimpLoader_TEST.cc @@ -285,3 +285,72 @@ TEST_F(AssimpLoader, LoadObjBox) EXPECT_EQ(mat->Specular(), math::Color(0.25, 0.25, 0.25, 1.0)); EXPECT_DOUBLE_EQ(mat->Transparency(), 0.0); } + +///////////////////////////////////////////////// +TEST_F(AssimpLoader, LoadFbxBox) +{ + common::AssimpLoader loader; + common::Mesh *mesh = loader.Load( + common::testing::TestFile("data", "box.fbx")); + + EXPECT_STREQ("unknown", mesh->Name().c_str()); + EXPECT_EQ(ignition::math::Vector3d(1, 1, 1), mesh->Max()); + EXPECT_EQ(ignition::math::Vector3d(-1, -1, -1), mesh->Min()); + // 36 vertices + // TODO check why now we have 24, sounds more correct than 36? + EXPECT_EQ(36u, mesh->VertexCount()); + EXPECT_EQ(36u, mesh->NormalCount()); + EXPECT_EQ(36u, mesh->IndexCount()); + EXPECT_EQ(0u, mesh->TexCoordCount()); + EXPECT_EQ(1u, mesh->SubMeshCount()); + EXPECT_EQ(1u, mesh->MaterialCount()); + + // Make sure we can read the submesh name + EXPECT_STREQ("Cube_Cube.001", mesh->SubMeshByIndex(0).lock()->Name().c_str()); + + EXPECT_EQ(mesh->MaterialCount(), 2u); + + const common::MaterialPtr mat = mesh->MaterialByIndex(1u); + ASSERT_TRUE(mat.get()); + + // Make sure we read the material color values + EXPECT_EQ(mat->Ambient(), math::Color(0.0, 0.0, 0.0, 1.0)); + EXPECT_EQ(mat->Diffuse(), math::Color(0.512f, 0.512f, 0.512f, 1.0f)); + EXPECT_EQ(mat->Specular(), math::Color(0.25, 0.25, 0.25, 1.0)); + EXPECT_DOUBLE_EQ(mat->Transparency(), 0.0); +} + +///////////////////////////////////////////////// +TEST_F(AssimpLoader, LoadGlTF2Box) +{ + common::AssimpLoader loader; + common::Mesh *mesh = loader.Load( + common::testing::TestFile("data", "box.glb")); + + EXPECT_STREQ("unknown", mesh->Name().c_str()); + EXPECT_EQ(ignition::math::Vector3d(1, 1, 1), mesh->Max()); + EXPECT_EQ(ignition::math::Vector3d(-1, -1, -1), mesh->Min()); + + // 36 vertices + // TODO check why now we have 24, sounds more correct than 36? + EXPECT_EQ(36u, mesh->VertexCount()); + EXPECT_EQ(36u, mesh->NormalCount()); + EXPECT_EQ(36u, mesh->IndexCount()); + EXPECT_EQ(0u, mesh->TexCoordCount()); + EXPECT_EQ(1u, mesh->SubMeshCount()); + EXPECT_EQ(1u, mesh->MaterialCount()); + + // Make sure we can read the submesh name + EXPECT_STREQ("Cube_Cube.001", mesh->SubMeshByIndex(0).lock()->Name().c_str()); + + EXPECT_EQ(mesh->MaterialCount(), 2u); + + const common::MaterialPtr mat = mesh->MaterialByIndex(1u); + ASSERT_TRUE(mat.get()); + + // Make sure we read the material color values + EXPECT_EQ(mat->Ambient(), math::Color(0.0, 0.0, 0.0, 1.0)); + EXPECT_EQ(mat->Diffuse(), math::Color(0.512f, 0.512f, 0.512f, 1.0f)); + EXPECT_EQ(mat->Specular(), math::Color(0.25, 0.25, 0.25, 1.0)); + EXPECT_DOUBLE_EQ(mat->Transparency(), 0.0); +} \ No newline at end of file diff --git a/test/data/box.fbx b/test/data/box.fbx new file mode 100644 index 0000000000000000000000000000000000000000..edf8d0d2542c83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