Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3514 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Mar 12, 2005, 2:27:48 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/trackManager: constructed a simple pathChooser-module, with Method-function pointer… really fancy stuff

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

Legend:

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

    r3498 r3514  
    4747  this->curve = NULL;
    4848  this->children = NULL;
     49  this->condFunc = &TrackElement::random;
    4950}
    5051
     
    110111}
    111112
     113int TrackElement::lowest(void* nothing)
     114{
     115  return 0;
     116}
     117
     118int TrackElement::highest(void* nothing)
     119{
     120  return this->childCount-1;
     121}
     122
     123int 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}
    112136
    113137
     
    530554      && this->currentTrackElem->children)
    531555    {
    532       if (this->currentTrackElem->jumpTime > 0) 
     556      if (this->currentTrackElem->jumpTime > 0)
    533557        this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
    534       this->currentTrackElem = this->currentTrackElem->children[0];
     558      this->currentTrackElem = this->currentTrackElem->children[this->choosePath(this->currentTrackElem)];
    535559    }
    536560  if (this->bindSlave)
     
    559583/**
    560584   \brief a Function that decides which Path we should follow.
    561    \param graphID The Path to choose.
     585   \param trackElem The Path to choose.
    562586   
    563587*/
    564 void TrackManager::choosePath(int graphID)
    565 {
    566 
     588int TrackManager::choosePath(TrackElement* trackElem)
     589{
     590  return (trackElem->*(trackElem->condFunc))(NULL);
    567591}
    568592
  • orxonox/branches/trackManager/src/track_manager.h

    r3498 r3514  
    5656  int childCount;            //!< The number of Children This TrackElement has.
    5757  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);
    5865};
    5966
     
    137144  void tick(float dt);
    138145  void jumpTo(float time);
    139   void choosePath(int graphID);
     146  int choosePath(TrackElement* trackElem);
    140147
    141148  void setBindSlave(PNode* bindSlave);
Note: See TracChangeset for help on using the changeset viewer.