Aegix GLTF is a compact library for loading and parsing GLTF 2.0 files in C++. It focuses on direct data mapping, translating all elements of a GLTF file into C++ structs that mirror the GLTF specification. The library uses the nlohmann/json library for JSON parsing.
For more details about the GLTF format and its capabilities, refer to the GLTF 2.0 Specification.
- Scene
- Node
- Mesh
- Accessor
- BufferView
- Buffer
- Material
- Texture
- Image
- Sampler
- Camera
- Skin
- Animation
-
Clone the repository
git clone https://github.com/chFleschutz/aegix-gltf.git
-
Generate Project Files
Use CMake to generate the project files, or open the folder directly in your CMake-supported IDE (e.g., Visual Studio).
-
Build and run the test project
The project builds as a static library. To use it in another project, follow these steps or refer to the test folder for an example:
-
Include the directory in your CMakeLists.txt file
add_subdirectory(path/to/aegix-gltf)
-
Link the library
target_link_libraries(your_target PRIVATE Aegix::GLTF)
-
Include
gltf.h
-
Load a GLTF file
Call
Aegix::GLTF::load
to load a GLTF file. The function returns astd::optional
which only contains a value if loading the file succeeds. -
(Optional) Include
gltf_print.h
Include
gltf_print.h
to define operator overloads for printing the GLTF structs.
#include "gltf.h"
#include "gltf_print.h" // Optional, for printing
std::filesystem::path gltfFilePath = "path/to/file.gltf";
std::optional<Aegix::GLTF::GLTF> gltf = Aegix::GLTF::load(gltfFilePath);
if (gltf.has_value())
{
std::cout << gltf.value() << "\n";
}