48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "cve_model.hpp"
|
|
|
|
#include <memory>
|
|
|
|
namespace cve {
|
|
|
|
struct Transform2dComponent {
|
|
glm::vec2 translation{}; // Position offset
|
|
glm::vec2 scale{1.f, 1.f};
|
|
float rotation;
|
|
|
|
glm::mat2 mat2() {
|
|
const float s = glm::sin(rotation);
|
|
const float c = glm::cos(rotation);
|
|
glm::mat2 rotMatrix{{c, s}, {-s, c}};
|
|
|
|
glm::mat2 scaleMat{{scale.x, .0f}, {.0f, scale.y}};
|
|
return rotMatrix*scaleMat;
|
|
};
|
|
};
|
|
|
|
class CveGameObject {
|
|
public:
|
|
using id_t = unsigned int;
|
|
|
|
static CveGameObject createGameObject() {
|
|
static id_t currentId = 0;
|
|
return CveGameObject{currentId++};
|
|
}
|
|
|
|
CveGameObject(const CveGameObject &) = delete;
|
|
CveGameObject &operator=(const CveGameObject &) = delete;
|
|
CveGameObject(CveGameObject &&) = default;
|
|
CveGameObject &operator=(CveGameObject &&) = default;
|
|
|
|
const id_t getId() { return id; }
|
|
|
|
std::shared_ptr<CveModel> model{};
|
|
glm::vec3 color;
|
|
Transform2dComponent transform2d{};
|
|
|
|
private:
|
|
CveGameObject(id_t objID) : id{objID} {}
|
|
id_t id;
|
|
};
|
|
} |