.. _program_listing_file_Src_GraphicsEngineOpenGL_scene_GameObject.cpp: Program Listing for File GameObject.cpp ======================================= |exhale_lsh| :ref:`Return to documentation for file ` (``Src/GraphicsEngineOpenGL/scene/GameObject.cpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include "GameObject.hpp" GameObject::GameObject() : model(std::make_shared(Model())) {} GameObject::GameObject(const std::string &model_path, glm::vec3 translation, GLfloat scale, Rotation rot) : model(std::make_shared()) { model->load_model_in_ram(model_path); this->translation = translation; this->scale_factor = scale; this->rot = rot; } void GameObject::init(const std::string &model_path, glm::vec3 translation, GLfloat scale, Rotation rot) { model = std::make_shared(Model()); model->load_model_in_ram(model_path); this->translation = translation; this->scale_factor = scale; this->rot = rot; } glm::mat4 GameObject::get_world_trafo() { glm::mat4 model_to_world = glm::mat4(1.0); model_to_world = glm::translate(model_to_world, translation); model_to_world = glm::scale(model_to_world, glm::vec3(scale_factor)); model_to_world = glm::rotate(model_to_world, glm::radians(rot.degrees), rot.axis); return model_to_world; } glm::mat4 GameObject::get_normal_world_trafo() { glm::mat4 world_trafo = get_world_trafo(); return glm::transpose(glm::inverse(world_trafo)); } void GameObject::render() { model->render(); } std::shared_ptr GameObject::get_aabb() { return model->get_aabb(); } std::shared_ptr GameObject::get_model() { return model; } void GameObject::translate(glm::vec3 translate) { this->translation = translate; } void GameObject::rotate(Rotation rot) { this->rot = rot; } void GameObject::scale(GLfloat scale_factor) { this->scale_factor = scale_factor; } GameObject::~GameObject() {}