Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3331 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jan 4, 2005, 1:39:32 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/parenting: added some more functionality, and wrote the [con|de]structors

Location:
orxonox/branches/parenting/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/parenting/src/curve.h

    r3330 r3331  
    1313
    1414//! An Enumerator that defines what sort of Curves are availible
    15 enum CurveType {BEZIER, UPOINT};
     15enum CurveType {BEZIERCURVE, UPOINTCURVE};
    1616
    1717
  • orxonox/branches/parenting/src/track_manager.cc

    r3330 r3331  
    2222using namespace std;
    2323
     24/**
     25   \brief initializes a TrackElement (sets the default values)
     26*/
     27TrackElement::TrackElement(void)
     28{
     29  this->isSavePoint = false;
     30  this->isFork = false;
     31  this->isJoined = false;
     32  this->cond; //!< todo think!!
     33  this->ID = -1;
     34  this->length =0;
     35  this->curveType = BEZIERCURVE;
     36  this->nodeCount = 0;
     37  childCount = 0;
     38  this->curve = NULL;
     39  this->children = NULL;
     40}
     41
     42/**
     43    \destroys all alocated memory)
     44    \todo eventually when deleting a TrackElement you would not like to delete all its preceding TrackElements
     45*/
     46TrackElement::~TrackElement(void)
     47{
     48  if (this->curve)
     49    delete this->curve;
     50  if (this->childCount > 0)
     51    {
     52      for (int i=0; i < this->childCount; i++)
     53        delete this->children[i];
     54    }
     55}
     56
     57
     58
    2459
    2560/**
     
    3065TrackManager::TrackManager ()
    3166{
    32    this->setClassName ("TrackManager");
    33 }
    34 
    35 
    36 /**
    37    \brief standard deconstructor
     67  this->setClassName ("TrackManager");
     68
     69  PRINTF(3)("Initializing the TrackManager\n");
     70  this->firstTrackElem = NULL;
     71  this->currentTrackElem = firstTrackElem;
     72  this->localTime = 0;
     73  this->maxTime = 0;
     74  this->trackElemCount = 0;
     75}
     76
     77
     78/**
     79   \brief standard destructor
    3880
    3981   \todo this deconstructor is not jet implemented - do it
     
    4183TrackManager::~TrackManager ()
    4284{
    43 
     85  PRINTF(3)("Destruct TrackManager\n");
     86
     87  PRINTF(3)("Deleting all the TrackElements\n");
     88  delete this->firstTrackElem;
     89  // we do not have a TrackManager anymore
     90  singletonRef = NULL;
     91}
     92
     93TrackManager* TrackManager::singletonRef = NULL;
     94
     95/**
     96   \returns The reference on the TrackManager.
     97
     98   If the TrackManager does not exist, it will be created.
     99*/
     100TrackManager* TrackManager::getInstance(void)
     101{
     102  if (singletonRef)
     103    return singletonRef;
     104  else
     105    return singletonRef = new TrackManager();
    44106}
    45107
     
    201263
    202264/**
     265   \brief Jumps to a certain point on the Track.
     266   \param time The time on the Track to jump to.
     267
     268   This should be used to Jump backwards on a Track, because moving forward means to change between the Path. (it then tries to choose the default.)
     269   Max is trackLengthMax.
     270*/
     271void TrackManager::jumpTo(float time)
     272{
     273
     274}
     275
     276/**
    203277   \brief a Function that decides which Path we should follow.
    204278   \param graphID The Path to choose.
  • orxonox/branches/parenting/src/track_manager.h

    r3330 r3331  
    1313
    1414#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  bool isSavePoint;          //!< If the first node is a savePoint
     36  bool isFork;               //!< If the first node is a Fork
     37  bool isJoined;             //!< If the End of the Curve is joined.
     38  PathCondition cond;        //!< The Split Condition;
     39  int ID;                    //!< The ID of this TrackElement
     40  float length;              //!< The time usedto cross this TrackElement (curve).
     41  CurveType curveType;       //!< The CurveType this will have.
     42  int nodeCount;             //!< The count of points this TrackElement has.
     43  Curve* curve;              //!< The Curve of this TrackElement
     44  int childCount;            //!< The number of Children This TrackElement has.
     45  TrackElement** children;   //!< A TrackElement can have a Tree of following TrackElements.
     46};
     47
    1548
    1649
     
    4275   
    4376   TrackManager can be handled as a StateMachine.
     77   \n\n
     78    Names:
     79    \li TrackManager: handles Tracks
     80    \li Track:        The Track that the ship can follow
     81    \li Path:         one way through the Level, that is dependent on conditionals.
     82    \li Conditional:  A decition making device, that chooses betwen different TrackElements for the Path.
     83    \li TrackElement: A Part of A whole Track
    4484*/
    45 class TrackManager : public BaseObject {
     85class TrackManager : public BaseObject
     86{
    4687 private:
    47   //! condition for choosing a certain Path. \todo implement a useful way.
    48   struct PathCondition
    49   {
    50    
    51   };
     88  TrackManager(void);
     89
     90  static TrackManager* singletonRef;  //!< There may only be one TrackManager existing.
     91  TrackElement* firstTrackElem;       //!< The first TrackElement that exists.
     92  TrackElement* currentTrackElem;       //!< The TrackElement we are working on.
     93  float localTime;                    //!< The time that has been passed since the traveling the Track.
     94  float maxTime;                      //!< The maximal time the track has.
     95  int trackElemCount;                 //!< The count of TrackElements that exist.
    5296 
    53   //! A Graph, that holds the curve-structure of a Level.
    54   /**
    55      A CurveGraph is used, to Define the structure of the Track itself.
    56      It is a graph and not a tree, because paths can fork and join again.
    57   */
    58   struct TrackElement
    59   {
    60     bool isSavePoint;          //!< If the first node is a savePoint
    61     bool isFork;               //!< If the first node is a Fork
    62     bool isJoined;             //!< If the End of the Curve is joined.
    63     PathCondition cond;        //!< The Split Condition;
    64     int ID;                    //!< The ID of this TrackElement
    65     float length;              //!< The time usedto cross this TrackElement (curve).
    66     CurveType curveType;       //!< The CurveType this will have.
    67     int nodeCount;             //!< The count of points this TrackElement has.
    68     Curve* curve;              //!< The Curve of this TrackElement
    69     TrackElement** children;   //!< A TrackElement can have a Tree of following TrackElements.
    70   };
    7197
    72 
    73   TrackElement* firstGraph;    //!< The first Graph-element we are on.
    74   TrackElement* currentGraph;  //!< The Graph-element we are working on.
    75   float localTime;             //!< The time that has been passed since the traveling the Track.
    76   int trackElementCount;       //!< The count of TrackElements that exist.
     98  TrackElement findTrackElementByID(int trackID);
    7799 
    78   TrackElement findTrackElementByID(int trackID);
    79100
    80101 public:
    81   TrackManager ();
    82   ~TrackManager ();
     102  ~TrackManager(void);
     103  static TrackManager* getInstance(void);
    83104
    84105  // Methods to change the Path (initialisation)
     
    99120  Vector calcDir();
    100121  void tick(float dt);
     122  void jumpTo(float time);
    101123  void choosePath(int graphID);
    102124
Note: See TracChangeset for help on using the changeset viewer.