minecraftvulkan/engine/xe_game_object.hpp

50 lines
924 B
C++
Raw Normal View History

2022-09-19 01:20:51 +00:00
#pragma once
#include "xe_model.hpp"
#include <glm/ext/matrix_transform.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/fwd.hpp>
#include <memory>
namespace xe {
struct TransformComponent {
glm::vec3 translation{};
glm::vec3 scale{1.f, 1.f, 1.f};
glm::vec3 rotation{};
glm::mat4 mat4();
glm::mat3 normalMatrix();
};
2022-09-25 01:16:13 +00:00
class GameObject {
2022-09-19 01:20:51 +00:00
public:
using id_t = unsigned int;
2022-09-25 01:16:13 +00:00
static GameObject createGameObject() {
2022-09-19 01:20:51 +00:00
static id_t currentId = 0;
2022-09-25 01:16:13 +00:00
return GameObject(currentId++);
2022-09-19 01:20:51 +00:00
}
2022-09-25 01:16:13 +00:00
GameObject(const GameObject &) = delete;
GameObject &operator=(const GameObject &) = delete;
GameObject(GameObject&&) = default;
GameObject &operator=(GameObject &&) = default;
2022-09-19 01:20:51 +00:00
id_t getId() { return id; }
2022-09-25 01:16:13 +00:00
std::shared_ptr<Model> model{};
2022-09-25 23:05:56 +00:00
// glm::vec3 color{};
2022-09-19 01:20:51 +00:00
TransformComponent transform;
private:
2022-09-25 01:16:13 +00:00
GameObject(id_t objId) : id{objId} {}
2022-09-19 01:20:51 +00:00
id_t id;
};
}