Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3515 in orxonox.OLD for orxonox/branches/trackManager


Ignore:
Timestamp:
Mar 12, 2005, 3:11:30 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/trackManager: now ability to set LEFT-RIGHT decision for nodes

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

Legend:

Unmodified
Added
Removed
  • orxonox/branches/trackManager/src/story_entities/world.cc

    r3505 r3515  
    240240
    241241            trackManager->setBindSlave(TrackNode::getInstance());
     242            trackManager->condition(3, LEFTRIGHT, myPlayer);
    242243            TrackNode::getInstance()->addChild(myPlayer);
    243244            TrackNode::getInstance()->addChild(localCamera);
  • orxonox/branches/trackManager/src/track_manager.cc

    r3514 r3515  
    123123int TrackElement::random(void* nothing)
    124124{
    125   if (this->childCount == 0)
     125  int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount);
     126  if (i >= this->childCount)
     127    return this->childCount-1;
     128  else
     129    return i;
     130}
     131
     132
     133int TrackElement::leftRight(void* node)
     134{
     135  PNode* tmpNode = (PNode*)node;
     136
     137  if (tmpNode->relCoordinate.z < 0)
    126138    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 }
     139  else
     140    return 1;
     141}
     142
     143
     144// todo
     145int TrackElement::nearest(void* node)
     146{
     147  PNode* tmpNode = (PNode*)node;
     148
     149  Vector nodeRelCoord = tmpNode->relCoordinate;
     150
     151  if (nodeRelCoord.z < 0)
     152    return 0;
     153  else
     154    return 1;
     155}
     156
    136157
    137158
     
    376397/**
    377398   \brief decides under what condition a certain Path will be chosen.
     399   \param cond the CONDITION of the decision
     400   \param subject the Subject that will be decided upon with CONDITION cond.
     401*/
     402void TrackManager::condition(CONDITION cond, void* subject)
     403{
     404  this->condition(this->currentTrackElem->ID, cond, subject);
     405}
     406/**
     407   \brief decides under what condition a certain Path will be chosen.
    378408   \param groupID the ID on which to choose the preceding move
    379    \param cond \todo think about this
    380 */
    381 void TrackManager::condition(unsigned int groupID, PathCondition cond)
    382 {
     409   \param cond the CONDITION of the decision
     410   \param subject the Subject that will be decided upon with CONDITION cond.
     411*/
     412void TrackManager::condition(unsigned int groupID, CONDITION cond, void* subject)
     413{
     414  TrackElement* tmpElem = this->findTrackElementByID(groupID);
    383415 
    384 }
     416  switch (cond)
     417    {
     418    case LOWEST:
     419      tmpElem->condFunc = &TrackElement::lowest;
     420      break;
     421    case HIGHEST:
     422      tmpElem->condFunc = &TrackElement::highest;
     423      break;
     424    case RANDOM:
     425      tmpElem->condFunc = &TrackElement::random;
     426      break;
     427    case LEFTRIGHT:
     428      tmpElem->condFunc = &TrackElement::leftRight;
     429      break;
     430    case NEAREST:
     431      tmpElem->condFunc = &TrackElement::nearest;
     432      break;
     433    case ENEMYKILLED:
     434      break;
     435    default: // same as LOWEST
     436      tmpElem->condFunc = &TrackElement::lowest;
     437      break;
     438    }
     439  tmpElem->subject=subject;
     440}
     441
    385442
    386443/**
     
    588645int TrackManager::choosePath(TrackElement* trackElem)
    589646{
    590   return (trackElem->*(trackElem->condFunc))(NULL);
     647  return (trackElem->*(trackElem->condFunc))(trackElem->subject);
    591648}
    592649
  • orxonox/branches/trackManager/src/track_manager.h

    r3514 r3515  
    5757  TrackElement** children;   //!< A TrackElement can have a Tree of following TrackElements.
    5858
    59   // CONDITION FUNCTIONS
     59  // CONDITION FUNCTIONS and STUFF
     60  void* subject;             //!< The Subject the Condition should act upon.
    6061  int (TrackElement::*condFunc)(void*); //!< Pointer to the condition function
    6162
     
    6364  int highest(void* nothing);
    6465  int random(void* nothing);
     66
     67  int leftRight(void* node);
     68  int nearest(void* node);
     69  int enemyKilled(void* entity);
    6570};
    6671
    67 
     72enum CONDITION {LOWEST, HIGHEST, RANDOM, LEFTRIGHT, NEAREST, ENEMYKILLED};
    6873
    6974//! The TrackManager handles the flow of the Players through the game.
     
    134139  void fork(unsigned int count, ...);
    135140  void forkV(unsigned int count, int* trackIDs);
    136   void condition(unsigned int groupID, PathCondition cond); //!< \todo really do this!!
     141  void condition(CONDITION cond, void* subject);
     142  void condition(unsigned int groupID, CONDITION cond, void* subject); //!< \todo really do this!!
    137143  void join(unsigned int count, ...);
    138144  void joinV(unsigned int count, int* trackIDs);
Note: See TracChangeset for help on using the changeset viewer.