Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3837 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Apr 15, 2005, 6:10:45 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: some more

Location:
orxonox/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/track_manager.cc

    r3836 r3837  
    452452  if (childCount == 1)
    453453    trackElem->getChild(0)->setName(trackElem->getName());
     454
     455  // select the first Child to work on.
     456  this->currentTrackElem = trackElem->getChild(0);
    454457}
    455458
     
    558561  trackElem->curve->addNode(newPoint);
    559562  trackElem->nodeCount++;
    560   this->initChildren(1);
    561   this->currentTrackElem = this->currentTrackElem->getChild(0);
     563  this->initChildren(1, trackElem);
    562564}
    563565
    564566/**
    565567   \brief Sets the last HotPoint into a savePoint.
     568   \param trackElem The TrackElement to appy this to. (if NULL chose this->currentTrackElement)
    566569   \returns A Pointer to a newly appended Curve
    567    
     570
    568571   If no HotPoint was defined the last added Point will be rendered into a savePoint. \n
    569572   If the HotPoint was defined as a fork the Point will \b not be set into a savePoint.
    570573*/
    571 int TrackManager::setSavePoint(void)
    572 {
     574int TrackManager::setSavePoint(TrackElement* trackElem)
     575{
     576  if (!trackElem)
     577    trackElem = this->currentTrackElem;
     578
    573579  PRINTF(4)("setting up a SavePoint.\n");
    574   if (this->currentTrackElem->isFork || this->currentTrackElem->isSavePoint)
    575     {
    576       PRINTF(2)("%d is already finished \n", currentTrackElem->ID);
    577       return this->currentTrackElem->getChild(0)->ID;
    578     }
    579   this->currentTrackElem->isSavePoint = true;
    580   this->currentTrackElem->isHotPoint = true;
    581 
    582   this->initChildren(1);
    583   this->currentTrackElem = this->currentTrackElem->getChild(0);
     580  if (trackElem->isFork || trackElem->isSavePoint)
     581    {
     582      PRINTF(2)("%d is already finished \n", trackElem->ID);
     583      return trackElem->getChild(0)->ID;
     584    }
     585  trackElem->isSavePoint = true;
     586  trackElem->isHotPoint = true;
     587
     588  this->initChildren(1, trackElem);
    584589}
    585590
     
    609614   \param count The Count of childrens the current HotPoint will have.
    610615   \param trackIDs A Pointer to an Array of ints which will hold the trackID's (the user will have to reserve space for this).
    611 
    612    \see void TrackManager::fork(int count, ...)
    613 
    614    \todo initialisation is wrong!! also in setSavePoint.
    615 */
    616 void TrackManager::forkV(unsigned int count, int* trackIDs)
    617 {
     616   \param trackElem The TrackElement to appy this to. (if NULL chose this->currentTrackElement)
     617*/
     618void TrackManager::forkV(unsigned int count, int* trackIDs, TrackElement* trackElem)
     619{
     620  if (!trackElem)
     621    trackElem = this->currentTrackElem;
     622
    618623  PRINTF(4)("Forking with %d children\n", count);
    619   if (this->currentTrackElem->isSavePoint)
     624  if (trackElem->isSavePoint)
    620625    return;
    621   this->currentTrackElem->isFork = true;
    622   this->currentTrackElem->isHotPoint = true;
     626  trackElem->isFork = true;
     627  trackElem->isHotPoint = true;
    623628  for(int i = 0; i < count; i++)
    624629    trackIDs[i]=this->trackElemCount+1+i;
    625   this->initChildren(count);
     630  this->initChildren(count, trackElem);
     631}
     632
     633/**
     634   \brief decides under what condition a certain Path will be chosen.
     635   \param trackID the trackID to apply this to.
     636   \param cond the CONDITION of the decision
     637   \param subject the Subject that will be decided upon with CONDITION cond.
     638*/
     639void TrackManager::condition(unsigned int trackID, CONDITION cond, void* subject)
     640{
     641  this->condition(cond, subject, this->firstTrackElem->findByID(trackID));
    626642}
    627643
     
    630646   \param cond the CONDITION of the decision
    631647   \param subject the Subject that will be decided upon with CONDITION cond.
    632 */
    633 void TrackManager::condition(CONDITION cond, void* subject)
    634 {
    635   this->condition(this->currentTrackElem->ID, cond, subject);
    636 }
    637 /**
    638    \brief decides under what condition a certain Path will be chosen.
    639    \param groupID the ID on which to choose the preceding move
    640    \param cond the CONDITION of the decision
    641    \param subject the Subject that will be decided upon with CONDITION cond.
    642 */
    643 void TrackManager::condition(unsigned int groupID, CONDITION cond, void* subject)
    644 {
    645   TrackElement* tmpElem = this->firstTrackElem->findByID(groupID);
    646   if (!tmpElem->isFork)
    647     {
    648       PRINTF(2)("%d is not a Fork, and no condition can be set in this case\n", tmpElem->ID);
     648   \param trackElem The TrackElement to appy this to. (if NULL chose this->currentTrackElement)
     649*/
     650void TrackManager::condition(CONDITION cond, void* subject, TrackElement* trackElem)
     651{
     652  if (!trackElem)
     653    trackElem = this->currentTrackElem;
     654
     655  if (!trackElem->isFork)
     656    {
     657      PRINTF(2)("%d is not a Fork, and no condition can be set in this case\n", trackElem->ID);
    649658      return;
    650659    }
     
    654663        {
    655664        case LOWEST:
    656           tmpElem->condFunc = &TrackElement::lowest;
     665          trackElem->condFunc = &TrackElement::lowest;
    657666          break;
    658667        case HIGHEST:
    659           tmpElem->condFunc = &TrackElement::highest;
     668          trackElem->condFunc = &TrackElement::highest;
    660669          break;
    661670        case RANDOM:
    662           tmpElem->condFunc = &TrackElement::random;
     671          trackElem->condFunc = &TrackElement::random;
    663672          break;
    664673        case LEFTRIGHT:
    665           tmpElem->condFunc = &TrackElement::leftRight;
     674          trackElem->condFunc = &TrackElement::leftRight;
    666675          break;
    667676        case NEAREST:
    668           tmpElem->condFunc = &TrackElement::nearest;
     677          trackElem->condFunc = &TrackElement::nearest;
    669678          break;
    670679        case ENEMYKILLED:
    671680          break;
    672681        }
    673       tmpElem->subject=subject;
     682      trackElem->subject=subject;
    674683    }
    675684}
  • orxonox/trunk/src/track_manager.h

    r3836 r3837  
    156156  bool addPoint(Vector newPoint, TrackElement* trackElem = NULL);
    157157  int addHotPoint(Vector newPoint, TrackElement* trackElem = NULL);
    158   int setSavePoint(void);
     158  int setSavePoint(TrackElement* trackElem = NULL);
    159159  void fork(unsigned int count, ...);
    160   void forkV(unsigned int count, int* trackIDs);
    161   void condition(CONDITION cond, void* subject);
    162   void condition(unsigned int groupID, CONDITION cond, void* subject);
     160  void forkV(unsigned int count, int* trackIDs, TrackElement* trackElem = NULL);
     161  void condition(unsigned int trackID, CONDITION cond, void* subject);
     162  void condition(CONDITION cond, void* subject, TrackElement* trackElem = NULL);
    163163  void join(unsigned int count, ...);
    164164  void joinV(unsigned int count, int* trackIDs);
Note: See TracChangeset for help on using the changeset viewer.