Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3332 was 3332, checked in by bensch, 20 years ago

orxonox/branches/parenting: TrackManager: wrote raw material for most Functions. It compiles, but there still is a lot to do.

  1. Forking and Joining.
  2. Initialisation of TrackElement
  3. Condition
  4. much more
File size: 5.2 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  TrackElement* findByID(unsigned int trackID);
36
37  bool isFresh;              //!< If no Points where added until now
38  bool isSavePoint;          //!< If the first node is a savePoint
39  bool isFork;               //!< If the first node is a Fork
40  bool isJoined;             //!< If the End of the Curve is joined.
41  PathCondition cond;        //!< The Split Condition;
42  int ID;                    //!< The ID of this TrackElement
43  float length;              //!< The time usedto cross this TrackElement (curve).
44  CurveType curveType;       //!< The CurveType this will have.
45  int nodeCount;             //!< The count of points this TrackElement has.
46  char* name;                //!< A name for the Trac.
47  Curve* curve;              //!< The Curve of this TrackElement
48  int childCount;            //!< The number of Children This TrackElement has.
49  TrackElement** children;   //!< A TrackElement can have a Tree of following TrackElements.
50};
51
52
53
54//! The TrackManager handles the flow of the Players through the game.
55/**
56   \todo write the methodes
57
58   <b>The TrackManager works as followed:</b> \n
59     \n
60   <b>1. Initialize it, by setting up the Graph. You can do this by using the following Commands.</b>
61    \li workOn(): changes the ID that will be altered through the changes.
62    \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).
63    \li setLength(): sets the length of the current path in seconds.
64    \li addPoint(): adds a point to the Curve.
65    \li addHotPoint(): adds save/splitpoint.\n
66    \li fork(): adds some interessting non-linear movments through the level (fork will force addHotPoint if not done then).
67    \li condition(): decides under what condition a certain Path will be chosen.
68    \li join(): joins some tracks together again. Join will set the localTime to the longest time a Path has to get to this Point)
69    \li setSavePoint(): Sets a HotPoint into a savePoint. A Savepoint can be used as a rollbackpoint if a Player gets shot.
70
71    HotPoints and Joins are at the beginning of a TrackElement. \n
72    SavePoints and Forks are at the end of a TrackElement \n
73    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
74\n
75   <b> 2. Runtime knows the following: </b>
76    \li calcPos(): returns the current position on the track
77    \li calcDir(): returns the current Direction the track is flying on.
78    \li tick(): makes a Step on the Path. increases localTime by dt.
79    \li choosePath(): a Function that decides which Path we should follow.
80   
81   TrackManager can be handled as a StateMachine.
82   \n\n
83    Names:
84    \li TrackManager: handles Tracks
85    \li Track:        The Track that the ship can follow
86    \li Path:         one way through the Level, that is dependent on conditionals.
87    \li Conditional:  A decition making device, that chooses betwen different TrackElements for the Path.
88    \li TrackElement: A Part of A whole Track
89*/
90class TrackManager : public BaseObject
91{
92 private:
93  TrackManager(void);
94
95  static TrackManager* singletonRef;  //!< There may only be one TrackManager existing.
96  TrackElement* firstTrackElem;       //!< The first TrackElement that exists.
97  TrackElement* currentTrackElem;     //!< The TrackElement we are working on.
98  float localTime;                    //!< The time that has been passed since the traveling the Track.
99  float maxTime;                      //!< The maximal time the track has.
100  int trackElemCount;                 //!< The count of TrackElements that exist.
101 
102
103  TrackElement* findTrackElementByID(unsigned int trackID) const;
104 
105
106 public:
107  ~TrackManager(void);
108  static TrackManager* getInstance(void);
109
110  // Methods to change the Path (initialisation)
111  void workOn(unsigned int trackID);
112  void setCurveType(CurveType curveType);
113  void setLength(float time);
114  void addPoint(Vector newPoint);
115  void addHotPoint(Vector newPoint);
116  void setSavePoint(void);
117  void fork(unsigned int count, ...);
118  void forkV(unsigned int count, int* trackIDs);
119  void condition(unsigned int groupID, PathCondition cond); //!< \todo really do this!!
120  void join(unsigned int count, ...);
121  void joinV(unsigned int count, int* trackIDs);
122
123  // Methods to calculate the position on the Path (runtime)
124  Vector calcPos(void) const;
125  Vector calcDir(void) const;
126  void tick(float dt);
127  void jumpTo(float time);
128  void choosePath(int graphID);
129
130};
131
132#endif /* _TRACK_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.