2018-10-25 00:19:38 +00:00
|
|
|
#ifndef DUST3D_ANIMATION_PLAYER_H
|
|
|
|
#define DUST3D_ANIMATION_PLAYER_H
|
2018-10-02 04:59:30 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QTime>
|
|
|
|
#include "meshloader.h"
|
|
|
|
|
|
|
|
class AnimationClipPlayer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2018-10-23 14:57:47 +00:00
|
|
|
|
2018-10-02 04:59:30 +00:00
|
|
|
signals:
|
|
|
|
void frameReadyToShow();
|
2018-10-23 14:57:47 +00:00
|
|
|
|
2018-10-02 04:59:30 +00:00
|
|
|
public:
|
2018-10-23 14:57:47 +00:00
|
|
|
enum class SpeedMode
|
|
|
|
{
|
|
|
|
Slow,
|
|
|
|
Normal,
|
|
|
|
Fast
|
|
|
|
};
|
|
|
|
|
2018-10-02 04:59:30 +00:00
|
|
|
~AnimationClipPlayer();
|
|
|
|
MeshLoader *takeFrameMesh();
|
|
|
|
void updateFrameMeshes(std::vector<std::pair<float, MeshLoader *>> &frameMeshes);
|
|
|
|
void clear();
|
2018-10-23 14:57:47 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setSpeedMode(SpeedMode speedMode);
|
|
|
|
|
2018-10-02 04:59:30 +00:00
|
|
|
private:
|
|
|
|
void freeFrames();
|
2018-10-23 14:57:47 +00:00
|
|
|
int getFrameDurationMillis(int frame);
|
|
|
|
|
2018-10-02 04:59:30 +00:00
|
|
|
MeshLoader *m_lastFrameMesh = nullptr;
|
|
|
|
int m_currentPlayIndex = 0;
|
|
|
|
std::vector<std::pair<float, MeshLoader *>> m_frameMeshes;
|
|
|
|
QTime m_countForFrame;
|
|
|
|
QTimer m_timerForFrame;
|
2018-10-23 14:57:47 +00:00
|
|
|
SpeedMode m_speedMode = SpeedMode::Normal;
|
2018-10-02 04:59:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|