2024-12-25 23:58:56 +00:00
|
|
|
// Transform.h
|
|
|
|
#pragma once
|
2024-12-27 01:34:34 +00:00
|
|
|
|
|
|
|
#include "Component.h"
|
2024-12-25 23:58:56 +00:00
|
|
|
#include <glm/glm.hpp>
|
2024-12-27 01:34:34 +00:00
|
|
|
#include <yaml-cpp/yaml.h>
|
2024-12-25 23:58:56 +00:00
|
|
|
|
2024-12-27 01:34:34 +00:00
|
|
|
class TransformComponent : public Component
|
2024-12-25 23:58:56 +00:00
|
|
|
{
|
2024-12-27 01:34:34 +00:00
|
|
|
public:
|
|
|
|
glm::vec3 position;
|
|
|
|
glm::vec3 rotation;
|
|
|
|
glm::vec3 scale;
|
2024-12-25 23:58:56 +00:00
|
|
|
|
2024-12-30 04:25:16 +00:00
|
|
|
glm::vec3 GetPosition() const
|
|
|
|
{
|
2024-12-28 03:43:17 +00:00
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
2024-12-30 04:25:16 +00:00
|
|
|
void SetPosition(float x, float y, float z)
|
|
|
|
{
|
|
|
|
position = {x, y, z};
|
2024-12-28 03:43:17 +00:00
|
|
|
}
|
|
|
|
|
2024-12-30 04:25:16 +00:00
|
|
|
glm::vec3 GetRotation() const
|
|
|
|
{
|
2024-12-28 03:43:17 +00:00
|
|
|
return rotation;
|
|
|
|
}
|
|
|
|
|
2024-12-30 04:25:16 +00:00
|
|
|
void SetRotation(float x, float y, float z)
|
|
|
|
{
|
|
|
|
rotation = {x, y, z};
|
2024-12-28 03:43:17 +00:00
|
|
|
}
|
|
|
|
|
2024-12-27 01:34:34 +00:00
|
|
|
TransformComponent();
|
2024-12-30 04:25:16 +00:00
|
|
|
virtual const std::string &GetName() const override;
|
|
|
|
static const std::string &GetStaticName();
|
|
|
|
|
|
|
|
virtual void Update(float deltaTime) override;
|
2024-12-25 23:58:56 +00:00
|
|
|
|
2024-12-27 01:34:34 +00:00
|
|
|
// Serialization methods
|
|
|
|
virtual YAML::Node Serialize() override;
|
2024-12-30 04:25:16 +00:00
|
|
|
virtual void Deserialize(const YAML::Node &node) override;
|
2025-01-05 04:04:21 +00:00
|
|
|
glm::mat4 GetTransformMatrix() const;
|
|
|
|
void SetTransformMatrix(const glm::mat4& transform);
|
|
|
|
|
2024-12-25 23:58:56 +00:00
|
|
|
|
2024-12-27 01:34:34 +00:00
|
|
|
private:
|
|
|
|
static const std::string name;
|
|
|
|
};
|