Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/track_manager.cc @ 3527

Last change on this file since 3527 was 3527, checked in by bensch, 19 years ago

orxonox/trunk: trackManager: now the TrackManager knows his path also backwards.

File size: 22.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16
17#include "track_manager.h"
18
19#include "p_node.h"
20
21#include <stdarg.h>
22#include "p_node.h"
23
24using namespace std;
25
26/**
27   \brief initializes a TrackElement (sets the default values)
28*/
29TrackElement::TrackElement(void)
30{
31  this->isFresh = true;
32  this->isHotPoint = false;
33  this->isSavePoint = false;
34  this->isFork = false;
35  this->isJoined = false;
36  this->mainJoin = false;
37  this->ID = -1;
38  this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager.
39  this->duration = 1;
40  this->endTime = 1;
41  this->jumpTime = 0;
42  this->curveType = BEZIERCURVE;
43  this->nodeCount = 0;
44  this->childCount = 0;
45  this->name = NULL;
46  this->curve = NULL;
47  this->children = NULL;
48
49  this->history = NULL;
50
51  this->condFunc = &TrackElement::random;
52}
53
54/**
55    \brief destroys all alocated memory)
56    \todo eventually when deleting a TrackElement you would not like to delete all its preceding TrackElements
57*/
58TrackElement::~TrackElement(void)
59{
60  if (this->name)
61    delete []name;
62  if (this->curve)
63    delete this->curve;
64  if ((!this->isJoined &&this->childCount > 0) || (this->isJoined && this->mainJoin))
65    {
66      for (int i=0; i < this->childCount; i++)
67        delete this->children[i];
68      delete this->children;
69    }
70}
71
72/**
73   \brief Searches through all the TrackElements for trackID.
74   \param trackID The ID to search for.
75   \returns The TrackElement if Found, NULL otherwise.
76   
77   \todo make this more modular, to search for different things
78*/
79TrackElement* TrackElement::findByID(unsigned int trackID)
80{
81  // return if Found.
82  if (this->ID == trackID)
83    return this;
84  // search on.
85  if (this->childCount > 0)
86    for (int i=0; i < this->childCount; i++)
87      {
88        TrackElement* tmpElem;
89        if ((tmpElem = this->children[i]->findByID(trackID)))
90          return tmpElem;
91      }
92  else return NULL;
93}
94
95
96/**
97   \brief checks if there are any BackLoops in the Track
98   \param trackElem the trackElement to check about
99   it simply does this by looking if the current trackElem is found again somewhere else in the Track
100*/
101bool TrackElement::backLoopCheck(TrackElement* trackElem)
102{
103  if (this->childCount == 0)
104    return true;
105  else
106    {
107      for (int i = 0; i < this->childCount; i++)
108        if(!this->children[i]->backLoopCheck(trackElem))
109          return false;
110     
111      return true;
112    }
113}
114
115/**
116   \brief CONDITION that chooses the first child for the decision (static)
117   \param nothing Nothing in this function
118   \returns the chosen child
119*/
120int TrackElement::lowest(void* nothing)
121{
122  return 0;
123}
124
125/**
126   \brief CONDITION that chooses the last child for the decision (static)
127   \param nothing Nothing in this function
128   \returns the chosen child
129*/
130int TrackElement::highest(void* nothing)
131{ 
132  return this->childCount-1;
133}
134
135/**
136   \brief CONDITION that chooses a random child for the decision (static)
137   \param nothing Nothing in this function
138   \returns the chosen child
139*/
140int TrackElement::random(void* nothing)
141{
142  int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount);
143  if (i >= this->childCount)
144    return this->childCount-1;
145  else 
146    return i;
147}
148
149/**
150   \brief CONDITION that chooses child 0, if the node(probably Player)
151   is left of its parent (z<0)) and 1/right otherwise.
152   \param node The node to act upon.
153   \returns the chosen child
154*/
155int TrackElement::leftRight(void* node)
156{
157  PNode* tmpNode = (PNode*)node;
158
159  if (tmpNode->getRelCoor().z < 0)
160    return 0;
161  else 
162    return 1;
163}
164
165
166/**
167   \brief CONDITION that chooses the child, that has the nearest distance to the node (probably player).
168   \param node The node to act upon.
169   \returns the chosen child
170
171   This is rather dangerous, because one must carefully set the points on the curve.
172   The best Way is to set the nodes as wide away of each other as possible,
173   but take into consideration, that if the nodes are to far from a center node, the center will be chosen.
174   (play with this!!).
175*/
176int TrackElement::nearest(void* node)
177{
178  PNode* tmpNode = (PNode*)node;
179
180  Vector nodeRelCoord = tmpNode->getRelCoor();
181  float minDist = 100000000;
182  int nodeNumber = 0;
183  for (int i = 0; i < this->childCount; i++)
184    {
185      float dist = (nodeRelCoord - this->children[i]->curve->getNode(4)).len();
186      if (dist < minDist)
187        {
188          minDist = dist;
189          nodeNumber = i;
190        }
191    }
192  PRINTF(3)("PathDecision with nearest algorithm: %d\n", nodeNumber);
193  return nodeNumber;
194}
195
196
197
198/////////////////////////////////////
199///// TRACKMANAGER //////////////////
200/////////////////////////////////////
201/**
202   \brief standard constructor
203
204*/
205TrackManager::TrackManager(void)
206{
207  this->setClassName ("TrackManager");
208
209  PRINTF(3)("Initializing the TrackManager\n");
210  this->firstTrackElem = new TrackElement();
211  this->firstTrackElem->ID = 1;
212  this->currentTrackElem = firstTrackElem;
213  this->localTime = 0;
214  this->maxTime = 0;
215  this->trackElemCount = 1;
216  this->bindSlave = NULL;
217}
218
219
220/**
221   \brief standard destructor
222
223*/
224TrackManager::~TrackManager(void)
225{
226  PRINTF(3)("Destruct TrackManager\n");
227
228  PRINTF(3)("Deleting all the TrackElements\n");
229  delete this->firstTrackElem;
230
231  // we do not have a TrackManager anymore
232  singletonRef = NULL;
233}
234
235TrackManager* TrackManager::singletonRef = NULL;
236
237/**
238   \returns The reference on the TrackManager.
239
240   If the TrackManager does not exist, it will be created.
241*/
242TrackManager* TrackManager::getInstance(void) 
243{
244  if (TrackManager::singletonRef)
245    return TrackManager::singletonRef;
246  else
247    return TrackManager::singletonRef = new TrackManager();
248}
249
250/**
251   \brief reserves Space for childCount children
252   \param childCount The Count of children to make space for.
253*/
254void TrackManager::initChildren(unsigned int childCount)
255{
256  this->currentTrackElem->childCount = childCount;
257  this->currentTrackElem->mainJoin = true;
258  this->currentTrackElem->children = new TrackElement*[childCount];
259  for (int i=0; i<childCount; i++)
260    {
261      this->currentTrackElem->children[i] = new TrackElement();
262      this->currentTrackElem->children[i]->ID = ++trackElemCount;
263      this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->endTime + this->currentTrackElem->jumpTime;
264      this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->children[i]);
265    }
266}
267
268/**
269   \brief Searches for a given trackID.
270   \param trackID the trackID to search for.
271   \returns The TrackElement #trackID if found, NULL otherwise.
272*/
273TrackElement* TrackManager::findTrackElementByID(unsigned int trackID) const
274{
275  return firstTrackElem->findByID(trackID);
276}
277
278// INITIALIZE //
279
280/**
281   \brief Sets the trackID we are working on.
282   \param trackID the trackID we are working on
283*/
284void TrackManager::workOn(unsigned int trackID)
285{
286  TrackElement* tmpElem = findTrackElementByID(trackID);
287  if (tmpElem)
288    this->currentTrackElem = tmpElem;
289  else
290    printf("TrackElement not Found, leaving unchanged\n");
291  printf("now Working on %d\n", this->currentTrackElem->ID);
292
293}
294
295/**
296   \brief Sets the Type of the Curve
297   \param curveType The Type to set
298   \param trackElem the TrackElement that should get a new Curve.
299*/
300void TrackManager::setCurveType(CurveType curveType, TrackElement* trackElem)
301{
302  if (!trackElem->isFresh)
303    {
304      PRINTF(2)("It is not possible to change the type of a Curve after you have have appended some points to it\n");
305      return;
306    }
307  trackElem->curveType = curveType;
308  switch (curveType)
309    {
310    case BEZIERCURVE:
311      trackElem->curve = new BezierCurve();
312      break;
313    case UPOINTCURVE:
314      trackElem->curve = new UPointCurve();
315      break;
316    }
317}
318
319/**
320   \brief Sets the duration of the current path in seconds.
321   \param time The duration in seconds.
322*/
323
324void TrackManager::setDuration(float time)
325{
326  this->currentTrackElem->duration = time;
327  this->currentTrackElem->endTime = this->currentTrackElem->startingTime + time;
328}
329
330/**
331   \brief adds a point to the current TrackElement
332   \param newPoint The point to add.
333*/
334bool TrackManager::addPoint(Vector newPoint)
335{
336  return this->addPoint(newPoint, this->currentTrackElem);
337}
338
339/**
340   \brief adds a point to trackElem
341   \param newPoint The point to add.
342   \param trackElem The TrackElement to add the Point to
343*/
344bool TrackManager::addPoint(Vector newPoint, TrackElement* trackElem)
345{
346  if (trackElem->isFresh)
347    {
348      this->setCurveType(BEZIERCURVE, trackElem);
349      trackElem->isFresh = false;
350    }
351  trackElem->curve->addNode(newPoint);
352  trackElem->nodeCount++;
353}
354
355/**
356   \brief adds save/splitpoint.
357   \param newPoint The point to add.
358   \returns A Pointer to a newly appended Curve
359*/
360int TrackManager::addHotPoint(Vector newPoint)
361{
362  printf("setting up a HotPoint\n");
363  if (this->currentTrackElem->isFresh)
364    {
365      this->setCurveType(BEZIERCURVE);
366      this->currentTrackElem->isFresh = false;
367    }
368
369  // \todo HotPoint Handling.
370  this->currentTrackElem->curve->addNode(newPoint);
371  this->currentTrackElem->nodeCount++;
372  this->initChildren(1);
373  this->currentTrackElem = this->currentTrackElem->children[0];
374}
375
376/**
377   \brief Sets the last HotPoint into a savePoint.
378   \returns A Pointer to a newly appended Curve
379   
380   If no HotPoint was defined the last added Point will be rendered into a savePoint. \n
381   If the HotPoint was defined as a fork the Point will \b not be set into a savePoint.
382*/
383int TrackManager::setSavePoint(void)
384{
385  printf("setting up a SavePoint.\n");
386  if (this->currentTrackElem->isFork || this->currentTrackElem->isSavePoint)
387    return this->currentTrackElem->children[1]->ID;
388  this->currentTrackElem->isSavePoint = true;
389  this->currentTrackElem->isHotPoint = true;
390
391  this->initChildren(1);
392  this->currentTrackElem = this->currentTrackElem->children[0];
393}
394
395/**
396   \brief adds some interessting non-linear movments through the level.
397   \param count The Count of childrens the current HotPoint will have.
398
399   If no HotPoint was defined the last added Point will be rendered into a fork. \n
400   If the HotPoint was defined as a savePoint the Point will \b not be set into a fork.
401*/
402void TrackManager::fork(unsigned int count, ...)
403{
404  int* trackIDs = new int[count];
405  this->forkV(count, trackIDs);
406  va_list ID;
407  va_start (ID, count);
408  for(int i = 0; i < count; i++)
409    {
410      *va_arg (ID, int*) = trackIDs[i];
411    }
412  va_end(ID); 
413  delete []trackIDs;
414}
415
416/**
417   \brief adds some interessting non-linear movments through the level.
418   \param count The Count of childrens the current HotPoint will have.
419   \param trackIDs A Pointer to an Array of ints which will hold the trackID's (the user will have to reserve space for this).
420
421   \see void TrackManager::fork(int count, ...)
422
423   \todo initialisation is wrong!! also in setSavePoint.
424*/
425void TrackManager::forkV(unsigned int count, int* trackIDs)
426{
427  printf("Forking with %d children\n", count);
428  if (this->currentTrackElem->isSavePoint)
429    return;
430  this->currentTrackElem->isFork = true;
431  this->currentTrackElem->isHotPoint = true;
432  for(int i = 0; i < count; i++)
433    trackIDs[i]=this->trackElemCount+1+i;
434  this->initChildren(count);
435}
436
437/**
438   \brief decides under what condition a certain Path will be chosen.
439   \param cond the CONDITION of the decision
440   \param subject the Subject that will be decided upon with CONDITION cond.
441*/
442void TrackManager::condition(CONDITION cond, void* subject)
443{
444  this->condition(this->currentTrackElem->ID, cond, subject);
445}
446/**
447   \brief decides under what condition a certain Path will be chosen.
448   \param groupID the ID on which to choose the preceding move
449   \param cond the CONDITION of the decision
450   \param subject the Subject that will be decided upon with CONDITION cond.
451*/
452void TrackManager::condition(unsigned int groupID, CONDITION cond, void* subject)
453{
454  TrackElement* tmpElem = this->findTrackElementByID(groupID);
455 
456  switch (cond)
457    {
458    case LOWEST:
459      tmpElem->condFunc = &TrackElement::lowest;
460      break;
461    case HIGHEST:
462      tmpElem->condFunc = &TrackElement::highest;
463      break;
464    case RANDOM: 
465      tmpElem->condFunc = &TrackElement::random;
466      break;
467    case LEFTRIGHT:
468      tmpElem->condFunc = &TrackElement::leftRight;
469      break;
470    case NEAREST:
471      tmpElem->condFunc = &TrackElement::nearest;
472      break;
473    case ENEMYKILLED:
474      break;
475    }
476  tmpElem->subject=subject;
477}
478
479
480/**
481   \brief joins some tracks together again.
482   \param count The count of Paths to join.
483
484   Join will set the localTime to the longest time a Path has to get to this Point. \n
485   Join will join all curves to the first curve, meaning that all the tangents will be matched.
486*/
487void TrackManager::join(unsigned int count, ...)
488{
489  int* trackIDs = new int [count];
490  va_list ID;
491  va_start (ID, count);
492  for(int i = 0; i < count; i++)
493    {
494      trackIDs[i] = va_arg (ID, int);
495    }
496  va_end(ID);
497  this->joinV(count, trackIDs);
498  delete []trackIDs;
499}
500
501/**
502   \brief joins some tracks together again.
503   \param count The count of Paths to join.
504   \param trackIDs an Array with the trackID's to join
505
506   \see void TrackManager::join(int count, ...)
507*/
508void TrackManager::joinV(unsigned int count, int* trackIDs)
509{
510  printf("Joining %d tracks and merging to Track %d\n", count, trackIDs[0]);
511
512  // checking if there is a back-loop-connection and ERROR if it is.
513  TrackElement* tmpTrackElem = this->findTrackElementByID(trackIDs[0]);
514  if (!tmpTrackElem->backLoopCheck(tmpTrackElem))
515    PRINTF(1)("Backloop connection detected at joining trackElements\n");
516
517  // chanching work-on to temporary value. going back at the end.
518  int tmpCurrentWorkingID = this->currentTrackElem->ID;
519  this->workOn(trackIDs[0]);
520  TrackElement* firstJoint = this->currentTrackElem;
521  float tmpLatestTime = firstJoint->endTime;
522
523  Vector tmpEndPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount());
524  Vector tmpTangentPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-1);
525  Vector tmpc2Point = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-2);
526  firstJoint->isJoined = true;
527  //  firstJoint->mainJoin = true;
528  if(!firstJoint->isHotPoint)
529    this->setSavePoint();
530  // Timing:
531  for (int i = 0; i < count; i++)
532    {
533      TrackElement* tmpJoinElem = this->findTrackElementByID(trackIDs[i]);
534      if (tmpJoinElem->childCount == 0
535          && tmpJoinElem->endTime > tmpLatestTime)
536        tmpLatestTime = tmpJoinElem->endTime;
537    }
538  // time the main Join.
539  firstJoint->jumpTime = tmpLatestTime - firstJoint->endTime;
540 
541  // Joining:
542  for (int i = 1; i < count; i++)
543    {
544      TrackElement* tmpJoinElem = this->findTrackElementByID(trackIDs[i]);
545      if (tmpJoinElem->childCount > 0)
546        printf("!!This Curve has children, and as such will not be joined!!\n You can try joining other childless TrackElements to this one!");
547      else
548        {
549          this->addPoint(tmpc2Point, tmpJoinElem);
550          this->addPoint(tmpTangentPoint, tmpJoinElem);
551          this->addPoint(tmpEndPoint, tmpJoinElem);
552          // time all other Joins
553          tmpJoinElem->jumpTime = tmpLatestTime - tmpJoinElem->endTime;
554         
555          //Copying Joint-Info
556          tmpJoinElem->children = firstJoint->children;
557          tmpJoinElem->childCount = firstJoint->childCount;
558          tmpJoinElem->isSavePoint = firstJoint->isSavePoint;
559          tmpJoinElem->isFork = firstJoint->isFork;
560
561          tmpJoinElem->isJoined = true;
562        }
563    }
564  if(firstJoint->childCount > 0)
565    for(int i = 0; i < firstJoint->childCount; i++)
566      {
567        printf("Setting startingTime of %d to %f.\n", firstJoint->children[i]->ID, tmpLatestTime);
568        firstJoint->children[i]->startingTime = tmpLatestTime;
569        firstJoint->children[i]->endTime = tmpLatestTime+firstJoint->children[i]->duration;
570      } 
571
572  // returning to the TrackElement we were working on.
573  this->workOn(tmpCurrentWorkingID);
574}
575
576/**
577   \brief finalizes the TrackSystem. after this it will not be editable anymore
578
579   \todo check for any inconsistencies, output errors
580*/
581void TrackManager::finalize(void)
582{
583  for (int i = 1; i<= trackElemCount ;i++)
584    {
585      TrackElement* tmpElem = findTrackElementByID(i);
586      if (tmpElem->childCount>0 && tmpElem->mainJoin)
587        {
588          for (int j = 0; j < tmpElem->childCount; j++)
589            {
590             
591              // c1-continuity
592              tmpElem->children[j]->curve->addNode(tmpElem->children[j]->curve->getNode(0) +
593                                                   ((tmpElem->children[j]->curve->getNode(0) - 
594                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1))
595                                                    ),2);
596              tmpElem->children[j]->nodeCount++;
597              // c2-continuity
598              tmpElem->children[j]->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())-
599                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) * 4 +
600                                                   tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-2), 3);
601              tmpElem->children[j]->nodeCount++;                                                   
602              printf("accelerations: %d-in: count: %d, %f, %f, %f\n                  %d-out: count: %d %f, %f, %f\n",
603                     tmpElem->ID, tmpElem->nodeCount,
604                     tmpElem->curve->calcAcc(0.999).x, tmpElem->curve->calcAcc(0.999).y, tmpElem->curve->calcAcc(0.999).z,
605                     tmpElem->children[j]->ID, tmpElem->children[j]->nodeCount,
606                     tmpElem->children[j]->curve->calcAcc(0).x, tmpElem->children[j]->curve->calcAcc(0).y, tmpElem->children[j]->curve->calcAcc(0).z);
607            }
608        }
609    }
610}
611
612
613// RUNTIME //
614
615/**
616   \brief calculates the Position for the localTime of the Track.
617   \returns the calculated Position
618*/
619Vector TrackManager::calcPos() const
620{
621  //  PRINTF(0)("TrackElement:%d, localTime: %f\n",this->currentTrackElem->ID, this->localTime);
622  return this->currentTrackElem->curve->calcPos((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
623}
624
625/**
626   \brief calculates the Rotation for the localTime of the Track.
627   \returns the calculated Rotation
628*/
629Vector TrackManager::calcDir() const
630{
631  return this->currentTrackElem->curve->calcDir((this->localTime - this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
632}
633
634/**
635   \brief Advances the local-time of the Track around dt
636   \param dt The time about which to advance.
637
638   This function also checks, if the TrackElement has to be changed.
639*/
640void TrackManager::tick(float dt)
641{
642  dt /= 1000;
643  printf("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
644  if (this->localTime <= this->firstTrackElem->duration)
645    this->jumpTo(this->localTime);
646  this->localTime += dt;
647  if (this->localTime > this->currentTrackElem->endTime
648      && this->currentTrackElem->children)
649    {
650      if (this->currentTrackElem->jumpTime != 0.0)
651        this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
652      // jump to the next TrackElement and also set the history of the new Element to the old one.
653      TrackElement* tmpHistoryElem = this->currentTrackElem;
654      this->currentTrackElem = this->currentTrackElem->children[this->choosePath(this->currentTrackElem)];
655      this->currentTrackElem->history = tmpHistoryElem;
656    }
657  if (this->bindSlave)
658    {
659      Vector tmp = this->calcPos();
660      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)); 
661      this->bindSlave->setAbsCoor(&tmp);
662      this->bindSlave->setAbsDir(&quat);
663    }
664}
665
666/**
667   \brief Jumps to a certain point on the Track.
668   \param time The time on the Track to jump to.
669
670   This should be used to Jump backwards on a Track, because moving forward means to change between the Path. (it then tries to choose the default.)
671   Max is trackLengthMax.
672*/
673void TrackManager::jumpTo(float time)
674{
675  if (time == 0)
676    this->currentTrackElem = this->firstTrackElem;
677  this->localTime = time;
678}
679
680/**
681   \brief a Function that decides which Path we should follow.
682   \param trackElem The Path to choose.
683   
684*/
685int TrackManager::choosePath(TrackElement* trackElem)
686{
687  return (trackElem->*(trackElem->condFunc))(trackElem->subject);
688}
689
690/**
691   \brief Sets the PNode, that should be moved along the Tack
692   \param bindSlave the PNode to set
693*/
694void TrackManager::setBindSlave(PNode* bindSlave)
695{
696  if (!this->bindSlave)
697    this->bindSlave = bindSlave;
698}
699
700
701// DEBUG //
702
703/**
704   \brief Imports a model of the Graph into the OpenGL-environment.
705   \param dt The Iterator used in seconds for Painting the Graph.
706
707   This is for testing facility only. Do this if you want to see the Path inside the Level.
708   eventually this will all be packed into a gl-list.
709*/
710void TrackManager::drawGraph(float dt) const
711{
712
713  for (int i = 1; i <= trackElemCount; i++)
714    {
715      glBegin(GL_LINE_STRIP);
716      TrackElement* tmpElem = this->findTrackElementByID(i);
717      if (tmpElem->curve)
718        for(float f = 0.0; f < 1.0; f+=dt)
719          {
720            //      printf("%f, %f, %f\n",trackManager->calcPos().x, trackManager->calcPos().y, trackManager->calcPos().z);
721            Vector tmpVector = tmpElem->curve->calcPos(f);
722            glVertex3f(tmpVector.x, tmpVector.y, tmpVector.z);
723          }
724  glEnd();
725    }
726}
727
728/**
729   \brief outputs debug information about the trackManager
730   \param level how much debug
731*/
732void TrackManager::debug(unsigned int level) const
733{
734  PRINT(0)("=========================================\n");
735  PRINT(0)("= CLASS TRACKMANAGER::debug information =\n");
736  PRINT(0)("=========================================\n");
737  //  PRINT(0)("Status is: %
738  PRINT(0)(" Consists of %d elements\n", this->trackElemCount);
739  PRINT(0)(" localTime is: %f\n", this->localTime);
740  if (level >= 2)
741    {
742      for (int i = 1; i <= trackElemCount; i++)
743        {
744          TrackElement* tmpElem = this->findTrackElementByID(i);
745          PRINT(0)("--== TrackElement:%i ==--", tmpElem->ID);
746          if(tmpElem->name)
747            PRINT(0)("Name: %s::", tmpElem->name);
748          if(tmpElem->isFresh)
749            PRINT(0)("  -- has not jet eddited in any way --\n");
750          PRINT(0)("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", tmpElem->startingTime, tmpElem->endTime, tmpElem->duration, tmpElem->jumpTime);
751          PRINT(0)("   consists of %d Points\n", tmpElem->nodeCount);
752          if (tmpElem->childCount == 0)
753            PRINT(0)("   has no child\n");
754          else if (tmpElem->childCount == 1)
755            PRINT(0)("   has 1 child: =%d=\n", tmpElem->children[0]->ID);
756          else if (tmpElem->childCount > 1)
757            {
758              PRINT(0)("   has %d children: ", tmpElem->childCount);
759              for(int i = 0; i < tmpElem->childCount; i++)
760                PRINT(0)("=%d= ", tmpElem->children[i]->ID);
761              PRINT(0)("\n");
762            }
763
764          if(tmpElem->isHotPoint)
765            PRINT(0)("   is a special Point:\n");
766          if(tmpElem->isSavePoint)
767            PRINT(0)("    is a SavePoint\n");
768          if(tmpElem->isFork)
769            {
770              PRINT(0)("    is A Fork with with %d children.\n", tmpElem->childCount);
771            }
772          if(tmpElem->isJoined)
773            PRINT(0)("   is Joined at the End\n");
774
775          if(!tmpElem->backLoopCheck(tmpElem)) /* this should not happen */
776            PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n");
777        }
778    }
779  PRINT(0)("-----------------------------------------\n");
780}
Note: See TracBrowser for help on using the repository browser.