Add assimp-based mesh import
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <XCEngine/Core/Asset/ResourceManager.h>
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -30,4 +31,44 @@ TEST(Mesh, GetSections) {
|
||||
EXPECT_EQ(mesh.GetSections().Size(), 0u);
|
||||
}
|
||||
|
||||
TEST(Mesh, SetVertexAndIndexData) {
|
||||
Mesh mesh;
|
||||
|
||||
StaticMeshVertex vertices[3];
|
||||
vertices[0].position = Vector3(0.0f, 0.0f, 0.0f);
|
||||
vertices[1].position = Vector3(1.0f, 0.0f, 0.0f);
|
||||
vertices[2].position = Vector3(0.0f, 1.0f, 0.0f);
|
||||
|
||||
const uint16_t indices[3] = {0, 1, 2};
|
||||
|
||||
mesh.SetVertexData(vertices, sizeof(vertices), 3, sizeof(StaticMeshVertex),
|
||||
VertexAttribute::Position | VertexAttribute::Normal | VertexAttribute::UV0);
|
||||
mesh.SetIndexData(indices, sizeof(indices), 3, false);
|
||||
|
||||
EXPECT_EQ(mesh.GetVertexCount(), 3u);
|
||||
EXPECT_EQ(mesh.GetIndexCount(), 3u);
|
||||
EXPECT_EQ(mesh.GetVertexStride(), sizeof(StaticMeshVertex));
|
||||
EXPECT_TRUE(HasVertexAttribute(mesh.GetVertexAttributes(), VertexAttribute::Position));
|
||||
EXPECT_TRUE(HasVertexAttribute(mesh.GetVertexAttributes(), VertexAttribute::Normal));
|
||||
EXPECT_TRUE(HasVertexAttribute(mesh.GetVertexAttributes(), VertexAttribute::UV0));
|
||||
EXPECT_GT(mesh.GetMemorySize(), 0u);
|
||||
}
|
||||
|
||||
TEST(Mesh, AddSection) {
|
||||
Mesh mesh;
|
||||
|
||||
MeshSection section{};
|
||||
section.baseVertex = 1;
|
||||
section.vertexCount = 3;
|
||||
section.startIndex = 6;
|
||||
section.indexCount = 9;
|
||||
section.materialID = 2;
|
||||
|
||||
mesh.AddSection(section);
|
||||
|
||||
ASSERT_EQ(mesh.GetSections().Size(), 1u);
|
||||
EXPECT_EQ(mesh.GetSections()[0].baseVertex, 1u);
|
||||
EXPECT_EQ(mesh.GetSections()[0].materialID, 2u);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user