41 lines
893 B
C++
41 lines
893 B
C++
#pragma once
|
|
|
|
#include <unordered_set>
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
#include "Mesh.h"
|
|
|
|
class Entity {
|
|
private:
|
|
glm::mat4 _transform;
|
|
|
|
glm::mat4 _localToWorld;
|
|
glm::mat4 _worldToLocal;
|
|
|
|
Entity* _parent;
|
|
std::unordered_set<Entity*> _children;
|
|
|
|
void _UpdateChildTransform() const;
|
|
|
|
public:
|
|
Entity(Entity* parent);
|
|
virtual ~Entity();
|
|
|
|
void AddChild(Entity* entity);
|
|
void RemoveChild(Entity* entity);
|
|
|
|
Entity* Parent() const { return _parent; }
|
|
|
|
void Transform(const glm::mat4& transform);
|
|
void TransformLocal(const glm::mat4& transform);
|
|
void SetTransform(const glm::mat4& transform);
|
|
const glm::mat4& LocalToWorld() const { return _localToWorld; }
|
|
const glm::mat4& WorldToLocal() const { return _worldToLocal; }
|
|
const glm::mat4& LocalObjectTransform() const { return _transform; }
|
|
|
|
virtual void Render(DefaultUniform& uniform) { };
|
|
virtual void Update(double deltaTime) { };
|
|
|
|
};
|