Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3333 in orxonox.OLD


Ignore:
Timestamp:
Jan 5, 2005, 12:53:42 AM (19 years ago)
Author:
bensch
Message:

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

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

Legend:

Unmodified
Added
Removed
  • orxonox/branches/parenting/src/track_manager.cc

    r3332 r3333  
    3434  this->cond; //!< todo think!!
    3535  this->ID = -1;
    36   this->length =0;
     36  this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager.
     37  this->duration =0;
    3738  this->curveType = BEZIERCURVE;
    3839  this->nodeCount = 0;
     
    5859        delete this->children[i];
    5960    }
     61  if (children)
     62    delete children;
     63}
     64
     65/**
     66   \brief reserves Space for childCount children
     67   \param childCount The Count of children to make space for.
     68*/
     69void TrackElement::initChildren(unsigned int childCount)
     70{
     71  this->childCount = childCount;
     72  this->children = new TrackElement*[childCount];
     73  for (int i=0; i<childCount; i++)
     74    this->children[i] = new TrackElement();
    6075}
    6176
     
    183198
    184199/**
    185    \brief Sets the length of the current path in seconds.
    186    \param time The length in seconds.
    187 */
    188 
    189 void TrackManager::setLength(float time)
    190 {
    191   this->currentTrackElem->length = time;
     200   \brief Sets the duration of the current path in seconds.
     201   \param time The duration in seconds.
     202*/
     203
     204void TrackManager::setDuration(float time)
     205{
     206  this->currentTrackElem->duration = time;
    192207}
    193208
     
    196211   \param newPoint The point to add.
    197212*/
    198 void TrackManager::addPoint(Vector newPoint)
     213bool TrackManager::addPoint(Vector newPoint)
    199214{
    200215  if (this->currentTrackElem->isFresh)
     
    209224   \brief adds save/splitpoint.
    210225   \param newPoint The point to add.
    211 */
    212 void TrackManager::addHotPoint(Vector newPoint)
     226   \returns A Pointer to a newly appended Curve
     227*/
     228int TrackManager::addHotPoint(Vector newPoint)
    213229{
    214230  if (this->currentTrackElem->isFresh)
     
    224240/**
    225241   \brief Sets the last HotPoint into a savePoint.
     242   \returns A Pointer to a newly appended Curve
    226243   
    227244   If no HotPoint was defined the last added Point will be rendered into a savePoint. \n
    228245   If the HotPoint was defined as a fork the Point will \b not be set into a savePoint.
    229246*/
    230 void TrackManager::setSavePoint(void)
     247int TrackManager::setSavePoint(void)
    231248{
    232249  if (this->currentTrackElem->isFork || this->currentTrackElem->isSavePoint)
    233     return;
     250    return this->currentTrackElem->children[1]->ID;
    234251  this->currentTrackElem->isSavePoint = true;
    235252
    236   this->currentTrackElem->children = new TrackElement*[1];
     253  this->currentTrackElem->initChildren(1);
    237254}
    238255
     
    273290  this->currentTrackElem->isFork = true;
    274291
    275   this->currentTrackElem->children = new TrackElement*[count];
     292  this->currentTrackElem->initChildren(count);
    276293}
    277294
     
    327344Vector TrackManager::calcPos() const
    328345{
    329  
     346  return this->currentTrackElem->curve->calcPos(this->localTime);
    330347}
    331348
     
    336353Vector TrackManager::calcDir() const
    337354{
    338 
     355  return this->currentTrackElem->curve->calcDir(this->localTime);
    339356}
    340357
     
    342359   \brief Advances the local-time of the Track around dt
    343360   \param dt The time about which to advance.
     361
     362   This function also checks, if the TrackElement has to be changed.
    344363*/
    345364void TrackManager::tick(float dt)
  • orxonox/branches/parenting/src/track_manager.h

    r3332 r3333  
    3333  ~TrackElement(void);
    3434
     35  void initChildren(unsigned int childCount);
     36
    3537  TrackElement* findByID(unsigned int trackID);
    3638
     
    4143  PathCondition cond;        //!< The Split Condition;
    4244  int ID;                    //!< The ID of this TrackElement
    43   float length;              //!< The time usedto cross this TrackElement (curve).
     45  float startingTime;        //!< The time at which this Track begins.
     46  float duration;            //!< The time used to cross this TrackElement (curve).
    4447  CurveType curveType;       //!< The CurveType this will have.
    4548  int nodeCount;             //!< The count of points this TrackElement has.
     
    6164    \li workOn(): changes the ID that will be altered through the changes.
    6265    \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.
     66    \li setDuration(): sets the length of the current path in seconds.
    6467    \li addPoint(): adds a point to the Curve.
    6568    \li addHotPoint(): adds save/splitpoint.\n
     
    102105
    103106  TrackElement* findTrackElementByID(unsigned int trackID) const;
    104  
    105107
    106108 public:
     
    111113  void workOn(unsigned int trackID);
    112114  void setCurveType(CurveType curveType);
    113   void setLength(float time);
    114   void addPoint(Vector newPoint);
    115   void addHotPoint(Vector newPoint);
    116   void setSavePoint(void);
     115  void setDuration(float time);
     116  bool addPoint(Vector newPoint);
     117  int addHotPoint(Vector newPoint);
     118  int setSavePoint(void);
    117119  void fork(unsigned int count, ...);
    118120  void forkV(unsigned int count, int* trackIDs);
Note: See TracChangeset for help on using the changeset viewer.