Add GLTF mesh file loader

This commit is contained in:
JosiahWI 2022-10-16 21:17:21 -05:00
parent 520569c1e3
commit 4860523223
No known key found for this signature in database
GPG Key ID: C7BB8573A4ABC4B9
6 changed files with 79 additions and 0 deletions

View File

@ -53,6 +53,9 @@ namespace scene
//! Halflife MDL model file
EAMT_MDL_HALFLIFE,
//! Graphics Language Transmission Format 2.0 (.gltf) mesh
EAMT_GLTF2,
//! generic skinned mesh
EAMT_SKINNED,

View File

@ -349,6 +349,12 @@ B3D, MS3D or X meshes */
#undef _IRR_COMPILE_WITH_OBJ_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_GLTF_LOADER_ if you want to load glTF files
#define _IRR_COMPILE_WITH_GLTF_LOADER_
#ifdef NO_IRR_COMPILE_WITH_GLTF_LOADER_
#undef _IRR_COMPILE_WITH_GLTF_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_BMP_LOADER_ if you want to load .bmp files
//! Disabling this loader will also disable the built-in font
#define _IRR_COMPILE_WITH_BMP_LOADER_

View File

@ -0,0 +1,31 @@
#include "CGLTFMeshFileLoader.h"
#include "coreutil.h"
#include "IAnimatedMesh.h"
#include "IReadFile.h"
#include "path.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)
{
return nullptr;
}
} // namespace irr
} // namespace scene

View File

@ -0,0 +1,31 @@
#ifndef __C_GLTF_MESH_FILE_LOADER_INCLUDED__
#define __C_GLTF_MESH_FILE_LOADER_INCLUDED__
#include "IAnimatedMesh.h"
#include "IMeshLoader.h"
#include "IReadFile.h"
#include "path.h"
namespace irr
{
namespace scene
{
class CGLTFMeshFileLoader : public IMeshLoader
{
public:
CGLTFMeshFileLoader();
bool isALoadableFileExtension(const io::path& filename) const override;
IAnimatedMesh* createMesh(io::IReadFile* file) override;
};
} // namespace scene
} // namespace irr
#endif // __C_GLTF_MESH_FILE_LOADER_INCLUDED__

View File

@ -161,6 +161,7 @@ set(IRRMESHLOADER
CB3DMeshFileLoader.cpp
COBJMeshFileLoader.cpp
CXMeshFileLoader.cpp
CGLTFMeshFileLoader.cpp
)
add_library(IRRMESHOBJ OBJECT

View File

@ -33,6 +33,10 @@
#include "CB3DMeshFileLoader.h"
#endif
#ifdef _IRR_COMPILE_WITH_GLTF_LOADER_
#include "CGLTFMeshFileLoader.h"
#endif
#ifdef _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_
#include "CBillboardSceneNode.h"
#endif // _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_
@ -105,6 +109,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
#ifdef _IRR_COMPILE_WITH_B3D_LOADER_
MeshLoaderList.push_back(new CB3DMeshFileLoader(this));
#endif
#ifdef _IRR_COMPILE_WITH_GLTF_LOADER_
MeshLoaderList.push_back(new CGLTFMeshFileLoader());
#endif
}