diff --git a/source/Irrlicht/CGLTFMeshFileLoader.cpp b/source/Irrlicht/CGLTFMeshFileLoader.cpp index 46dfc197..6b1397d9 100644 --- a/source/Irrlicht/CGLTFMeshFileLoader.cpp +++ b/source/Irrlicht/CGLTFMeshFileLoader.cpp @@ -3,6 +3,7 @@ #include "IAnimatedMesh.h" #include "IReadFile.h" #include "path.h" +#include "SAnimatedMesh.h" namespace irr { @@ -22,7 +23,14 @@ bool CGLTFMeshFileLoader::isALoadableFileExtension( IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file) { - return nullptr; + if (file->getSize() == 0) { + return nullptr; + } + + // sorry Bjarne + SAnimatedMesh* mesh { new SAnimatedMesh {} }; + + return mesh; } } // namespace irr diff --git a/source/Irrlicht/tests/assets/minimal_triangle.gltf b/source/Irrlicht/tests/assets/minimal_triangle.gltf new file mode 100644 index 00000000..412dbac5 --- /dev/null +++ b/source/Irrlicht/tests/assets/minimal_triangle.gltf @@ -0,0 +1,70 @@ +{ + "scene": 0, + "scenes" : [ + { + "nodes" : [ 0 ] + } + ], + + "nodes" : [ + { + "mesh" : 0 + } + ], + + "meshes" : [ + { + "primitives" : [ { + "attributes" : { + "POSITION" : 1 + }, + "indices" : 0 + } ] + } + ], + + "buffers" : [ + { + "uri" : "data:application/octet-stream;base64,AAABAAIAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAA=", + "byteLength" : 44 + } + ], + "bufferViews" : [ + { + "buffer" : 0, + "byteOffset" : 0, + "byteLength" : 6, + "target" : 34963 + }, + { + "buffer" : 0, + "byteOffset" : 8, + "byteLength" : 36, + "target" : 34962 + } + ], + "accessors" : [ + { + "bufferView" : 0, + "byteOffset" : 0, + "componentType" : 5123, + "count" : 3, + "type" : "SCALAR", + "max" : [ 2 ], + "min" : [ 0 ] + }, + { + "bufferView" : 1, + "byteOffset" : 0, + "componentType" : 5126, + "count" : 3, + "type" : "VEC3", + "max" : [ 1.0, 1.0, 0.0 ], + "min" : [ 0.0, 0.0, 0.0 ] + } + ], + + "asset" : { + "version" : "2.0" + } +} diff --git a/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp b/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp index 179777f4..7dacf2f4 100644 --- a/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp +++ b/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp @@ -8,10 +8,21 @@ TEST_CASE("load empty gltf file") { irr::IrrlichtDevice* device { irr::createDevice(irr::video::EDT_NULL) }; irr::scene::ISceneManager* smgr { device->getSceneManager() }; - irr::io::InMemoryFile filebuf{"test.gltf", ""}; + irr::io::InMemoryFile filebuf {"test.gltf", ""}; auto* mesh { smgr->getMesh(&filebuf) }; - REQUIRE(mesh == nullptr); + CHECK(mesh == nullptr); + + device->drop(); +} + +TEST_CASE("load minimal triangle") { + irr::IrrlichtDevice* device { irr::createDevice(irr::video::EDT_NULL) }; + irr::scene::ISceneManager* smgr { device->getSceneManager() }; + + auto* mesh { smgr->getMesh( + "source/Irrlicht/tests/assets/minimal_triangle.gltf", "") }; + REQUIRE(mesh != nullptr); device->drop(); }