Changeset 3514 in orxonox.OLD for orxonox/branches
- Timestamp:
- Mar 12, 2005, 2:27:48 AM (20 years ago)
- Location:
- orxonox/branches/trackManager/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/trackManager/src/track_manager.cc
r3498 r3514 47 47 this->curve = NULL; 48 48 this->children = NULL; 49 this->condFunc = &TrackElement::random; 49 50 } 50 51 … … 110 111 } 111 112 113 int TrackElement::lowest(void* nothing) 114 { 115 return 0; 116 } 117 118 int TrackElement::highest(void* nothing) 119 { 120 return this->childCount-1; 121 } 122 123 int TrackElement::random(void* nothing) 124 { 125 if (this->childCount == 0) 126 return 0; 127 else 128 { 129 int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount); 130 if (i >= this->childCount) 131 return this->childCount-1; 132 else 133 return i; 134 } 135 } 112 136 113 137 … … 530 554 && this->currentTrackElem->children) 531 555 { 532 if (this->currentTrackElem->jumpTime > 0) 556 if (this->currentTrackElem->jumpTime > 0) 533 557 this->jumpTo(this->localTime + this->currentTrackElem->jumpTime); 534 this->currentTrackElem = this->currentTrackElem->children[ 0];558 this->currentTrackElem = this->currentTrackElem->children[this->choosePath(this->currentTrackElem)]; 535 559 } 536 560 if (this->bindSlave) … … 559 583 /** 560 584 \brief a Function that decides which Path we should follow. 561 \param graphIDThe Path to choose.585 \param trackElem The Path to choose. 562 586 563 587 */ 564 void TrackManager::choosePath(int graphID)565 { 566 588 int TrackManager::choosePath(TrackElement* trackElem) 589 { 590 return (trackElem->*(trackElem->condFunc))(NULL); 567 591 } 568 592 -
orxonox/branches/trackManager/src/track_manager.h
r3498 r3514 56 56 int childCount; //!< The number of Children This TrackElement has. 57 57 TrackElement** children; //!< A TrackElement can have a Tree of following TrackElements. 58 59 // CONDITION FUNCTIONS 60 int (TrackElement::*condFunc)(void*); //!< Pointer to the condition function 61 62 int lowest(void* nothing); 63 int highest(void* nothing); 64 int random(void* nothing); 58 65 }; 59 66 … … 137 144 void tick(float dt); 138 145 void jumpTo(float time); 139 void choosePath(int graphID);146 int choosePath(TrackElement* trackElem); 140 147 141 148 void setBindSlave(PNode* bindSlave);
Note: See TracChangeset
for help on using the changeset viewer.