Untitled Game engine no.5
1.0
|
5 #ifndef ENGINE_PROJ_ANIMATION_H
6 #define ENGINE_PROJ_ANIMATION_H
9 #include "MeshRenderer.hpp"
12 #include "Texture.hpp"
20 bool singleTexture =
true;
23 size_t m_currentFrame = 0;
24 size_t m_lastFrame = 0;
35 std::vector<Ref<TextureLookup>>
lookup = std::vector<Ref<TextureLookup>>();
43 auto ecs = scene.GetECS();
44 for (
auto e : ecs.GetEntitiesWith<
Animation>()) {
71 if (m_currentFrame >=
lookup.size()) {
81 if (m_currentFrame < 0) {
82 m_currentFrame =
lookup.size() - 1;
85 if (m_currentFrame != m_lastFrame) {
96 auto texData =
lookup[m_currentFrame];
97 if (
renderer ==
nullptr || texData ==
nullptr)
102 renderer->mesh = CreateRef<Mesh>(Mesh::quad(glm::scale(glm::vec3{texData->width, texData->height, 1})));
109 #endif //ENGINE_PROJ_ANIMATION_H
A container for entities currently in the Scene.
Definition: Scene.hpp:9
Animation(const Ref< MeshRenderer > &meshRenderer, const std::vector< Ref< TextureLookup >> &textureLookup)
Definition: Animation.hpp:58
std::shared_ptr< T > Ref
Has stuff for making references a lot more easily shared smart pointer.
Definition: Base.hpp:21
Container for texture based animations.
Definition: Animation.hpp:16
Ref< MeshRenderer > renderer
Renderer Reference.
Definition: Animation.hpp:33
static void Update(const Scene &scene)
Definition: Animation.hpp:42
Ref< C > GetComponent(const EntityID &id)
Definition: ECS.hpp:80
std::vector< Ref< TextureLookup > > lookup
lookup table for animation frame data
Definition: Animation.hpp:35
virtual void drawFrame()
Definition: Animation.hpp:95
Definition: Animation.hpp:14
static double dt
time since last update
Definition: Time.hpp:12
void UpdateTime()
Advance frame data if needed.
Definition: Animation.hpp:63