#include "model.h" #include "mesh.h" #include "state.h" #include "../lib/glm/gtc/matrix_transform.hpp" Model::Model(const std::shared_ptr& mesh) : mesh_(mesh) { } void Model::draw() { if (!mesh_) return; // Build model matrix: Translation * Rotation * Scale glm::mat4 model = glm::mat4(1.0f); // Translation model = glm::translate(model, position_); // Rotation (applying X, Y, Z rotations) model = glm::rotate(model, rotation_.x, glm::vec3(1.0f, 0.0f, 0.0f)); model = glm::rotate(model, rotation_.y, glm::vec3(0.0f, 1.0f, 0.0f)); model = glm::rotate(model, rotation_.z, glm::vec3(0.0f, 0.0f, 1.0f)); // Scale model = glm::scale(model, scale_); // Set the model matrix in state state::model_matrix = model; // Draw the mesh mesh_->draw(); }