2022-10-17 14:17:07 +02:00
|
|
|
#include "CGLTFMeshFileLoader.h"
|
2022-10-17 14:34:19 +02:00
|
|
|
#include "CMeshBuffer.h"
|
2022-10-17 14:17:07 +02:00
|
|
|
#include "coreutil.h"
|
|
|
|
#include "IAnimatedMesh.h"
|
|
|
|
#include "IReadFile.h"
|
2022-10-17 14:34:19 +02:00
|
|
|
#include "irrTypes.h"
|
2022-10-17 14:17:07 +02:00
|
|
|
#include "path.h"
|
2022-10-17 14:34:19 +02:00
|
|
|
#include "S3DVertex.h"
|
2022-10-17 14:17:07 +02:00
|
|
|
#include "SAnimatedMesh.h"
|
2022-10-17 14:34:19 +02:00
|
|
|
#include "SMesh.h"
|
2022-10-17 14:17:07 +02:00
|
|
|
|
|
|
|
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
|
2022-10-17 14:34:19 +02:00
|
|
|
SMeshBuffer* meshbuf { new SMeshBuffer {} };
|
2022-10-17 14:17:07 +02:00
|
|
|
|
2022-10-17 14:34:19 +02:00
|
|
|
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] {} };
|
|
|
|
meshbuf->append(vertices, 3, indices, 3);
|
|
|
|
|
|
|
|
SMesh* mesh { new SMesh {} };
|
|
|
|
mesh->addMeshBuffer(meshbuf);
|
|
|
|
|
|
|
|
SAnimatedMesh* animatedMesh { new SAnimatedMesh {} };
|
|
|
|
animatedMesh->addMesh(mesh);
|
|
|
|
|
|
|
|
return animatedMesh;
|
2022-10-17 14:17:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace irr
|
|
|
|
|
|
|
|
} // namespace scene
|
|
|
|
|