Test that minimal triangle returns some mesh

This commit is contained in:
JosiahWI 2022-10-17 07:17:07 -05:00 committed by Josiah VanderZee
parent 7900f0a3a9
commit a9f56df279
3 changed files with 122 additions and 2 deletions

View File

@ -0,0 +1,39 @@
#include "CGLTFMeshFileLoader.h"
#include "coreutil.h"
#include "IAnimatedMesh.h"
#include "IReadFile.h"
#include "path.h"
#include "SAnimatedMesh.h"
namespace irr
{
namespace scene
{
CGLTFMeshFileLoader::CGLTFMeshFileLoader()
{
}
bool CGLTFMeshFileLoader::isALoadableFileExtension(
const io::path& filename) const
{
return core::hasFileExtension(filename, "gltf");
}
IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file)
{
if (file->getSize() == 0) {
return nullptr;
}
// sorry Bjarne
SAnimatedMesh* mesh { new SAnimatedMesh {} };
return mesh;
}
} // namespace irr
} // namespace scene

View File

@ -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"
}
}

View File

@ -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();
}