Changeset 3348 in orxonox.OLD for orxonox/branches/parenting/src/track_manager.cc
- Timestamp:
- Jan 6, 2005, 3:03:54 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/parenting/src/track_manager.cc
r3335 r3348 35 35 this->ID = -1; 36 36 this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager. 37 this->duration = 0;37 this->duration = 1; 38 38 this->curveType = BEZIERCURVE; 39 39 this->nodeCount = 0; 40 childCount = 0;40 this->childCount = 0; 41 41 this->name = NULL; 42 42 this->curve = NULL; … … 102 102 103 103 PRINTF(3)("Initializing the TrackManager\n"); 104 this->firstTrackElem = new TrackElement; 104 this->firstTrackElem = new TrackElement(); 105 this->firstTrackElem->ID = 1; 105 106 this->currentTrackElem = firstTrackElem; 106 107 this->localTime = 0; 107 108 this->maxTime = 0; 108 this->trackElemCount = 0;109 this->trackElemCount = 1; 109 110 } 110 111 … … 146 147 void TrackManager::initChildren(unsigned int childCount) 147 148 { 148 trackElemCount = 0;149 149 this->currentTrackElem->childCount = childCount; 150 150 this->currentTrackElem->children = new TrackElement*[childCount]; 151 151 for (int i=0; i<childCount; i++) 152 this->currentTrackElem->children[i] = new TrackElement(); 152 { 153 this->currentTrackElem->children[i] = new TrackElement(); 154 this->currentTrackElem->children[i]->ID = ++trackElemCount; 155 this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->startingTime+this->currentTrackElem->duration; 156 } 153 157 } 154 158 … … 252 256 253 257 this->initChildren(1); 258 this->currentTrackElem = this->currentTrackElem->children[0]; 254 259 } 255 260 … … 344 349 Vector TrackManager::calcPos() const 345 350 { 346 return this->currentTrackElem->curve->calcPos(this->localTime); 351 // PRINTF(0)("TrackElement:%d, localTime: %f\n",this->currentTrackElem->ID, this->localTime); 352 return this->currentTrackElem->curve->calcPos((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration); 347 353 } 348 354 … … 353 359 Vector TrackManager::calcDir() const 354 360 { 355 return this->currentTrackElem->curve->calcDir( this->localTime);361 return this->currentTrackElem->curve->calcDir((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration); 356 362 } 357 363 … … 364 370 void TrackManager::tick(float dt) 365 371 { 372 if (this->localTime <= this->firstTrackElem->duration) 373 this->jumpTo(this->localTime); 366 374 this->localTime += dt; 375 if (this->localTime > this->currentTrackElem->startingTime + this->currentTrackElem->duration && this->currentTrackElem->childCount > 0) 376 this->currentTrackElem = this->currentTrackElem->children[0]; 367 377 } 368 378 … … 376 386 void TrackManager::jumpTo(float time) 377 387 { 378 localTime = time; 388 if (time == 0) 389 this->currentTrackElem = this->firstTrackElem; 390 this->localTime = time; 379 391 } 380 392
Note: See TracChangeset
for help on using the changeset viewer.