mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
blocks animation fix
This commit is contained in:
parent
4fe79458ab
commit
36a5da5bc1
2 changed files with 65 additions and 56 deletions
|
|
@ -13,40 +13,40 @@ class Framebuffer;
|
|||
constexpr float DEFAULT_FRAME_DURATION = 0.150f;
|
||||
|
||||
struct Frame {
|
||||
glm::ivec2 srcPos;
|
||||
glm::ivec2 dstPos;
|
||||
glm::ivec2 size;
|
||||
float duration = DEFAULT_FRAME_DURATION;
|
||||
glm::ivec2 srcPos;
|
||||
glm::ivec2 dstPos;
|
||||
glm::ivec2 size;
|
||||
float duration = DEFAULT_FRAME_DURATION;
|
||||
};
|
||||
|
||||
class TextureAnimation {
|
||||
public:
|
||||
TextureAnimation(Texture* srcTex, Texture* dstTex) : srcTexture(srcTex), dstTexture(dstTex) {};
|
||||
~TextureAnimation() {};
|
||||
TextureAnimation(Texture* srcTex, Texture* dstTex) : srcTexture(srcTex), dstTexture(dstTex) {};
|
||||
~TextureAnimation() {};
|
||||
|
||||
void addFrame(const Frame& frame) { frames.emplace_back(frame); };
|
||||
void addFrame(const Frame& frame) { frames.emplace_back(frame); };
|
||||
|
||||
size_t currentFrame = 0;
|
||||
float timer = 0.f;
|
||||
Texture* srcTexture;
|
||||
Texture* dstTexture;
|
||||
std::vector<Frame> frames;
|
||||
size_t currentFrame = 0;
|
||||
float timer = 0.f;
|
||||
Texture* srcTexture;
|
||||
Texture* dstTexture;
|
||||
std::vector<Frame> frames;
|
||||
};
|
||||
|
||||
class TextureAnimator {
|
||||
public:
|
||||
TextureAnimator();
|
||||
~TextureAnimator();
|
||||
TextureAnimator();
|
||||
~TextureAnimator();
|
||||
|
||||
void addAnimation(const TextureAnimation& animation) { animations.emplace_back(animation); };
|
||||
void addAnimations(const std::vector<TextureAnimation>& animations);
|
||||
void addAnimation(const TextureAnimation& animation) { animations.emplace_back(animation); };
|
||||
void addAnimations(const std::vector<TextureAnimation>& animations);
|
||||
|
||||
void update(float delta);
|
||||
void update(float delta);
|
||||
private:
|
||||
uint fboR;
|
||||
uint fboD;
|
||||
|
||||
Framebuffer* frameBuffer;
|
||||
|
||||
std::vector<TextureAnimation> animations;
|
||||
std::vector<TextureAnimation> animations;
|
||||
};
|
||||
|
||||
#endif // !TEXTURE_ANIMATION_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue