Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 18, 2005, 11:52:15 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged trunk back to levelloader
merged with command:
svn merge -r 3499:HEAD trunk branches/levelloader

Conflicts in
C track_manager.h
C world_entities/player.cc
C world_entities/player.h
C world_entities/environment.h
C lib/coord/p_node.cc
C defs/debug.h
C track_manager.cc
C story_entities/campaign.h

solved in merge-favouring. It was quite easy because Chris only worked on the headers, and he didi it quite clean. Thats the spirit :)

Conflits in world.cc are a MESS: fix it

File:
1 edited

Legend:

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

    r3562 r3605  
    1414*/
    1515
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_TRACK_MANAGER
    1617
    1718#include "track_manager.h"
     
    1920#include "p_node.h"
    2021#include "substring.h"
     22
     23#include "track_node.h"
    2124
    2225#include <stdarg.h>
     
    3538  this->isJoined = false;
    3639  this->mainJoin = false;
    37   this->cond; //!< todo think!!
    3840  this->ID = -1;
    39   this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager.
    40   this->duration = 1;
     41  this->startingTime = 0;
     42  this->duration = TMAN_DEFAULT_DURATION;
    4143  this->endTime = 1;
    4244  this->jumpTime = 0;
    43   this->curveType = BEZIERCURVE;
     45  this->width = TMAN_DEFAULT_WIDTH;
    4446  this->nodeCount = 0;
    4547  this->childCount = 0;
     
    4749  this->curve = NULL;
    4850  this->children = NULL;
     51
     52  this->history = NULL;
     53
     54  this->condFunc = &TrackElement::random;
    4955}
    5056
     
    6167  if ((!this->isJoined &&this->childCount > 0) || (this->isJoined && this->mainJoin))
    6268    {
    63       for (int i=0; i < this->childCount; i++)
    64         delete this->children[i];
     69      TrackElement* enumElem = children->enumerate();
     70      while (enumElem)
     71        {
     72          delete enumElem;
     73          enumElem = children->nextElement();
     74        }
    6575      delete this->children;
    6676    }
     
    8191  // search on.
    8292  if (this->childCount > 0)
    83     for (int i=0; i < this->childCount; i++)
    84       {
    85         TrackElement* tmpElem;
    86         if ((tmpElem = this->children[i]->findByID(trackID)))
    87           return tmpElem;
    88       }
    89   else return NULL;
    90 }
    91 
    92 /**
    93    \brief Sets the name of this TrackElement
    94    \param trackName The new name for this element
    95 */
    96 void TrackElement::setName(const char* trackName)
    97 {
    98         if( this->name != NULL) delete this->name;
    99        
    100         this->name = new char[strlen(trackName) + 1];
    101         strcpy( this->name, trackName);
     93    {
     94      TrackElement* enumElem = this->children->enumerate();
     95      TrackElement* tmpElem;
     96      while (enumElem)
     97        {
     98          if ((tmpElem = enumElem->findByID(trackID)))
     99            return tmpElem;
     100          enumElem = this->children->nextElement();
     101        }
     102    }
     103  else
     104    return NULL;
    102105}
    103106
     
    116119  // search on.
    117120  if (this->childCount > 0)
    118     for (int i=0; i < this->childCount; i++)
    119       {
    120         TrackElement* tmpElem;
    121         if ((tmpElem = this->children[i]->findByName(trackName)))
    122           return tmpElem;
    123       }
    124   else return NULL;
    125 }
    126 
    127 
    128 
    129 
    130 /////////////////////////////////////
    131 ///// TRACKMANAGER //////////////////
    132 /////////////////////////////////////
     121    {
     122   
     123      TrackElement* enumElem = this->children->enumerate();
     124      TrackElement* tmpElem;
     125      while (enumElem)
     126        {
     127          if ((tmpElem = enumElem->findByName(trackName)))
     128            return tmpElem;
     129          enumElem = this->children->nextElement();
     130        }
     131    }
     132  else
     133    return NULL;
     134}
     135
     136/**
     137   \brief checks if there are any BackLoops in the Track
     138   \param trackElem the trackElement to check about
     139   it simply does this by looking if the current trackElem is found again somewhere else in the Track
     140*/
     141bool TrackElement::backLoopCheck(TrackElement* trackElem)
     142{
     143  if (this->childCount == 0)
     144    return true;
     145  else
     146    {
     147      TrackElement* enumElem = this->children->enumerate();
     148      while (enumElem)
     149        {
     150          if(!enumElem->backLoopCheck(trackElem))
     151            return false;
     152          enumElem = this->children->nextElement();
     153        }
     154     
     155      return true;
     156    }
     157}
     158
     159/**
     160   \param childNumber which child to return
     161   \returns the n-the children (starting at 0)
     162*/
     163TrackElement* TrackElement::getChild(int childCount)
     164{
     165  if (this->childCount == 0)
     166    return NULL;
     167  if (childCount > this->childCount)
     168    childCount = this->childCount;
     169 
     170  TrackElement* enumElem = this->children->enumerate();
     171  for (int i = 0; i < childCount; i++)
     172    enumElem = this->children->nextElement();
     173  return enumElem;
     174}
     175
     176/**
     177   \param name the Name to set.
     178*/
     179void TrackElement::setName(const char* name)
     180{
     181  //  delete the old name
     182  if (this->name)
     183    delete []this->name;
     184  // if a name was given already.
     185  if (name)
     186    {
     187      this->name = new char[strlen(name)+1];
     188      strcpy(this->name, name);
     189    }
     190  else
     191    this->name = NULL;
     192}
     193
     194/**
     195   \returns The name of this TrackElement
     196*/
     197char* TrackElement::getName(void) const
     198{
     199  return this->name;
     200}
     201
     202/**
     203   \brief prints out debug information about this TrackElement
     204*/
     205void TrackElement::debug(void)
     206{
     207  PRINT(0)("--== TrackElement:%i ==--", this->ID);
     208  if(this->getName())
     209    PRINT(0)("Name: %s::", this->getName());
     210  if(this->isFresh)
     211    PRINT(0)("  -- has not jet eddited in any way --\n");
     212  PRINT(0)("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", this->startingTime, this->endTime, this->duration, this->jumpTime);
     213  PRINT(0)("   consists of %d Points\n", this->nodeCount);
     214  if (this->childCount == 0)
     215    PRINT(0)("   has no child\n");
     216  else if (this->childCount == 1)
     217    PRINT(0)("   has 1 child: =%d=\n", this->getChild(0)->ID);
     218  else if (this->childCount > 1)
     219    {
     220      PRINT(0)("   has %d children: ", this->childCount);
     221      TrackElement* enumElem = this->children->enumerate();
     222      while (enumElem)
     223        {
     224          PRINT(0)("=%d= ", enumElem->ID);
     225          enumElem = this->children->nextElement();
     226        }
     227      PRINT(0)("\n");
     228    }
     229 
     230  if(this->isHotPoint)
     231    PRINT(0)("   is a special Point:\n");
     232  if(this->isSavePoint)
     233    PRINT(0)("    is a SavePoint\n");
     234  if(this->isFork)
     235    {
     236      PRINT(0)("    is A Fork with with %d children.\n", this->childCount);
     237    }
     238  if(this->isJoined)
     239    PRINT(0)("   is Joined at the End\n");
     240 
     241  if(!this->backLoopCheck(this)) /* this should not happen */
     242    PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n");
     243}
     244
     245/**
     246   \brief CONDITION that chooses the first child for the decision (static)
     247   \param nothing Nothing in this function
     248   \returns the chosen child
     249*/
     250int TrackElement::lowest(void* nothing)
     251{
     252  return 0;
     253}
     254
     255/**
     256   \brief CONDITION that chooses the last child for the decision (static)
     257   \param nothing Nothing in this function
     258   \returns the chosen child
     259*/
     260int TrackElement::highest(void* nothing)
     261{
     262  return this->childCount-1;
     263}
     264
     265/**
     266   \brief CONDITION that chooses a random child for the decision (static)
     267   \param nothing Nothing in this function
     268   \returns the chosen child
     269*/
     270int TrackElement::random(void* nothing)
     271{
     272  int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount);
     273  if (i >= this->childCount)
     274    return this->childCount-1;
     275  else
     276    return i;
     277}
     278
     279/**
     280   \brief CONDITION that chooses child 0, if the node(probably Player)
     281   is left of its parent (z<0)) and 1/right otherwise.
     282   \param node The node to act upon.
     283   \returns the chosen child
     284*/
     285int TrackElement::leftRight(void* node)
     286{
     287  PNode* tmpNode = (PNode*)node;
     288
     289  if (tmpNode->getRelCoor().z < 0)
     290    return 0;
     291  else
     292    return 1;
     293}
     294
     295
     296/**
     297   \brief CONDITION that chooses the child, that has the nearest distance to the node (probably player).
     298   \param node The node to act upon.
     299   \returns the chosen child
     300
     301   This is rather dangerous, because one must carefully set the points on the curve.
     302   The best Way is to set the nodes as wide away of each other as possible,
     303   but take into consideration, that if the nodes are to far from a center node, the center will be chosen.
     304   (play with this!!).
     305*/
     306int TrackElement::nearest(void* node)
     307{
     308  PNode* tmpNode = (PNode*)node;
     309
     310  Vector nodeRelCoord = tmpNode->getRelCoor();
     311  float minDist = 100000000;
     312  int childNumber = 0;
     313  int i = 0;
     314
     315  TrackElement* enumElem = this->children->enumerate();
     316  while (enumElem)
     317    {
     318      float dist = (nodeRelCoord - enumElem->curve->getNode(4)).len();
     319      if (dist < minDist)
     320        {
     321          minDist = dist;
     322          childNumber = i;
     323        }
     324      i++;
     325      enumElem = this->children->nextElement();
     326    }
     327
     328  PRINTF(4)("PathDecision with nearest algorithm: %d\n", childNumber);
     329  return childNumber;
     330}
     331
     332
     333////////////////////////
     334///// TRACKMANAGER /////
     335////////////////////////
    133336/**
    134337   \brief standard constructor
     
    137340TrackManager::TrackManager(void)
    138341{
    139   this->setClassName ("TrackManager");
     342  this->setClassName("TrackManager");
     343 
     344  TrackManager::singletonRef = this;
    140345
    141346  PRINTF(3)("Initializing the TrackManager\n");
     
    146351  this->maxTime = 0;
    147352  this->trackElemCount = 1;
    148   this->bindSlave = NULL;
     353  this->setBindSlave(this->trackNode = new TrackNode());
    149354}
    150355
     
    152357/**
    153358   \brief standard destructor
    154 
    155359*/
    156360TrackManager::~TrackManager(void)
     
    158362  PRINTF(3)("Destruct TrackManager\n");
    159363
    160   PRINTF(3)("Deleting all the TrackElements\n");
     364  PRINTF(4)("Deleting all the TrackElements\n");
    161365  delete this->firstTrackElem;
    162366  // delete this->name;
    163367
    164368  // we do not have a TrackManager anymore
    165   singletonRef = NULL;
    166 }
    167 
     369  TrackManager::singletonRef = NULL;
     370}
     371
     372//! Singleton Reference to TrackManager
    168373TrackManager* TrackManager::singletonRef = NULL;
    169374
     
    175380TrackManager* TrackManager::getInstance(void)
    176381{
    177   if (singletonRef)
    178     return singletonRef;
    179   else
    180     return singletonRef = new TrackManager();
     382  if (!TrackManager::singletonRef)
     383    TrackManager::singletonRef = new TrackManager();
     384  return TrackManager::singletonRef;
    181385}
    182386
     
    189393  this->currentTrackElem->childCount = childCount;
    190394  this->currentTrackElem->mainJoin = true;
    191   this->currentTrackElem->children = new TrackElement*[childCount];
    192   for (int i=0; i<childCount; i++)
    193     {
    194            
    195       this->currentTrackElem->children[i] = new TrackElement();
    196       this->currentTrackElem->children[i]->ID = ++trackElemCount;
    197       this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->endTime + this->currentTrackElem->jumpTime;
    198       this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->children[i]);
    199         if( names != NULL)
     395  this->currentTrackElem->children =  new tList<TrackElement>();
     396  for (int i = 0; i < childCount; i++)
     397    {
     398      TrackElement* newElem = new TrackElement();
     399      this->currentTrackElem->children->add(newElem);
     400      newElem->ID = ++trackElemCount;
     401      newElem->startingTime = this->currentTrackElem->endTime + this->currentTrackElem->jumpTime;
     402      this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->getChild(i));
     403      if( names != NULL)
    200404        {
    201                 // todo check for duplicate track names to avoid confusion
    202                 /*if( this->findTrackElementByName( names->getString(i)) != NULL)
    203                         PRINTF0("Track name '%s' already taken", names->getString(i));
    204                 else*/
    205                         this->currentTrackElem->children[i]->setName( names->getString(i));
    206             }
     405          // todo check for duplicate track names to avoid confusion
     406          /*if( this->findTrackElementByName( names->getString(i)) != NULL)
     407            PRINTF0("Track name '%s' already taken", names->getString(i));
     408            else*/
     409          this->currentTrackElem->getChild(i)->setName(names->getString(i));
     410        }
    207411           
    208412   }
     413  if (childCount == 1)
     414    this->currentTrackElem->getChild(0)->setName(this->currentTrackElem->getName());
    209415}
    210416
     
    240446    this->currentTrackElem = tmpElem;
    241447  else
    242     printf("TrackElement not Found, leaving unchanged\n");
    243   printf("now Working on %d\n", this->currentTrackElem->ID);
     448    PRINTF(2)("TrackElement not Found, leaving unchanged\n");
     449  PRINTF(4)("now Working on %d\n", this->currentTrackElem->ID);
    244450
    245451}
     
    247453/**
    248454   \brief Sets the Type of the Curve
    249    \brief curveType The Type to set
     455   \param curveType The Type to set
     456   \param trackElem the TrackElement that should get a new Curve.
    250457*/
    251458void TrackManager::setCurveType(CurveType curveType, TrackElement* trackElem)
     
    256463      return;
    257464    }
    258   trackElem->curveType = curveType;
     465  this->curveType = curveType;
    259466  switch (curveType)
    260467    {
     
    262469      trackElem->curve = new BezierCurve();
    263470      break;
    264     case UPOINTCURVE:
    265       trackElem->curve = new UPointCurve();
    266       break;
     471
    267472    }
    268473}
     
    297502  if (trackElem->isFresh)
    298503    {
    299       this->setCurveType(BEZIERCURVE, trackElem);
     504      this->setCurveType(TMAN_DEFAULT_CURVETYPE, trackElem);
    300505      trackElem->isFresh = false;
    301506    }
     
    311516int TrackManager::addHotPoint(Vector newPoint)
    312517{
    313   printf("setting up a HotPoint\n");
     518  PRINTF(4)("setting up a HotPoint\n");
    314519  if (this->currentTrackElem->isFresh)
    315520    {
     
    322527  this->currentTrackElem->nodeCount++;
    323528  this->initChildren(1);
    324   this->currentTrackElem = this->currentTrackElem->children[0];
     529  this->currentTrackElem = this->currentTrackElem->getChild(0);
    325530}
    326531
     
    334539int TrackManager::setSavePoint(void)
    335540{
    336   printf("setting up a SavePoint.\n");
     541  PRINTF(4)("setting up a SavePoint.\n");
    337542  if (this->currentTrackElem->isFork || this->currentTrackElem->isSavePoint)
    338     return this->currentTrackElem->children[1]->ID;
     543    {
     544      PRINTF(2)("%d is already finished \n", currentTrackElem->ID);
     545      return this->currentTrackElem->getChild(0)->ID;
     546    }
    339547  this->currentTrackElem->isSavePoint = true;
    340548  this->currentTrackElem->isHotPoint = true;
    341549
    342550  this->initChildren(1);
    343   this->currentTrackElem = this->currentTrackElem->children[0];
     551  this->currentTrackElem = this->currentTrackElem->getChild(0);
    344552}
    345553
     
    377585void TrackManager::forkV(unsigned int count, int* trackIDs, SubString* names)
    378586{
    379   printf("Forking with %d children\n", count);
     587  PRINTF(4)("Forking with %d children\n", count);
    380588  if (this->currentTrackElem->isSavePoint)
    381589  {
     
    392600/**
    393601   \brief decides under what condition a certain Path will be chosen.
     602   \param cond the CONDITION of the decision
     603   \param subject the Subject that will be decided upon with CONDITION cond.
     604*/
     605void TrackManager::condition(CONDITION cond, void* subject)
     606{
     607  this->condition(this->currentTrackElem->ID, cond, subject);
     608}
     609/**
     610   \brief decides under what condition a certain Path will be chosen.
    394611   \param groupID the ID on which to choose the preceding move
    395    \param cond \todo think about this
    396 */
    397 void TrackManager::condition(unsigned int groupID, PathCondition cond)
    398 {
    399  
    400 }
     612   \param cond the CONDITION of the decision
     613   \param subject the Subject that will be decided upon with CONDITION cond.
     614*/
     615void TrackManager::condition(unsigned int groupID, CONDITION cond, void* subject)
     616{
     617  TrackElement* tmpElem = this->findTrackElementByID(groupID);
     618  if (!tmpElem->isFork)
     619    {
     620      PRINTF(2)("%d is not a Fork, and no condition can be set in this case\n", tmpElem->ID);
     621      return;
     622    }
     623  else
     624    {
     625      switch (cond)
     626        {
     627        case LOWEST:
     628          tmpElem->condFunc = &TrackElement::lowest;
     629          break;
     630        case HIGHEST:
     631          tmpElem->condFunc = &TrackElement::highest;
     632          break;
     633        case RANDOM:
     634          tmpElem->condFunc = &TrackElement::random;
     635          break;
     636        case LEFTRIGHT:
     637          tmpElem->condFunc = &TrackElement::leftRight;
     638          break;
     639        case NEAREST:
     640          tmpElem->condFunc = &TrackElement::nearest;
     641          break;
     642        case ENEMYKILLED:
     643          break;
     644        }
     645      tmpElem->subject=subject;
     646    }
     647}
     648
    401649
    402650/**
     
    430678void TrackManager::joinV(unsigned int count, int* trackIDs)
    431679{
    432   printf("Joining %d tracks and merging to Track %d\n", count, trackIDs[0]);
     680  PRINTF(3)("Joining %d tracks and merging to Track %d\n", count, trackIDs[0]);
     681
     682  // checking if there is a back-loop-connection and ERROR if it is.
     683  TrackElement* tmpTrackElem = this->findTrackElementByID(trackIDs[0]);
     684  if (!tmpTrackElem->backLoopCheck(tmpTrackElem))
     685    PRINTF(2)("Backloop connection detected at joining trackElements\n");
    433686
    434687  // chanching work-on to temporary value. going back at the end.
     
    480733    }
    481734  if(firstJoint->childCount > 0)
    482     for(int i = 0; i < firstJoint->childCount; i++)
    483       {
    484         printf("Setting startingTime of %d to %f.\n", firstJoint->children[i]->ID, tmpLatestTime);
    485         firstJoint->children[i]->startingTime = tmpLatestTime;
    486         firstJoint->children[i]->endTime = tmpLatestTime+firstJoint->children[i]->duration;
    487       }
    488 
     735    {
     736      TrackElement* enumElem = firstJoint->children->enumerate();
     737      while (enumElem)
     738        {
     739          PRINTF(4)("Setting startingTime of %d to %f.\n", enumElem->ID, tmpLatestTime);
     740          enumElem->startingTime = tmpLatestTime;
     741          enumElem->endTime = tmpLatestTime + enumElem->duration;
     742         
     743          enumElem = firstJoint->children->nextElement();
     744        }
     745    }
    489746  // returning to the TrackElement we were working on.
    490747  this->workOn(tmpCurrentWorkingID);
     
    501758    {
    502759      TrackElement* tmpElem = findTrackElementByID(i);
    503       if (tmpElem->childCount>0 && tmpElem->mainJoin)
    504         {
    505           for (int j = 0; j < tmpElem->childCount; j++)
     760      if (tmpElem->childCount > 0 && tmpElem->mainJoin)
     761        {
     762
     763          TrackElement* enumElem = tmpElem->children->enumerate();
     764          while (enumElem)
    506765            {
    507766             
    508767              // c1-continuity
    509               tmpElem->children[j]->curve->addNode(tmpElem->children[j]->curve->getNode(0) +
    510                                                    ((tmpElem->children[j]->curve->getNode(0) -
     768              enumElem->curve->addNode(enumElem->curve->getNode(0) +
     769                                                   ((enumElem->curve->getNode(0) -
    511770                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1))
    512771                                                    ),2);
    513               tmpElem->children[j]->nodeCount++;
     772              enumElem->nodeCount++;
    514773              // c2-continuity
    515               tmpElem->children[j]->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())-
     774              enumElem->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())-
    516775                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) * 4 +
    517776                                                   tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-2), 3);
    518               tmpElem->children[j]->nodeCount++;                                                   
    519               printf("accelerations: %d-in: count: %d, %f, %f, %f\n                  %d-out: count: %d %f, %f, %f\n",
     777              enumElem->nodeCount++;                                               
     778              PRINTF(5)("accelerations: %d-in: count: %d, %f, %f, %f\n                  %d-out: count: %d %f, %f, %f\n",
    520779                     tmpElem->ID, tmpElem->nodeCount,
    521780                     tmpElem->curve->calcAcc(0.999).x, tmpElem->curve->calcAcc(0.999).y, tmpElem->curve->calcAcc(0.999).z,
    522                      tmpElem->children[j]->ID, tmpElem->children[j]->nodeCount,
    523                      tmpElem->children[j]->curve->calcAcc(0).x, tmpElem->children[j]->curve->calcAcc(0).y, tmpElem->children[j]->curve->calcAcc(0).z);
     781                     enumElem->ID, enumElem->nodeCount,
     782                     enumElem->curve->calcAcc(0).x, enumElem->curve->calcAcc(0).y, enumElem->curve->calcAcc(0).z);
     783             
     784              enumElem = tmpElem->children->nextElement();
    524785            }
    525786        }
    526787    }
     788  for (int i = 1; i <=trackElemCount;i++)
     789    if (this->findTrackElementByID(i)->endTime > this->maxTime)
     790      this->maxTime = findTrackElementByID(i)->endTime; // very bad implemented :/
    527791}
    528792
     
    536800Vector TrackManager::calcPos() const
    537801{
    538   //  PRINTF(0)("TrackElement:%d, localTime: %f\n",this->currentTrackElem->ID, this->localTime);
    539802  return this->currentTrackElem->curve->calcPos((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
    540803}
     
    550813
    551814/**
     815   \returns the current Width of the track
     816*/
     817float TrackManager::getWidth(void) const
     818{
     819  return this->currentTrackElem->width;
     820}
     821
     822/**
    552823   \brief Advances the local-time of the Track around dt
    553824   \param dt The time about which to advance.
     
    558829{
    559830  dt /= 1000;
    560   printf("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
     831  PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
    561832  if (this->localTime <= this->firstTrackElem->duration)
    562833    this->jumpTo(this->localTime);
    563   this->localTime += dt;
     834  if (this->localTime <= this->maxTime)
     835    this->localTime += dt;
    564836  if (this->localTime > this->currentTrackElem->endTime
    565837      && this->currentTrackElem->children)
    566838    {
    567       if (this->currentTrackElem->jumpTime > 0)
     839      if (this->currentTrackElem->jumpTime != 0.0)
    568840        this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
    569       this->currentTrackElem = this->currentTrackElem->children[0];
     841      // jump to the next TrackElement and also set the history of the new Element to the old one.
     842      TrackElement* tmpHistoryElem = this->currentTrackElem;
     843      this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
     844      this->currentTrackElem->history = tmpHistoryElem;
    570845    }
    571846  if (this->bindSlave)
     
    573848      Vector tmp = this->calcPos();
    574849      Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
     850
     851      Vector v(0.0, 1.0, 0.0);
     852      Quaternion q(-PI/2, v);
     853      quat = quat * q;
     854
    575855      this->bindSlave->setAbsCoor(&tmp);
    576856      this->bindSlave->setAbsDir(&quat);
     
    594874/**
    595875   \brief a Function that decides which Path we should follow.
    596    \param graphID The Path to choose.
     876   \param trackElem The Path to choose.
    597877   
    598878*/
    599 void TrackManager::choosePath(int graphID)
    600 {
    601 
     879int TrackManager::choosePath(TrackElement* trackElem)
     880{
     881  return (trackElem->*(trackElem->condFunc))(trackElem->subject);
    602882}
    603883
     
    608888void TrackManager::setBindSlave(PNode* bindSlave)
    609889{
    610   if (!this->bindSlave)
    611     this->bindSlave = bindSlave;
    612 }
    613 
     890  this->bindSlave = bindSlave;
     891}
     892
     893/**
     894   \returns the main TrackNode
     895*/
     896PNode* TrackManager::getTrackNode(void)
     897{
     898  return this->trackNode;
     899}
    614900
    615901// DEBUG //
     
    646932void TrackManager::debug(unsigned int level) const
    647933{
    648   printf("::CLASS TRACKMANAGER::debug information::\n");
    649   //  printf("Status is: %
    650   printf(" Consists of %d elements\n", this->trackElemCount);
    651   printf(" localTime is: %f\n", this->localTime);
     934  PRINT(0)("=========================================\n");
     935  PRINT(0)("= CLASS TRACKMANAGER::debug information =\n");
     936  PRINT(0)("=========================================\n");
     937  //  PRINT(0)("Status is: %
     938  PRINT(0)(" Consists of %d elements\n", this->trackElemCount);
     939  PRINT(0)(" localTime is: %f\n", this->localTime);
    652940  if (level >= 2)
    653941    {
     
    655943        {
    656944          TrackElement* tmpElem = this->findTrackElementByID(i);
    657           printf("  ::TrackElement:%i::", tmpElem->ID);
    658           if(tmpElem->name)
    659             printf("name:%s::", tmpElem->name);
    660           if(tmpElem->isFresh)
    661             printf("   has not jet eddited in any way\n");
    662           printf("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", tmpElem->startingTime, tmpElem->endTime, tmpElem->duration, tmpElem->jumpTime);
    663           printf("   consists of %d Points\n", tmpElem->nodeCount);
    664           if (tmpElem->childCount == 0)
    665             printf("   has no child\n");           
    666           else if (tmpElem->childCount == 1)
    667             printf("   has 1 child: ==%d==\n", tmpElem->children[0]->ID);
    668           else if (tmpElem->childCount > 1)
    669             {
    670               printf("   has %d children: ", tmpElem->childCount);
    671               for(int i = 0; i < tmpElem->childCount; i++)
    672                 printf("=%d= ", tmpElem->children[i]->ID);
    673               printf("\n");
    674             }
    675 
    676           if(tmpElem->isHotPoint)
    677             printf("   is a special Point:\n");
    678           if(tmpElem->isSavePoint)
    679             printf("    is a SavePoint\n");
    680           if(tmpElem->isFork)
    681             {
    682               printf("    is A Fork with with %d children.\n", tmpElem->childCount);
    683             }
    684           if(tmpElem->isJoined)
    685             printf("   is Joined at the End\n");
    686         }
    687     }
     945          tmpElem->debug();
     946        }
     947    }
     948  PRINT(0)("-----------------------------------------\n");
    688949}
    689950
Note: See TracChangeset for help on using the changeset viewer.