Skip to content
Snippets Groups Projects
bat.cpp 1.44 KiB
Newer Older
Marie AUDOUARD's avatar
Marie AUDOUARD committed
#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 });

}