#ifndef DRONE_CONTROLLER_HH #define DRONE_CONTROLLER_HH #include "opengl_mesh.hh" #include #include #include template 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 waypoints; int mesh_id; QVector3D pos; int id; public: Drone(int id); Drone(const QJsonObject &json); const QVector getWaypoints() const; void setTo(int frame); QVector3D getPos() const; int getId() const; }; class DroneController : public QObject { Q_OBJECT int framerate; int frame = 0; int duration = 0; QVector drones; QTimer timer; bool paused = true; static bool collides(const Drone &a, const Drone &b, double radius); public: DroneController(const QJsonObject &json); int getDuration() 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); }; #endif