|
|
|
|
/******************************************************************************
|
|
|
|
|
* File - components.h
|
|
|
|
|
* Author - Joey Pollack
|
|
|
|
|
* Date - 2022/05/24 (y/m/d)
|
|
|
|
|
* Mod Date - 2022/05/24 (y/m/d)
|
|
|
|
|
* Description - ECS component declarations
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef LUNARIUM_COMPONENTS_H_
|
|
|
|
|
#define LUNARIUM_COMPONENTS_H_
|
|
|
|
|
|
|
|
|
|
#include <core/common_defs.h>
|
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
|
|
|
|
|
|
#define GLM_ENABLE_EXPERIMENTAL
|
|
|
|
|
#include <glm/gtx/quaternion.hpp>
|
|
|
|
|
|
|
|
|
|
#include <renderer/orthographic_camera.h>
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
struct TagComponent
|
|
|
|
|
{
|
|
|
|
|
std::string Info;
|
|
|
|
|
|
|
|
|
|
TagComponent(std::string _info = "")
|
|
|
|
|
{
|
|
|
|
|
Info.reserve(256);
|
|
|
|
|
Info.insert(0, _info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TagComponent(const TagComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct TransformComponent
|
|
|
|
|
{
|
|
|
|
|
glm::vec3 Position = { 0.0f, 0.0f, 0.0f };
|
|
|
|
|
glm::vec3 Rotation = { 0.0f, 0.0f, 0.0f };
|
|
|
|
|
glm::vec3 Scale = { 1.0f, 1.0f, 1.0f };
|
|
|
|
|
|
|
|
|
|
TransformComponent(glm::vec3 p = glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3 r = glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3 s = glm::vec3(1.0f, 1.0f, 1.0f))
|
|
|
|
|
: Position(p), Rotation(r), Scale(s)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TransformComponent(const TransformComponent&) = default;
|
|
|
|
|
|
|
|
|
|
glm::mat4 GetTransform()
|
|
|
|
|
{
|
|
|
|
|
// Quaternion code taken from Hazel engine
|
|
|
|
|
// https://github.com/TheCherno/Hazel/blob/dev/Hazel/src/Hazel/Scene/Components.h
|
|
|
|
|
return (glm::translate(glm::mat4(1.0f), Position) * glm::toMat4(glm::quat(Rotation)) * glm::scale(glm::mat4(1.0f), Scale ));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct VelocityComponent
|
|
|
|
|
{
|
|
|
|
|
glm::vec3 Velocity = { 0.0f, 0.0f, 0.0f};
|
|
|
|
|
|
|
|
|
|
VelocityComponent() = default;
|
|
|
|
|
VelocityComponent(const VelocityComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CameraComponent
|
|
|
|
|
{
|
|
|
|
|
OrthographicCamera Camera;
|
|
|
|
|
|
|
|
|
|
CameraComponent() = default;
|
|
|
|
|
CameraComponent(const CameraComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct BlockOutComponent
|
|
|
|
|
{
|
|
|
|
|
glm::vec4 Color;
|
|
|
|
|
glm::vec2 Size;
|
|
|
|
|
|
|
|
|
|
BlockOutComponent() = default;
|
|
|
|
|
BlockOutComponent(const BlockOutComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // LUNARIUM_COMPONENTS_H_
|