[2191] | 1 | /*! |
---|
| 2 | \file coordinates.h |
---|
| 3 | \brief Basic coordinate system definitions |
---|
| 4 | */ |
---|
| 5 | |
---|
[2551] | 6 | #ifndef COORDINATES_H |
---|
| 7 | #define COORDINATES_H |
---|
[2191] | 8 | |
---|
[2551] | 9 | #include "vector.h" |
---|
| 10 | |
---|
| 11 | class Track; |
---|
| 12 | |
---|
[2191] | 13 | //! Coordinates relative to track |
---|
| 14 | /** |
---|
| 15 | This identifies the position of an object on the track system |
---|
| 16 | */ |
---|
| 17 | typedef struct |
---|
| 18 | { |
---|
| 19 | unsigned long part; //!< ID of the track part the object is on |
---|
[2551] | 20 | Track* track; //!< This is the current Track to which the Entity belongs to |
---|
[2191] | 21 | float dist; //!< The distance that has already been traveled on the track |
---|
[2551] | 22 | Vector pos; //!< The position relative to the offset marked by the distance already covered - this is mostly for user interaction/control |
---|
| 23 | Quaternion rot; //!< The direction the object is heading (relative to track direction) |
---|
[2191] | 24 | } Location; |
---|
| 25 | |
---|
| 26 | //! Absolute coordinates |
---|
| 27 | /** |
---|
| 28 | This is used to store the position of a object in the rendered coordinate system |
---|
| 29 | */ |
---|
| 30 | typedef struct |
---|
| 31 | { |
---|
[3013] | 32 | Vector pos; //!< Absolute x/y/z coordinates |
---|
| 33 | Quaternion rot; //!< Absolute orientation |
---|
[2191] | 34 | } Placement; |
---|
[2551] | 35 | |
---|
[3023] | 36 | |
---|
| 37 | /////////////////////////////////////////////////////////////////// |
---|
| 38 | //////// NEW COORDINATES, because the old ones were a bit fuzy // |
---|
| 39 | /////////////////////////////////////////////////////////////////// |
---|
| 40 | enum COORD_TYPE {WORLD, TRACK, LOCAL}; |
---|
| 41 | |
---|
| 42 | typedef struct |
---|
| 43 | { |
---|
| 44 | Vector position; |
---|
| 45 | Quaternion rotation; |
---|
| 46 | } Coord; |
---|
| 47 | |
---|
[3028] | 48 | //! A class to handle coordinates of Objects. |
---|
[3023] | 49 | class Coordinate |
---|
| 50 | { |
---|
| 51 | private: |
---|
| 52 | Coord worldCoord; |
---|
| 53 | |
---|
| 54 | public: |
---|
| 55 | |
---|
| 56 | void setCoord (Coord coordinate, COORD_TYPE cType); |
---|
| 57 | void setPosition (Vector position, COORD_TYPE cType); |
---|
| 58 | void setRotation (Quaternion rotation, COORD_TYPE cType); |
---|
| 59 | |
---|
[3028] | 60 | void move (Vector, COORD_TYPE cType); // just move a Object |
---|
| 61 | |
---|
[3023] | 62 | Coord getCoord (COORD_TYPE cType) const; |
---|
| 63 | Vector getPosition (COORD_TYPE cType) const; |
---|
| 64 | Quaternion getRotation (COORD_TYPE cType) const; |
---|
| 65 | }; |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | //! World coordinates: |
---|
| 72 | /** |
---|
| 73 | Absolute coordinates in 3D-space are defined as the coordinates, an Entity has in respect to the absolute Zero point |
---|
| 74 | */ |
---|
| 75 | typedef struct |
---|
| 76 | { |
---|
| 77 | Vector position; //!< absolute position of the Object (the one opengl has to know) |
---|
| 78 | Quaternion rot; //!< absolute rotation |
---|
| 79 | } WorldCoord; |
---|
| 80 | |
---|
| 81 | typedef struct |
---|
| 82 | { |
---|
| 83 | Vector position; //!< The Vector from the current Path-Position to the Entity. (worldCoord->position - track->worldCoord->position) |
---|
| 84 | Quaternion rot; //!< rotation an entity has to the track. |
---|
| 85 | } TrackCoord; |
---|
| 86 | |
---|
| 87 | typedef struct |
---|
| 88 | { |
---|
| 89 | Vector position; //!< the coordinate to the object itself. This shoud be 0 for an entity. (can be used for explosions on the ship, shoot and so on.) |
---|
| 90 | Quaternion rot; //!< the Rotation of an object itself. (to easily shoot in different directions) |
---|
| 91 | } LocalCoord; |
---|
| 92 | |
---|
[2551] | 93 | #endif |
---|