Loading the first 3D model in the Wavefront Object (.obj) format
Now, we are ready to integrate a 3D object loader into our code. The first step is to create an empty class called ObjLoader
along with the source (.cpp
) and header (.h
) files. This class handles all the functions related to 3D object loading, parsing, and drawing using the OpenGL and Assimp libraries. The headers of the class will include the Assimp core functions for the handling of the data structures and all I/O mechanisms of the 3D data format:
#include <cimport.h> #include <scene.h> #include <postprocess.h>
In the ObjLoader.h
file, we provide interfaces for the main program to create, destroy, load, and display the 3D data. In the ObjLoader.cpp
file, we implement a set of functions to parse the scene (a hierarchical representation of the 3D objects in terms of meshes and faces) using the built-in functions from Assimp.
The Assimp library can support various 3D model data formats; however, in our example...