aboutsummaryrefslogtreecommitdiff
path: root/src/drone_controller.hh
blob: de9385d1de4fc62c8045877fd633389fcc3800c7 (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
#ifndef DRONE_CONTROLLER_HH
#define DRONE_CONTROLLER_HH

#include "drone.hh"

#include "opengl_widget.hh"

#include <QJsonObject>
#include <QTimer>
#include <QOpenGLExtraFunctions>


class DroneController : public QObject, public Painter {
	Q_OBJECT

	int framerate;
	int frame = 0;
	int duration = 0;
	QVector<Drone> drones;
	QTimer timer;
	bool paused = true;
	bool draw_spheres = false;
	double sphere_radius = 0;
	QTimer sphere_timer;

	static OpenGLMesh *sphere;
	static const unsigned char sphere_neutral[];

	static bool collides(const Drone &a, const Drone &b, double radius);

public:
	DroneController(const QJsonObject &json);
	int getDuration() const;
	void draw(QOpenGLExtraFunctions *f) const;

signals:
	void frameChanged(int frame);
	void playing();
	void pausing();
	void collision(int idA, int idB, int frame);

private slots:
	void step();

public slots:
	void play();
	void pause();
	void suspend();
	void resume();
	void seek(int frame);
	void computeCollisions(double sphere_radius);
	void displaySpheres(double sphere_radius);
};


#endif