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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#pragma once
#include <string>
#include "icommandsystem.h"
#include "imap.h"
#include "math/Vector3.h"
#include <memory>
class Entity;
namespace map
{
/** greebo: An instance of such a class manages a single Map Position.
*
* It provides methods to save itself to a given target entity,
* as well as methods to recall the stored position.
*/
class MapPosition
{
unsigned int _index;
// The saved position/angles
Vector3 _position;
Vector3 _angle;
// The entity key names according to this index
std::string _posKey;
std::string _angleKey;
public:
// Construct this position with its index
MapPosition(unsigned int index);
/** greebo: Loads the position from the given entity
*/
void loadFrom(Entity* entity);
/** greebo: Removes the values from the given entity
*/
void removeFrom(Entity* entity);
void loadFrom(const scene::IMapRootNodePtr& root);
// Store the current position to the map root
void saveTo(const scene::IMapRootNodePtr& root);
// Remove the current position from the given node
void removeFrom(const scene::IMapRootNodePtr& root);
/** greebo: Resets the position/angles to 0,0,0
*/
void clear();
/** greebo: Returns true if this position is not saved yet
*/
bool empty() const;
/** greebo: Reads the current position from the camera and
* stores it into the internal values.
*/
void store(const cmd::ArgumentList& args);
/** greebo: Recalls the stored position
*/
void recall(const cmd::ArgumentList& args);
};
typedef std::shared_ptr<MapPosition> MapPositionPtr;
} // namespace map
|