From 60e70c3cc52d8d6ecb9a40071501a8aa8d775568 Mon Sep 17 00:00:00 2001 From: JosiahWI Date: Mon, 17 Oct 2022 14:27:11 -0500 Subject: [PATCH] Update vertex test for coordinate system This is also the first working version of the mesh. I successfully loaded it in Minetest. --- source/Irrlicht/CGLTFMeshFileLoader.cpp | 11 +++++++---- source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/Irrlicht/CGLTFMeshFileLoader.cpp b/source/Irrlicht/CGLTFMeshFileLoader.cpp index 14e08165..22378e97 100644 --- a/source/Irrlicht/CGLTFMeshFileLoader.cpp +++ b/source/Irrlicht/CGLTFMeshFileLoader.cpp @@ -7,8 +7,11 @@ #include "path.h" #include "S3DVertex.h" #include "SAnimatedMesh.h" +#include "SColor.h" #include "SMesh.h" +#include + namespace irr { @@ -35,10 +38,10 @@ IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file) SMeshBuffer* meshbuf { new SMeshBuffer {} }; const video::S3DVertex* vertices { new video::S3DVertex[3] { - {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {}, 0.0f, 0.0f}, - {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {}, 0.0f, 0.0f}, - {1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, {}, 0.0f, 0.0f} } }; - const u16* indices { new u16[3] {} }; + {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f}, {}, {0.0f, 0.0f}}, + {{0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}, {}, {1.0f, 0.0f}}, + {{-1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f}, {}, {0.0f, 1.0f}} } }; + const u16* indices { new u16[3] {0, 1, 2} }; meshbuf->append(vertices, 3, indices, 3); SMesh* mesh { new SMesh {} }; diff --git a/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp b/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp index 1cadf669..73f618da 100644 --- a/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp +++ b/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp @@ -29,8 +29,8 @@ TEST_CASE("minimal triangle has correct vertices") { reinterpret_cast( meshbuf->getVertices()) }; CHECK(vertices[0].Pos == irr::core::vector3df {0.0f, 0.0f, 0.0f}); - CHECK(vertices[1].Pos == irr::core::vector3df {1.0f, 0.0f, 0.0f}); - CHECK(vertices[2].Pos == irr::core::vector3df {1.0f, 1.0f, 0.0f}); + CHECK(vertices[1].Pos == irr::core::vector3df {0.0f, 1.0f, 0.0f}); + CHECK(vertices[2].Pos == irr::core::vector3df {-1.0f, 0.0f, 0.0f}); device->drop(); }