#include "bats.hpp" #include "environment.hpp" #include "key_positions_structure.hpp" #include "interpolation.hpp" #include "terrain.hpp" void bats::initialize_bats() { // 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_mesh.add(body, "Bat base"); bat_mesh.add(wing1, "Bat wing left1", "Bat base"); bat_mesh.add(wing2, "Bat wing right1", "Bat base"); N = 0; } void bats::update_mvt() { for (int i = 0; i < N; i++) { bats_prop[i].update_mvt(); } } void bats::add_bat(vec3 new_pos, float _size, numarray<vec3> key_positions, numarray<float> key_times) { N++; bats_prop.resize(N); bats_prop[N - 1].pos = new_pos; bats_prop[N - 1].isdead = false; bats_prop[N - 1].size = _size; bats_prop[N - 1].initialize_mvt(new_pos, key_positions, key_times); }