5#include <glm/ext/matrix_transform.hpp>
7#include <glm/gtc/quaternion.hpp>
8#include <glm/gtx/matrix_decompose.hpp>
9#include <glm/gtx/quaternion.hpp>
67 const bool success = glm::decompose(matrix,
68 transform_component.
scale,
71 transform_component.
skew,
74 std::cerr <<
"Failed to decompose transformation matrix.\n";
77 return transform_component;
111 transform[3] = glm::vec4(newLocation, 1.0f);
123 const glm::vec3 currentTranslation = currentComponents.
translation;
124 const glm::vec3 currentScale = currentComponents.
scale;
127 const glm::mat4 rotationMatrix = glm::toMat4(newQuaternion);
145 glm::quat rotationQuat = glm::quat(glm::radians(newRotationEuler));
149 glm::vec3 currentTranslation = currentComponents.
translation;
150 glm::vec3 currentScale = currentComponents.
scale;
153 glm::mat4 rotationMatrix = glm::toMat4(rotationQuat);
172 glm::vec3 currentTranslation = currentComponents.
translation;
173 glm::quat currentRotation = currentComponents.
rotation;
176 glm::mat4 rotationMatrix = glm::toMat4(currentRotation);
200 const glm::mat4 parentMatrix = parent.
toMatrix();
201 const glm::mat4 localMatrix = this->
toMatrix();
204 const glm::mat4 worldMatrix = parentMatrix * localMatrix;
214 transform.setRotation(glm::degrees(glm::eulerAngles(transform_component.
rotation)));
227 "(x:" + std::to_string(
getScale().x) +
",y:" + std::to_string(
getScale().y) +
",z:" + std::to_string(
getScale().z) +
"))";
255 return typeid(*this).name();
284 const bool success = glm::decompose(matrix,
285 transform_component.
scale,
288 transform_component.
skew,
291 std::cerr <<
"Failed to decompose transformation matrix.\n";
294 return transform_component;
299 return glm::vec3(matrix[3]);
305 glm::normalize(glm::vec3(matrix[0])),
306 glm::normalize(glm::vec3(matrix[1])),
307 glm::normalize(glm::vec3(matrix[2]))
309 return glm::quat_cast(rotMat);
314 return glm::degrees(glm::eulerAngles(
getRotation(matrix)));
320 glm::length(glm::vec3(matrix[0])),
321 glm::length(glm::vec3(matrix[1])),
322 glm::length(glm::vec3(matrix[2]))
328 transform.
matrix[3] = glm::vec4(newPosition, 1.0f);
333 setRotation(transform, glm::quat(glm::radians(newRotation)));
339 glm::vec3 currentScale;
340 currentScale.x = glm::length(glm::vec3(transform.
matrix[0]));
341 currentScale.y = glm::length(glm::vec3(transform.
matrix[1]));
342 currentScale.z = glm::length(glm::vec3(transform.
matrix[2]));
345 glm::mat3 rotMat = glm::mat3_cast(newQuaternion);
347 transform.
matrix[0] = glm::vec4(rotMat[0] * currentScale.x, 0.f);
348 transform.
matrix[1] = glm::vec4(rotMat[1] * currentScale.y, 0.f);
349 transform.
matrix[2] = glm::vec4(rotMat[2] * currentScale.z, 0.f);
355 transform.
matrix[0] = glm::vec4(glm::normalize(glm::vec3(transform.
matrix[0])) * newScale.x, 0.f);
356 transform.
matrix[1] = glm::vec4(glm::normalize(glm::vec3(transform.
matrix[1])) * newScale.y, 0.f);
357 transform.
matrix[2] = glm::vec4(glm::normalize(glm::vec3(transform.
matrix[2])) * newScale.z, 0.f);
#define TRACY_ZONE_SCOPED_FUNCTION
static void deserialize(nlohmann::json &archive, glm::vec3 &vector)
static void Serialize(nlohmann::json &archive, const glm::vec3 &vector)
virtual void Serialize(nlohmann::json &archive)
Data structs for the Entity Component System.
Log category system implementation.