Raito 0.1
Loading...
Searching...
No Matches
Components.h
Go to the documentation of this file.
1/*
2MIT License
3
4Copyright (c) 2023 Víctor Falcón Zaro
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in all
14copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE.
23*/
24
25#pragma once
26
27#include <string>
28
29#include <Raito/Core/UUID.h>
30#include <Raito/Math/Math.h>
31
32namespace Raito::ECS
33{
35 {
37
38 IDComponent() = default;
39 IDComponent(const UUID& id) : ID(id){}
40 IDComponent(const IDComponent&) = default;
41 };
42
44 {
45 std::string Tag;
46
47 TagComponent() = default;
48 TagComponent(const TagComponent&) = default;
49 TagComponent(const std::string& tag)
50 : Tag(tag) {}
51 };
52
54 {
57
58 MeshComponent() = default;
59 MeshComponent(const MeshComponent&) = default;
60 MeshComponent(u32 mesh, u32 material)
61 : MeshId(mesh), MaterialId(material) {}
62 };
63
65 {
66 V3 Translation = { 0.0f, 0.0f, 0.0f };
67 Quaternion Rotation = { 0.0f, 0.0f, 0.0f, 1.0f };
68 V3 Scale = { 1.0f, 1.0f, 1.0f };
69
70 TransformComponent() = default;
72 TransformComponent(V3 translation, Quaternion rotation, V3 scale)
73 : Translation(translation), Rotation(rotation), Scale(scale) {}
74 TransformComponent(const V3& translation)
75 : Translation(translation) {}
76
81
86 };
87
89 {
90 enum class Type
91 {
96
97 V3 Color = { 1.0f, 1.0f, 1.0f };
98 V3 Direction = { 0.0f, 0.0f, 0.0f };
99 float Radius;
100
101 LightComponent() = default;
103 LightComponent(const Type type, const V3 color, const float radius)
104 : LightType(type), Color(color), Direction(0.0), Radius(radius) {}
105
106 LightComponent(const Type type , const V3 color, const V3 direction)
107 : LightType(type),Color(color), Direction(direction){}
108 };
109
110}
unsigned __int32 u32
Unsigned integer 32 bit type.
Definition BasicTypes.h:55
Definition UUID.h:32
Definition Components.h:33
Mat4 CreateTransform(const V3 &translation, const Quaternion &rotation, const V3 &scale)
Definition Math.cpp:33
void DecomposeTransform(const Mat4 &m, V3 &translation, Quaternion &rotation, V3 &scale)
Definition Math.cpp:38
glm::mat4x4 Mat4
Definition MathTypes.h:80
glm::vec4 Color
Color structure.
Definition MathTypes.h:86
glm::quat Quaternion
Quaternion structure.
Definition MathTypes.h:83
glm::vec3 V3
3D Vector; 32 bit floating point components
Definition MathTypes.h:47
Definition Components.h:35
IDComponent(const IDComponent &)=default
UUID ID
Definition Components.h:36
IDComponent(const UUID &id)
Definition Components.h:39
Definition Components.h:89
enum Raito::ECS::LightComponent::Type LightType
LightComponent(const LightComponent &)=default
LightComponent(const Type type, const V3 color, const V3 direction)
Definition Components.h:106
Type
Definition Components.h:91
V3 Direction
Definition Components.h:98
float Radius
Definition Components.h:99
LightComponent(const Type type, const V3 color, const float radius)
Definition Components.h:103
Definition Components.h:54
u32 MeshId
Definition Components.h:55
MeshComponent(u32 mesh, u32 material)
Definition Components.h:60
u32 MaterialId
Definition Components.h:56
MeshComponent(const MeshComponent &)=default
Definition Components.h:44
TagComponent(const TagComponent &)=default
std::string Tag
Definition Components.h:45
TagComponent(const std::string &tag)
Definition Components.h:49
Definition Components.h:65
TransformComponent(const Mat4 &mat)
Definition Components.h:77
V3 Translation
Definition Components.h:66
TransformComponent(const V3 &translation)
Definition Components.h:74
Mat4 GetTransform() const
Definition Components.h:82
TransformComponent(V3 translation, Quaternion rotation, V3 scale)
Definition Components.h:72
TransformComponent(const TransformComponent &)=default
V3 Scale
Definition Components.h:68
Quaternion Rotation
Definition Components.h:67