ecsgame/ECS/Components/PathMove.h

47 lines
1.2 KiB
C
Raw Normal View History

#ifndef __PATHMOVE_H__
#define __PATHMOVE_H__
#include <glm/glm.hpp>
2020-09-29 17:56:07 +02:00
#include <glm/gtx/quaternion.hpp>
#include <vector>
struct PathMove {
struct Path {
Path(std::vector<glm::vec3> points) : points(points) {
// Calculate distances
for (int i = 0; i < points.size() - 1; i++) {
distances.emplace_back(glm::distance(points[i], points[i + 1]));
}
}
void add_point(glm::vec3 new_point) {
distances.emplace_back(glm::distance(points.back(), new_point));
points.emplace_back(new_point);
}
2020-09-29 17:56:07 +02:00
std::vector<glm::vec3> points;
std::vector<float> distances;
};
2020-09-29 17:56:07 +02:00
struct Views {
Views(std::vector<glm::quat> views) : views(views) {}
void add_view(glm::quat new_quat) { views.emplace_back(new_quat); }
2020-09-29 17:56:07 +02:00
std::vector<glm::quat> views;
};
PathMove(double speed, Path path, Views views) : speed(speed), path(path), views(views) {}
bool is_active = false;
2020-09-29 17:56:07 +02:00
double speed;
float time_passed = 0.0;
int current_point_index = 0;
int speed_addition =
0; // 0, -1 or 1 depending on whether the speed should stay, decrease or increase
2020-10-03 00:56:41 +02:00
2020-09-29 17:56:07 +02:00
Path path;
Views views;
};
#endif // __PATHMOVE_H__