/*! \file coordinates.h \brief Basic coordinate system definitions */ #ifndef COORDINATES_H #define COORDINATES_H #include "vector.h" class Track; //! Coordinates relative to track /** This identifies the position of an object on the track system */ typedef struct { unsigned long part; //!< ID of the track part the object is on Track* track; //!< This is the current Track to which the Entity belongs to float dist; //!< The distance that has already been traveled on the track Vector pos; //!< The position relative to the offset marked by the distance already covered - this is mostly for user interaction/control Quaternion rot; //!< The direction the object is heading (relative to track direction) } Location; //! Absolute coordinates /** This is used to store the position of a object in the rendered coordinate system */ typedef struct { Vector pos; //!< Absolute x/y/z coordinates Quaternion rot; //!< Absolute orientation } Placement; /////////////////////////////////////////////////////////////////// //////// NEW COORDINATES, because the old ones were a bit fuzy // /////////////////////////////////////////////////////////////////// enum COORD_TYPE {WORLD, TRACK, LOCAL}; typedef struct { Vector position; Quaternion rotation; } Coord; //! A class to handle coordinates of Objects. class Coordinate { private: Coord worldCoord; public: void setCoord (Coord coordinate, COORD_TYPE cType); void setPosition (Vector position, COORD_TYPE cType); void setRotation (Quaternion rotation, COORD_TYPE cType); void move (Vector, COORD_TYPE cType); // just move a Object Coord getCoord (COORD_TYPE cType) const; Vector getPosition (COORD_TYPE cType) const; Quaternion getRotation (COORD_TYPE cType) const; }; //! World coordinates: /** Absolute coordinates in 3D-space are defined as the coordinates, an Entity has in respect to the absolute Zero point */ typedef struct { Vector position; //!< absolute position of the Object (the one opengl has to know) Quaternion rot; //!< absolute rotation } WorldCoord; typedef struct { Vector position; //!< The Vector from the current Path-Position to the Entity. (worldCoord->position - track->worldCoord->position) Quaternion rot; //!< rotation an entity has to the track. } TrackCoord; typedef struct { 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.) Quaternion rot; //!< the Rotation of an object itself. (to easily shoot in different directions) } LocalCoord; #endif