Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/parenting/src/track_manager.h @ 3333

Last change on this file since 3333 was 3333, checked in by bensch, 19 years ago

orxonox/branches/parenting: :TrackManager: reimplemented some functions, and added some for the logic of it.

File size: 5.3 KB
Line 
1/*!
2    \file track_manager.h
3    \brief manages all tracks defined in the world and the path the player takes
4
5    it is a container for all tracks and all track-nodes. it manages the movement of
6    the track helper-parent (that drives the player). it is responsable for calculating
7    smooth curves etc.
8*/
9
10
11#ifndef _TRACK_MANAGER_H
12#define _TRACK_MANAGER_H
13
14#include "stdincl.h"
15
16
17//! condition for choosing a certain Path. \todo implement a useful way.
18struct PathCondition
19{
20 
21};
22 
23
24//! A Graph-Element, that holds the curve-structure of a Level.
25/**
26   A TrackElement is used, to define the structure of the Track itself.
27   It is a graph and not a tree, because paths can fork and join again.
28*/
29class TrackElement
30{
31 public:
32  TrackElement(void);
33  ~TrackElement(void);
34
35  void initChildren(unsigned int childCount);
36
37  TrackElement* findByID(unsigned int trackID);
38
39  bool isFresh;              //!< If no Points where added until now
40  bool isSavePoint;          //!< If the first node is a savePoint
41  bool isFork;               //!< If the first node is a Fork
42  bool isJoined;             //!< If the End of the Curve is joined.
43  PathCondition cond;        //!< The Split Condition;
44  int ID;                    //!< The ID of this TrackElement
45  float startingTime;        //!< The time at which this Track begins.
46  float duration;            //!< The time used to cross this TrackElement (curve).
47  CurveType curveType;       //!< The CurveType this will have.
48  int nodeCount;             //!< The count of points this TrackElement has.
49  char* name;                //!< A name for the Trac.
50  Curve* curve;              //!< The Curve of this TrackElement
51  int childCount;            //!< The number of Children This TrackElement has.
52  TrackElement** children;   //!< A TrackElement can have a Tree of following TrackElements.
53};
54
55
56
57//! The TrackManager handles the flow of the Players through the game.
58/**
59   \todo write the methodes
60
61   <b>The TrackManager works as followed:</b> \n
62     \n
63   <b>1. Initialize it, by setting up the Graph. You can do this by using the following Commands.</b>
64    \li workOn(): changes the ID that will be altered through the changes.
65    \li setCurveType(): lets you set the CurveType of the Curve we are Working on. (default is BezierCurve, set this as early as possible, for this uses resources).
66    \li setDuration(): sets the length of the current path in seconds.
67    \li addPoint(): adds a point to the Curve.
68    \li addHotPoint(): adds save/splitpoint.\n
69    \li fork(): adds some interessting non-linear movments through the level (fork will force addHotPoint if not done then).
70    \li condition(): decides under what condition a certain Path will be chosen.
71    \li join(): joins some tracks together again. Join will set the localTime to the longest time a Path has to get to this Point)
72    \li setSavePoint(): Sets a HotPoint into a savePoint. A Savepoint can be used as a rollbackpoint if a Player gets shot.
73
74    HotPoints and Joins are at the beginning of a TrackElement. \n
75    SavePoints and Forks are at the end of a TrackElement \n
76    look out: <b>SAVEPOINTS CAN NOT BE FORKS</b> (but joins), because the condition is really hard to guess if you do not give some impuls. \n
77\n
78   <b> 2. Runtime knows the following: </b>
79    \li calcPos(): returns the current position on the track
80    \li calcDir(): returns the current Direction the track is flying on.
81    \li tick(): makes a Step on the Path. increases localTime by dt.
82    \li choosePath(): a Function that decides which Path we should follow.
83   
84   TrackManager can be handled as a StateMachine.
85   \n\n
86    Names:
87    \li TrackManager: handles Tracks
88    \li Track:        The Track that the ship can follow
89    \li Path:         one way through the Level, that is dependent on conditionals.
90    \li Conditional:  A decition making device, that chooses betwen different TrackElements for the Path.
91    \li TrackElement: A Part of A whole Track
92*/
93class TrackManager : public BaseObject
94{
95 private:
96  TrackManager(void);
97
98  static TrackManager* singletonRef;  //!< There may only be one TrackManager existing.
99  TrackElement* firstTrackElem;       //!< The first TrackElement that exists.
100  TrackElement* currentTrackElem;     //!< The TrackElement we are working on.
101  float localTime;                    //!< The time that has been passed since the traveling the Track.
102  float maxTime;                      //!< The maximal time the track has.
103  int trackElemCount;                 //!< The count of TrackElements that exist.
104 
105
106  TrackElement* findTrackElementByID(unsigned int trackID) const;
107
108 public:
109  ~TrackManager(void);
110  static TrackManager* getInstance(void);
111
112  // Methods to change the Path (initialisation)
113  void workOn(unsigned int trackID);
114  void setCurveType(CurveType curveType);
115  void setDuration(float time);
116  bool addPoint(Vector newPoint);
117  int addHotPoint(Vector newPoint);
118  int setSavePoint(void);
119  void fork(unsigned int count, ...);
120  void forkV(unsigned int count, int* trackIDs);
121  void condition(unsigned int groupID, PathCondition cond); //!< \todo really do this!!
122  void join(unsigned int count, ...);
123  void joinV(unsigned int count, int* trackIDs);
124
125  // Methods to calculate the position on the Path (runtime)
126  Vector calcPos(void) const;
127  Vector calcDir(void) const;
128  void tick(float dt);
129  void jumpTo(float time);
130  void choosePath(int graphID);
131
132};
133
134#endif /* _TRACK_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.