Project developed to study mesh rendering and skeleton animation with OpenGL.
The meshes, skeletons and animations are loaded from a JSON file with the following structure:
{
"texture": "texName",
"animations": [{
"name": "animName",
"duration": "<time_in_second>",
"bones":[{
"name":"boneName",
"pos_keys":[{"x":1, "y":1, "z":1, "time":1}, "..."],
"rot_keys":[{"w":1, "x":1, "y":1, "z":1, "time":1}, "..."],
"scale_keys":[{"x":1, "y":1, "z":1, "time":1}, "..."]
}, "..."]
}, "..."],
"meshes":[{
"bones":[{
"id": "<bone_id>",
"name": "boneName",
"pos":{"x":1, "y":1, "z":1},
"rot":{"w":1, "x":1, "y":1, "z":1},
"scale":{"x":1, "y":1, "z":1}
}, "..."],
"vertices":[{
"id": "<vertex_id>",
"normal": {"x":1, "y":1, "z":1},
"pos": {"x":1, "y":1, "z":1},
"texcoord": {"x":1, "y":1},
"joints":[{
"id": "<joint_id>",
"weight": "<joint_weight>"
}, "..."]
}, "..."],
"indices":["<id>", "<id>", "..."]
}, "..."],
"rootnode":{
"name": "<node name>",
"pos":{"x":1, "y":1, "z":1},
"rot":{"w":1, "x":1, "y":1, "z":1},
"scale":{"x":1, "y":1, "z":1},
"children": "<vector of nodes with name, pos, rot, scale and children>"
}
}
The parsing of the JSON file is done using Nlohmann's JSON for Modern C++.
The class structure is inspired from ThinMatrix's tutorial playlist, and so is the animated model used for this project.
The rendering is performed with OpenGL and most of the math operations are done using glm.
The textures are loaded using nothings' stb library.