Using a C++ glTF loader to get the model data
An uncomplicated way to load a glTF model into a structured data model can be achieved by using a glTF loader library. For this book, we will use the tinygltf
library.
The repository for the project is available at GitHub: https://github.com/syoyo/tinygltf.
We need to add a couple of files to our project. Create a new folder called tinygltf
, download the following files, and move them into the new folder:
tiny_gltf.h
tiny_gltf.cc
json.hpp
The tiny_gltf.h
file contains the glTF loader implementation itself; this is the file we will have to include to the classes loading the model file. The next file on the list, tiny_gltf.cc
, has some additional C-style #define
directives that are required for the loader. The last file, json.hpp
, is required to read and write JSON files.
In addition to these three files, we need to get two other files. Download these two files to the include
folder:
stb_image.h
...