vengine  0.0.1
3D graphics engine
Loading...
Searching...
No Matches
Transform3D.hpp
Go to the documentation of this file.
1///
2/// @file Transform3D.hpp
3/// @brief This file contains the Transform3D class
4/// @namespace ven
5///
6
7#pragma once
8
9#include <glm/gtc/matrix_transform.hpp>
10
11namespace ven {
12
13 ///
14 /// @class Transform3D
15 /// @brief Class for 3D transformation
16 /// @namespace ven
17 ///
19
20 public:
21
22 [[nodiscard]] glm::mat4 transformMatrix() const {
23 auto rotationMatrix = glm::mat4(1.0F);
24
25 rotationMatrix = rotate(rotationMatrix, rotation.x, glm::vec3(1.0F, 0.0F, 0.0F));
26 rotationMatrix = rotate(rotationMatrix, rotation.y, glm::vec3(0.0F, 1.0F, 0.0F));
27 rotationMatrix = rotate(rotationMatrix, rotation.z, glm::vec3(0.0F, 0.0F, 1.0F));
28
29 const glm::mat4 scaleMatrix = glm::scale(glm::mat4(1.0F), scale);
30 const glm::mat4 translationMatrix = translate(glm::mat4(1.0F), translation);
31
32 return translationMatrix * rotationMatrix * scaleMatrix;
33 }
34 [[nodiscard]] glm::mat3 normalMatrix() const { return transpose(inverse(glm::mat3(transformMatrix()))); }
35
36 glm::vec3 translation{};
37 glm::vec3 scale{};
38 glm::vec3 rotation{};
39
40 }; // class Transform3D
41
42} // namespace ven
Class for 3D transformation.
glm::mat4 transformMatrix() const
glm::vec3 translation
glm::mat3 normalMatrix() const