You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lunarium_OLD/src/world/components.h

48 lines
1.3 KiB
C

/******************************************************************************
* 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 <string>
namespace lunarium
{
struct TagComponent
{
std::string Info;
TagComponent()
{
Info.reserve(256);
}
};
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 };;
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 ));
}
};
}
#endif // LUNARIUM_COMPONENTS_H_