2023-05-23 23:38:37 +02:00
|
|
|
#ifndef HOLESOME_TRACKING_VIEW_H
|
|
|
|
#define HOLESOME_TRACKING_VIEW_H
|
2023-05-09 20:50:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include "../game_object.h"
|
2023-05-14 22:23:25 +02:00
|
|
|
#include "ITrackable.h"
|
|
|
|
#include "../../primitives/circle_object.h"
|
2023-05-24 17:05:47 +02:00
|
|
|
#include "tracking_area.h"
|
2023-05-25 22:40:26 +02:00
|
|
|
#include "tracking_view_options.hpp"
|
2023-05-09 20:50:50 +02:00
|
|
|
|
2023-05-24 14:00:51 +02:00
|
|
|
class CircleObject;
|
|
|
|
|
2023-05-23 23:38:37 +02:00
|
|
|
class TrackingView : public GameObject
|
2023-05-09 20:50:50 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-05-25 22:40:26 +02:00
|
|
|
explicit TrackingView(TrackingViewOptions options = TrackingViewOptions());
|
2023-05-09 20:50:50 +02:00
|
|
|
|
2023-05-23 23:38:37 +02:00
|
|
|
~TrackingView();
|
2023-05-09 20:50:50 +02:00
|
|
|
|
2023-05-14 22:23:25 +02:00
|
|
|
|
2023-06-10 15:24:03 +02:00
|
|
|
void draw(sf::RenderWindow *window) override;
|
2023-05-24 14:00:51 +02:00
|
|
|
|
|
|
|
void lateUpdate() override;
|
2023-05-09 20:50:50 +02:00
|
|
|
|
2023-06-13 19:04:38 +02:00
|
|
|
void addTrackable(const std::shared_ptr<ITrackable>& trackable);
|
2023-05-24 01:15:05 +02:00
|
|
|
|
2023-05-14 22:23:25 +02:00
|
|
|
sf::Vector2f getSize() const;
|
2023-05-24 14:00:51 +02:00
|
|
|
|
2023-05-14 22:23:25 +02:00
|
|
|
sf::Vector2f getCenter() const;
|
2023-05-09 20:50:50 +02:00
|
|
|
|
|
|
|
private:
|
2023-05-14 22:23:25 +02:00
|
|
|
sf::View *view{};
|
|
|
|
bool hasViewChanged{};
|
2023-05-25 22:40:26 +02:00
|
|
|
TrackingViewOptions options;
|
2023-06-13 19:04:38 +02:00
|
|
|
std::vector<std::shared_ptr<ITrackable>> trackables;
|
2023-05-14 22:23:25 +02:00
|
|
|
|
|
|
|
CircleObject *marker;
|
2023-05-10 11:03:14 +02:00
|
|
|
|
2023-05-24 14:00:51 +02:00
|
|
|
void initializeView();
|
2023-05-10 11:30:11 +02:00
|
|
|
|
2023-05-25 22:40:26 +02:00
|
|
|
void followTrackables();
|
2023-05-14 22:23:25 +02:00
|
|
|
|
|
|
|
void moveCenter(sf::Vector2<float> delta);
|
|
|
|
|
2023-05-24 17:05:47 +02:00
|
|
|
TrackingArea getTrackingArea() const;
|
2023-05-24 01:15:05 +02:00
|
|
|
|
|
|
|
void processTrackableStates();
|
2023-05-24 15:21:53 +02:00
|
|
|
|
2023-05-25 22:40:26 +02:00
|
|
|
void adjustSizeToTrackables();
|
|
|
|
|
|
|
|
void setSize(sf::Vector2f newSize);
|
|
|
|
|
|
|
|
sf::Vector2f applyPadding(sf::Vector2f viewSize) const;
|
|
|
|
|
|
|
|
sf::Vector2f restrainToBounds(sf::Vector2f viewSize) const;
|
|
|
|
|
|
|
|
float getRadius(float threshold) const;
|
2023-05-27 18:37:08 +02:00
|
|
|
|
|
|
|
sf::Vector2f getWindowSize() const;
|
2023-05-09 20:50:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-05-23 23:38:37 +02:00
|
|
|
#endif //HOLESOME_TRACKING_VIEW_H
|