Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283//// Created by kam on 20.2.2026.//
#include "Model.h"
using namespace Snail;
Model::Model(Mesh::Instance &mesh, Shader &shader, const glm::vec3 &position, const glm::quat &rotation, const glm::vec3 &scale): mesh(mesh), shader(shader), position(position), scale(scale), rotation(rotation), transform() { compute_transform();}
auto Model::set_name(const char* name) -> void { this->name = name;}
auto Model::set_shader(const Shader &shader) -> void { this->shader = shader;}
auto Model::set_transform(const glm::mat4 &transform) -> void { this->transform = transform;}
auto Model::set_transform(const glm::vec3 &position, const glm::quat &rotation, const glm::vec3 &scale) -> void { this->position = position; this->rotation = rotation; this->scale = scale; compute_transform();}
auto Model::set_position(const glm::vec3 &position) -> void { this->position = position; compute_transform();}
auto Model::set_scale(const glm::vec3 &scale) -> void { this->scale = scale; compute_transform();}
auto Model::set_rotation(const glm::quat &rotation) -> void { this->rotation = rotation; compute_transform();}
auto Model::get_transform() const -> glm::mat4 { return this->transform;}
auto Model::get_position() const -> glm::vec3 { return this->position;}
auto Model::get_scale() const -> glm::vec3 { return this->scale;}
auto Model::get_rotation() const -> glm::quat { return this->rotation;}
auto Model::get_shader() const -> Shader & { return this->shader;}
auto Model::get_mesh() const -> Mesh::Instance & { return this->mesh;}
auto Model::compute_transform() -> void { glm::mat4 mat{1.f}; auto t = glm::translate(mat, position); auto r = glm::toMat4(rotation); auto s = glm::scale(mat, scale); transform = t * r * s;}