blob: 18fc7220c6954ba1c460d36d1dadb265a0474e37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#ifndef DRONE_CONTROLLER_HH
#define DRONE_CONTROLLER_HH
#include "opengl_mesh.hh"
#include <QJsonObject>
#include <QVector3D>
#include <QTimer>
template <typename T>
static T lerp(T a, T b, double factor) {
return a + (factor * (b - a));
}
struct Waypoint {
int frame;
QVector3D pos;
Waypoint(unsigned frame, QVector3D pos);
Waypoint(const QJsonObject &json);
};
class Drone {
static OpenGLMesh *mesh;
static bool mesh_initialized;
QVector<Waypoint> waypoints;
int mesh_id;
public:
Drone();
Drone(const QJsonObject &json);
const QVector<Waypoint> getWaypoints() const;
void setTo(int frame);
};
class DroneController : public QObject {
Q_OBJECT
int framerate;
int frame = 0;
int duration = 0;
QVector<Drone> drones;
QTimer timer;
bool paused = true;
public:
DroneController(const QJsonObject &json);
int getDuration() const;
signals:
void frameChanged(int frame);
void playing();
void pausing();
private slots:
void step();
public slots:
void play();
void pause();
void suspend();
void resume();
void seek(int frame);
};
#endif
|