vengine  0.1.0
3D graphics engine made with Vulkan
Loading...
Searching...
No Matches
object.cpp
Go to the documentation of this file.
1#include "VEngine/Object.hpp"
2
4 const float c3 = glm::cos(rotation.z);
5 const float s3 = glm::sin(rotation.z);
6 const float c2 = glm::cos(rotation.x);
7 const float s2 = glm::sin(rotation.x);
8 const float c1 = glm::cos(rotation.y);
9 const float s1 = glm::sin(rotation.y);
10 return glm::mat4{
11 {
12 scale.x * (c1 * c3 + s1 * s2 * s3),
13 scale.x * (c2 * s3),
14 scale.x * (c1 * s2 * s3 - c3 * s1),
15 0.0F,
16 },
17 {
18 scale.y * (c3 * s1 * s2 - c1 * s3),
19 scale.y * (c2 * c3),
20 scale.y * (c1 * c3 * s2 + s1 * s3),
21 0.0F,
22 },
23 {
24 scale.z * (c2 * s1),
25 scale.z * (-s2),
26 scale.z * (c1 * c2),
27 0.0F,
28 },
29 {
33 1.0F
34 }
35 };
36}
37
39{
40 const float c3 = glm::cos(rotation.z);
41 const float s3 = glm::sin(rotation.z);
42 const float c2 = glm::cos(rotation.x);
43 const float s2 = glm::sin(rotation.x);
44 const float c1 = glm::cos(rotation.y);
45 const float s1 = glm::sin(rotation.y);
46 const glm::vec3 invScale = 1.0F / scale;
47
48 return glm::mat3{
49 {
50 invScale.x * (c1 * c3 + s1 * s2 * s3),
51 invScale.x * (c2 * s3),
52 invScale.x * (c1 * s2 * s3 - c3 * s1)
53 },
54 {
55 invScale.y * (c3 * s1 * s2 - c1 * s3),
56 invScale.y * (c2 * c3),
57 invScale.y * (c1 * c3 * s2 + s1 * s3)
58 },
59 {
60 invScale.z * (c2 * s1),
61 invScale.z * (-s2),
62 invScale.z * (c1 * c2)
63 }
64 };
65}
66
67ven::Object ven::Object::makePointLight(const float intensity, const float radius, const glm::vec3 color)
68{
70 obj.color = color;
71 obj.transform3D.scale.x = radius;
72 obj.pointLight = std::make_unique<PointLightComponent>();
73 obj.pointLight->lightIntensity = intensity;
74 return obj;
75}
This file contains the Object class.
Transform3DComponent transform3D
Definition Object.hpp:55
std::unique_ptr< PointLightComponent > pointLight
Definition Object.hpp:57
static Object makePointLight(float intensity=10.F, float radius=0.1F, glm::vec3 color=glm::vec3(1.F))
Definition object.cpp:67
glm::vec3 color
Definition Object.hpp:54
static Object createObject()
Definition Object.hpp:40
glm::mat3 normalMatrix() const
Definition object.cpp:38
glm::mat4 mat4() const
Definition object.cpp:3