Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "bat.hpp"
#include "environment.hpp"
void bat::initialize_bat()
{
// Initialize the temporary mesh_drawable that will be inserted in the hierarchy
mesh_drawable body;
mesh_drawable wing1;
mesh_drawable wing2;
// Create the geometry of the meshes
// Note: this geometry must be set in their local coordinates with respect to their position in the hierarchy (and with respect to their animation)
body.initialize_data_on_gpu(mesh_load_file_obj(project::path + "assets/batbodyok.obj"));
wing1.initialize_data_on_gpu(mesh_load_file_obj(project::path + "assets/batwingleft.obj"));
wing2.initialize_data_on_gpu(mesh_load_file_obj(project::path + "assets/batwingright.obj"));
// Scale the model
body.model.scaling = 0.2f;
wing1.model.scaling = 0.2f;
wing2.model.scaling = 0.2f;
// Set the color of some elements
body.material.color = { 0.3f,0.3f,0.3f };
wing1.material.color = { 0.2f,0.2f,0.2f };
wing2.material.color = { 0.2f,0.2f,0.2f };
// Add the elements in the hierarchy
// The syntax is hierarchy.add(mesh_drawable, "name of the parent element", [optional: local translation in the hierarchy])
// Notes:
// - An element must necessarily be added after its parent
// - The first element (without explicit name of its parent) is assumed to be the root.
bat.add(body, "Bat base");
bat.add(wing1, "Bat wing left1", "Bat base", { -0.05f,0,0 });
bat.add(wing2, "Bat wing right1", "Bat base", { 0.05f,0,0 });
}