KlassischeKeplerKriege/game/state/trace.hpp

50 lines
1.5 KiB
C++
Raw Normal View History

2016-09-27 17:32:12 +00:00
#pragma once
#include <glm/vec2.hpp>
2016-09-27 17:43:40 +00:00
#include <vector>
2016-09-27 17:32:12 +00:00
namespace game {
2016-09-27 17:43:40 +00:00
class Missile;
2016-09-27 17:32:12 +00:00
/*
* Trace of a missile through the space.
* Useful for rendering sth. like a smoke trail to follow the rocket.
*/
class Trace {
public:
2016-09-27 17:43:40 +00:00
Trace(const Missile *missile);
// Add the current position of the missile as a new point on the
// trace.
// Parameters:
// forceAdd: set to true to add this point (good for the endpoint of
// the missile) in case the fidelityCounter would skip the current position.
void addPointFromMissile(bool forceAdd=false);
2016-09-27 20:35:16 +00:00
// call this to mark the trace as finish and disconnect it from the
// missile.
void finish();
// TODO: add extendLastPointToPosition() method for saving points /
// optimization later on
2016-09-27 17:43:40 +00:00
/*
* Trace point data to be used when rendering.
*/
struct TracePoint {
TracePoint(const Missile *missile);
2016-09-27 17:32:12 +00:00
glm::vec2 position;
float speed;
2016-09-27 17:43:40 +00:00
};
2016-09-27 17:32:12 +00:00
2016-09-27 17:43:40 +00:00
std::vector<TracePoint> points;
const Missile *missile; // missile which creates this path.
// counter which is incremented each time addPointFromMissile() is called.
// when reaching a certain value the point is saved for
// optimization.
int fidelityCounter;
2016-09-27 17:32:12 +00:00
};
}