Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Mar 1, 2005, 2:36:56 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: merged back the trackManager to the trunk.
merged with command:
svn merge -r 3369:HEAD branches/trackManager trunk
resolved conflicts in world.cc additive differences.

Location:
orxonox/trunk/src
Files:
2 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/Makefile.am

    r3421 r3433  
    1818                 ini_parser.cc \
    1919                 keynames.cc \
    20                  track.cc \
    2120                 base_entity.cc \
    2221                 game_loader.cc \
     
    4544                 npc.h \
    4645                 stdincl.h \
     46                 glincl.h \
    4747                 ai.h \
    4848                 environment.h \
     
    5252                 error.h \
    5353                 player.h \
    54                  track.h \
    5554                 camera.h \
    5655                 ini_parser.h \
  • orxonox/trunk/src/Makefile.in

    r3429 r3433  
    5757        world_entity.$(OBJEXT) vector.$(OBJEXT) camera.$(OBJEXT) \
    5858        command_node.$(OBJEXT) ini_parser.$(OBJEXT) keynames.$(OBJEXT) \
    59         track.$(OBJEXT) base_entity.$(OBJEXT) game_loader.$(OBJEXT) \
    60         campaign.$(OBJEXT) story_entity.$(OBJEXT) \
    61         environment.$(OBJEXT) model.$(OBJEXT) objModel.$(OBJEXT) \
    62         array.$(OBJEXT) material.$(OBJEXT) texture.$(OBJEXT) \
    63         list.$(OBJEXT) p_node.$(OBJEXT) null_parent.$(OBJEXT) \
    64         base_object.$(OBJEXT) helper_parent.$(OBJEXT) \
    65         track_manager.$(OBJEXT) matrix.$(OBJEXT) curve.$(OBJEXT) \
    66         glmenu_imagescreen.$(OBJEXT) skysphere.$(OBJEXT)
     59        base_entity.$(OBJEXT) game_loader.$(OBJEXT) campaign.$(OBJEXT) \
     60        story_entity.$(OBJEXT) environment.$(OBJEXT) model.$(OBJEXT) \
     61        objModel.$(OBJEXT) array.$(OBJEXT) material.$(OBJEXT) \
     62        texture.$(OBJEXT) list.$(OBJEXT) p_node.$(OBJEXT) \
     63        null_parent.$(OBJEXT) base_object.$(OBJEXT) \
     64        helper_parent.$(OBJEXT) track_manager.$(OBJEXT) \
     65        matrix.$(OBJEXT) curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT) \
     66        skysphere.$(OBJEXT)
    6767orxonox_OBJECTS = $(am_orxonox_OBJECTS)
    6868orxonox_LDADD = $(LDADD)
     
    8787@AMDEP_TRUE@    ./$(DEPDIR)/player.Po ./$(DEPDIR)/skysphere.Po \
    8888@AMDEP_TRUE@    ./$(DEPDIR)/story_entity.Po ./$(DEPDIR)/texture.Po \
    89 @AMDEP_TRUE@    ./$(DEPDIR)/track.Po ./$(DEPDIR)/track_manager.Po \
    90 @AMDEP_TRUE@    ./$(DEPDIR)/vector.Po ./$(DEPDIR)/world.Po \
    91 @AMDEP_TRUE@    ./$(DEPDIR)/world_entity.Po
     89@AMDEP_TRUE@    ./$(DEPDIR)/track_manager.Po ./$(DEPDIR)/vector.Po \
     90@AMDEP_TRUE@    ./$(DEPDIR)/world.Po ./$(DEPDIR)/world_entity.Po
    9291CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
    9392        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
     
    228227                 ini_parser.cc \
    229228                 keynames.cc \
    230                  track.cc \
    231229                 base_entity.cc \
    232230                 game_loader.cc \
     
    255253                 npc.h \
    256254                 stdincl.h \
     255                 glincl.h \
    257256                 ai.h \
    258257                 environment.h \
     
    262261                 error.h \
    263262                 player.h \
    264                  track.h \
    265263                 camera.h \
    266264                 ini_parser.h \
     
    318316          esac; \
    319317        done; \
    320         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/Makefile'; \
     318        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/Makefile'; \
    321319        cd $(top_srcdir) && \
    322           $(AUTOMAKE) --foreign  src/Makefile
     320          $(AUTOMAKE) --gnu  src/Makefile
    323321.PRECIOUS: Makefile
    324322Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
     
    398396@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/story_entity.Po@am__quote@
    399397@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/texture.Po@am__quote@
    400 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/track.Po@am__quote@
    401398@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/track_manager.Po@am__quote@
    402399@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector.Po@am__quote@
  • orxonox/trunk/src/console/Makefile.in

    r3424 r3433  
    203203          esac; \
    204204        done; \
    205         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/console/Makefile'; \
     205        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/console/Makefile'; \
    206206        cd $(top_srcdir) && \
    207           $(AUTOMAKE) --foreign  src/console/Makefile
     207          $(AUTOMAKE) --gnu  src/console/Makefile
    208208.PRECIOUS: Makefile
    209209Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/curve.cc

    r3365 r3433  
    4040    }
    4141  currentNode->position = newNode;
    42   currentNode->next = 0; // not sure if this really points to NULL!!
     42  currentNode->next = 0;
    4343  currentNode->number = (++nodeCount);
    4444  this->rebuild();
     
    4646}
    4747
     48void Curve::addNode(const Vector& newNode, unsigned int insertPosition)
     49{
     50
     51  if (this->nodeCount == 0 || insertPosition > this->nodeCount)
     52    return addNode(newNode);
     53
     54  if (insertPosition == 0)
     55    insertPosition = 1;
     56
     57  PathNode* insNode = new PathNode;
     58
     59  // relinking
     60  PathNode* tmpNode = this->firstNode;
     61  if (insertPosition > 1)
     62    {
     63      while (tmpNode->next->number != insertPosition)
     64        tmpNode= tmpNode->next;
     65      insNode->next = tmpNode->next;
     66      tmpNode->next = insNode;
     67    }
     68  else
     69    {
     70      insNode->next = this->firstNode;
     71      this->firstNode = insNode;
     72    }
     73  // renumbering
     74  insNode->number = insertPosition;
     75  tmpNode = insNode->next;
     76  while (tmpNode)
     77    {
     78      tmpNode->number++;
     79      tmpNode = tmpNode->next;
     80    }
     81
     82    // finished
     83  insNode->position = newNode;
     84  ++nodeCount;
     85  this->rebuild();
     86  return;
     87}
     88
    4889/**
    4990   \brief Finds a Node by its Number, and returns its Position
     
    5394Vector Curve::getNode(unsigned int nodeToFind)
    5495{
    55   if (nodeToFind > this->nodeCount)
     96  if (nodeToFind > this->nodeCount || nodeToFind < 0)
    5697    return Vector(0,0,0);
    5798  PathNode* tmpNode = this->firstNode;
     
    60101  return tmpNode->position;
    61102}
     103
     104/**
     105   \brief Outputs information about the state of this Curve
     106*/
     107void Curve::debug(void)
     108{
     109  printf("<<-------------------------------\n");
     110  printf("Curve Information:\n");
     111  printf("NodeCount: %d\n", this->nodeCount);
     112  PathNode* tmpNode = this->firstNode;
     113  while (tmpNode)
     114    {
     115      printf("node #%d: %f, %f, %f\n", tmpNode->number, tmpNode->position.x, tmpNode->position.y, tmpNode->position.z);
     116      tmpNode = tmpNode->next;
     117    }
     118  printf("------------------------------->>\n");
     119}
     120
    62121
    63122///////////////////////////////////
     
    142201
    143202  // rebuilding the Derivation curve
    144   if(this->derivation == 0)
     203  if(this->derivation <= 1)
    145204    {
    146205      tmpNode = firstNode;
     
    202261}
    203262
     263Vector BezierCurve::calcAcc (float t)
     264{
     265  return dirCurve->dirCurve->calcPos(t);
     266}
     267
    204268/**
    205269   \brief Calculates the Quaternion needed for our rotations
     
    374438}
    375439
     440Vector UPointCurve::calcAcc (float t)
     441{
     442}
     443
    376444/**
    377445   \brief Calculates the Quaternion needed for our rotations
  • orxonox/trunk/src/curve.h

    r3365 r3433  
    2323  Vector curvePoint;     //!< The point on the Cureve at a local Time.
    2424  float localTime;       //!< If the time of one point is asked more than once the programm will not calculate it again.
    25   Curve* dirCurve;       //!< The derivation-curve of this Curve.
    2625  int derivation;        //!< Which derivation of a Curve is this.
    2726
     
    4241  virtual void rebuild(void) = 0;
    4342 public:
     43  Curve* dirCurve;       //!< The derivation-curve of this Curve.
    4444  void addNode(const Vector& newNode);
     45  void addNode(const Vector& newNode, unsigned int insertPosition);
    4546  Vector getNode(unsigned int nodeToFind);
    4647  inline int getNodeCount(void) { return this->nodeCount;}
     
    4849  virtual Vector calcPos(float t) = 0;
    4950  virtual Vector calcDir(float t) = 0;
     51  virtual Vector calcAcc(float t) = 0;
    5052  virtual Quaternion calcQuat(float t) = 0;
    5153 
     54  // DEBUG
     55  void debug(void);
    5256};
    5357
     
    6973  Vector calcPos(float t);
    7074  Vector calcDir(float t);
     75  Vector calcAcc(float t);
    7176  Quaternion calcQuat(float t);
    7277 
     
    105110  Vector calcPos(float t);
    106111  Vector calcDir(float t);
     112  Vector calcAcc(float t);
    107113  Quaternion calcQuat(float t);
    108114 
  • orxonox/trunk/src/debug.h

    r3395 r3433  
    3434///////////////////////////////////////////////////
    3535
    36 #ifdef  DEBUG
     36#ifdef DEBUG
    3737extern int verbose;
    3838#define PRINTF(x) \
  • orxonox/trunk/src/environment.cc

    r3396 r3433  
    5555  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    5656  //rotate
    57   this->getAbsDir ().matrix (matrix);
     57  this->getAbsDir().matrix (matrix);
    5858  glMultMatrixf((float*)matrix);
    5959 
    60   glMatrixMode(GL_MODELVIEW);
    6160  this->model->draw();
    6261}
  • orxonox/trunk/src/game_loader.cc

    r3225 r3433  
    2525#include "command_node.h"
    2626#include "vector.h"
    27 #include "track.h"
    2827
    2928#include <string.h>
  • orxonox/trunk/src/gui/Makefile.in

    r3424 r3433  
    234234          esac; \
    235235        done; \
    236         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/gui/Makefile'; \
     236        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/gui/Makefile'; \
    237237        cd $(top_srcdir) && \
    238           $(AUTOMAKE) --foreign  src/gui/Makefile
     238          $(AUTOMAKE) --gnu  src/gui/Makefile
    239239.PRECIOUS: Makefile
    240240Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/importer/Makefile.in

    r3429 r3433  
    215215          esac; \
    216216        done; \
    217         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/importer/Makefile'; \
     217        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/importer/Makefile'; \
    218218        cd $(top_srcdir) && \
    219           $(AUTOMAKE) --foreign  src/importer/Makefile
     219          $(AUTOMAKE) --gnu  src/importer/Makefile
    220220.PRECIOUS: Makefile
    221221Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/p_node.cc

    r3370 r3433  
    214214*/
    215215Quaternion PNode::getAbsDir ()
    216 {}
     216{
     217  return this->absDirection;
     218}
    217219
    218220
  • orxonox/trunk/src/stdincl.h

    r3365 r3433  
    2222#endif
    2323
    24 #ifndef __APPLE__
    25 #include <SDL/SDL.h>
    26 #include <GL/gl.h>
    27 #include <GL/glu.h>
    28 #else
    29 #include <SDL.h>
    30 #include <OpenGL/gl.h>
    31 #include <OpenGL/glu.h>
    32 #endif
     24#include "glincl.h"
    3325
     26// MATH //
     27#include "matrix.h"
    3428#include "vector.h"
    35 #include "matrix.h"
    3629#include "curve.h"
    37 //#include "coordinates.h"
     30
    3831#include "list.h"
    3932#include "list_template.h"
    40 #include "error.h"
    41 #include "debug.h"
    4233#include "message_structures.h"
    4334#include "orxonox.h"
     
    4536#include "base_object.h"
    4637
     38#include "error.h"
     39#include "debug.h"
     40
    4741#endif /* _STDINCL_H */
  • orxonox/trunk/src/track_manager.cc

    r3365 r3433  
    1 
    2 
    31/*
    42   orxonox - the future of 3D-vertical-scrollers
     
    1210
    1311   ### File Specific:
    14    main-programmer: Patrick Boenzli
     12   main-programmer: Benjamin Grauer
    1513   co-programmer: ...
    1614*/
     
    1917#include "track_manager.h"
    2018#include <stdarg.h>
    21 
     19#include "p_node.h"
    2220
    2321using namespace std;
     
    3836  this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager.
    3937  this->duration = 1;
     38  this->endTime = 1;
     39  this->jumpTime = 0;
    4040  this->curveType = BEZIERCURVE;
    4141  this->nodeCount = 0;
    4242  this->childCount = 0;
    4343  this->name = NULL;
    44   this->startPoint = Vector(0,0,0);
    45   this->startTangentPoint = Vector(0,0,0);
    4644  this->curve = NULL;
    4745  this->children = NULL;
     
    111109  this->maxTime = 0;
    112110  this->trackElemCount = 1;
     111  this->bindSlave = NULL;
    113112}
    114113
     
    151150{
    152151  this->currentTrackElem->childCount = childCount;
     152  this->currentTrackElem->mainJoin = true;
    153153  this->currentTrackElem->children = new TrackElement*[childCount];
    154154  for (int i=0; i<childCount; i++)
     
    156156      this->currentTrackElem->children[i] = new TrackElement();
    157157      this->currentTrackElem->children[i]->ID = ++trackElemCount;
    158       this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->startingTime+this->currentTrackElem->duration;
    159       this->currentTrackElem->children[i]->startPoint = this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount());
    160       this->currentTrackElem->children[i]->startTangentPoint = (this->currentTrackElem->children[i]->startPoint *2) - this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()-1);
     158      this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->endTime + this->currentTrackElem->jumpTime;
     159      this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->children[i]);
    161160    }
    162161}
     
    193192   \brief curveType The Type to set
    194193*/
    195 void TrackManager::setCurveType(CurveType curveType)
    196 {
    197   if (!this->currentTrackElem->isFresh)
     194void TrackManager::setCurveType(CurveType curveType, TrackElement* trackElem)
     195{
     196  if (!trackElem->isFresh)
    198197    {
    199198      PRINTF(2)("It is not possible to change the type of a Curve after you have have appended some points to it\n");
    200199      return;
    201200    }
    202   this->currentTrackElem->curveType = curveType;
     201  trackElem->curveType = curveType;
    203202  switch (curveType)
    204203    {
    205204    case BEZIERCURVE:
    206       this->currentTrackElem->curve = new BezierCurve();
     205      trackElem->curve = new BezierCurve();
    207206      break;
    208207    case UPOINTCURVE:
    209       this->currentTrackElem->curve = new UPointCurve();
     208      trackElem->curve = new UPointCurve();
    210209      break;
    211210    }
     
    220219{
    221220  this->currentTrackElem->duration = time;
     221  this->currentTrackElem->endTime = this->currentTrackElem->startingTime + time;
    222222}
    223223
     
    240240  if (trackElem->isFresh)
    241241    {
    242       this->setCurveType(BEZIERCURVE);
     242      this->setCurveType(BEZIERCURVE, trackElem);
    243243      trackElem->isFresh = false;
    244       if(trackElem != this->firstTrackElem)
    245         {
    246           this->addPoint(trackElem->startPoint);
    247           this->addPoint(trackElem->startTangentPoint);
    248         }
    249244    }
    250245  trackElem->curve->addNode(newPoint);
     
    374369void TrackManager::joinV(unsigned int count, int* trackIDs)
    375370{
    376   printf("Joining %d tracks to Track %d\n", count, trackIDs[0]);
     371  printf("Joining %d tracks and merging to Track %d\n", count, trackIDs[0]);
    377372
    378373  // chanching work-on to temporary value. going back at the end.
    379374  int tmpCurrentWorkingID = this->currentTrackElem->ID;
    380375  this->workOn(trackIDs[0]);
    381 
    382376  TrackElement* firstJoint = this->currentTrackElem;
     377  float tmpLatestTime = firstJoint->endTime;
     378
    383379  Vector tmpEndPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount());
    384   Vector tmpTangentPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-1);
     380  Vector tmpTangentPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-1);
     381  Vector tmpc2Point = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-2);
    385382  firstJoint->isJoined = true;
    386   firstJoint->mainJoin = true;
     383  //  firstJoint->mainJoin = true;
    387384  if(!firstJoint->isHotPoint)
    388385    this->setSavePoint();
    389 
     386  // Timing:
     387  for (int i = 0; i < count; i++)
     388    {
     389      TrackElement* tmpJoinElem = this->findTrackElementByID(trackIDs[i]);
     390      if (tmpJoinElem->childCount == 0
     391          && tmpJoinElem->endTime > tmpLatestTime)
     392        tmpLatestTime = tmpJoinElem->endTime;
     393    }
     394  // time the main Join.
     395  firstJoint->jumpTime = tmpLatestTime - firstJoint->endTime;
     396 
     397  // Joining:
    390398  for (int i = 1; i < count; i++)
    391399    {
     
    395403      else
    396404        {
     405          this->addPoint(tmpc2Point, tmpJoinElem);
    397406          this->addPoint(tmpTangentPoint, tmpJoinElem);
    398407          this->addPoint(tmpEndPoint, tmpJoinElem);
     408          // time all other Joins
     409          tmpJoinElem->jumpTime = tmpLatestTime - tmpJoinElem->endTime;
    399410         
    400411          //Copying Joint-Info
     
    403414          tmpJoinElem->isSavePoint = firstJoint->isSavePoint;
    404415          tmpJoinElem->isFork = firstJoint->isFork;
    405          
     416
    406417          tmpJoinElem->isJoined = true;
    407418        }
    408419    }
     420  if(firstJoint->childCount > 0)
     421    for(int i = 0; i < firstJoint->childCount; i++)
     422      {
     423        printf("Setting startingTime of %d to %f.\n", firstJoint->children[i]->ID, tmpLatestTime);
     424        firstJoint->children[i]->startingTime = tmpLatestTime;
     425        firstJoint->children[i]->endTime = tmpLatestTime+firstJoint->children[i]->duration;
     426      }
     427
    409428  // returning to the TrackElement we were working on.
    410429  this->workOn(tmpCurrentWorkingID);
    411430}
    412431
     432/**
     433   \brief finalizes the TrackSystem. after this it will not be editable anymore
     434
     435   \todo check for any inconsistencies, output errors
     436*/
     437void TrackManager::finalize(void)
     438{
     439  for (int i = 1; i<= trackElemCount ;i++)
     440    {
     441      TrackElement* tmpElem = findTrackElementByID(i);
     442      if (tmpElem->childCount>0 && tmpElem->mainJoin)
     443        {
     444          for (int j = 0; j < tmpElem->childCount; j++)
     445            {
     446             
     447              // c1-continuity
     448              tmpElem->children[j]->curve->addNode(tmpElem->children[j]->curve->getNode(0) +
     449                                                   ((tmpElem->children[j]->curve->getNode(0) -
     450                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1))
     451                                                    ),2);
     452              tmpElem->children[j]->nodeCount++;
     453              // c2-continuity
     454              tmpElem->children[j]->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())-
     455                                                    tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) * 4 +
     456                                                   tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-2), 3);
     457              tmpElem->children[j]->nodeCount++;                                                   
     458              printf("accelerations: %d-in: count: %d, %f, %f, %f\n                  %d-out: count: %d %f, %f, %f\n",
     459                     tmpElem->ID, tmpElem->nodeCount,
     460                     tmpElem->curve->calcAcc(0.999).x, tmpElem->curve->calcAcc(0.999).y, tmpElem->curve->calcAcc(0.999).z,
     461                     tmpElem->children[j]->ID, tmpElem->children[j]->nodeCount,
     462                     tmpElem->children[j]->curve->calcAcc(0).x, tmpElem->children[j]->curve->calcAcc(0).y, tmpElem->children[j]->curve->calcAcc(0).z);
     463            }
     464        }
     465    }
     466}
     467
     468
    413469// RUNTIME //
    414470
     
    429485Vector TrackManager::calcDir() const
    430486{
    431   return this->currentTrackElem->curve->calcDir((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
     487  return this->currentTrackElem->curve->calcDir((this->localTime - this->currentTrackElem->startingTime)/this->currentTrackElem->duration);
    432488}
    433489
     
    440496void TrackManager::tick(float dt)
    441497{
     498  dt /= 1000;
     499  printf("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
    442500  if (this->localTime <= this->firstTrackElem->duration)
    443501    this->jumpTo(this->localTime);
    444502  this->localTime += dt;
    445   if (this->localTime > this->currentTrackElem->startingTime + this->currentTrackElem->duration && this->currentTrackElem->childCount > 0)
    446     this->currentTrackElem = this->currentTrackElem->children[0];
     503  if (this->localTime > this->currentTrackElem->endTime
     504      && this->currentTrackElem->children)
     505    {
     506      if (this->currentTrackElem->jumpTime > 0)
     507        this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
     508      this->currentTrackElem = this->currentTrackElem->children[0];
     509    }
     510  if (this->bindSlave)
     511    {
     512      Vector tmp = this->calcPos();
     513      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));
     514      this->bindSlave->setAbsCoor(&tmp);
     515      this->bindSlave->setAbsDir(&quat);
     516    }
    447517}
    448518
     
    471541}
    472542
     543/**
     544   \brief Sets the PNode, that should be moved along the Tack
     545   \param bindSlave the PNode to set
     546*/
     547void TrackManager::setBindSlave(PNode* bindSlave)
     548{
     549  if (!this->bindSlave)
     550    this->bindSlave = bindSlave;
     551}
    473552
    474553
     
    500579}
    501580
     581/**
     582   \brief outputs debug information about the trackManager
     583   \param level how much debug
     584*/
    502585void TrackManager::debug(unsigned int level) const
    503586{
     
    516599          if(tmpElem->isFresh)
    517600            printf("   has not jet eddited in any way\n");
    518           printf("\n   TimeTable: starting at = %f; ends at = %f; duration = %f\n", tmpElem->startingTime, tmpElem->startingTime+tmpElem->duration, tmpElem->duration);
     601          printf("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", tmpElem->startingTime, tmpElem->endTime, tmpElem->duration, tmpElem->jumpTime);
    519602          printf("   consists of %d Points\n", tmpElem->nodeCount);
    520603          if (tmpElem->childCount == 0)
     
    536619          if(tmpElem->isFork)
    537620            {
    538               printf("    is A Fork with with %d children.", tmpElem->childCount);
     621              printf("    is A Fork with with %d children.\n", tmpElem->childCount);
    539622            }
    540623          if(tmpElem->isJoined)
  • orxonox/trunk/src/track_manager.h

    r3365 r3433  
    1414#include "stdincl.h"
    1515
     16class PNode;
    1617
    1718//! condition for choosing a certain Path. \todo implement a useful way.
     
    4546  float startingTime;        //!< The time at which this Track begins.
    4647  float duration;            //!< The time used to cross this TrackElement (curve).
     48  float endTime;             //!< The time at which this Track ends.
     49  float jumpTime;            //!< The Time this Track has to jump to its preceding Track (only >0 if Track isJoined==true)
    4750  CurveType curveType;       //!< The CurveType this will have.
    4851  int nodeCount;             //!< The count of points this TrackElement has.
    4952  char* name;                //!< A name for the Trac.
    50   Vector startPoint;         //!< A Vector that Points to the first point of the containing Curve. (for c1-steadiness)
    51   Vector startTangentPoint;  //!< A Vector that points into the direction of the previous Curve. (for c1-steadiness)
    5253  Curve* curve;              //!< The Curve of this TrackElement
    5354  int childCount;            //!< The number of Children This TrackElement has.
     
    5960//! The TrackManager handles the flow of the Players through the game.
    6061/**
    61    \todo write the methodes
    6262
    6363   <b>The TrackManager works as followed:</b> \n
     
    104104  float maxTime;                      //!< The maximal time the track has.
    105105  int trackElemCount;                 //!< The count of TrackElements that exist.
     106  PNode* bindSlave;
    106107 
    107108  void initChildren(unsigned int childCount);
     
    115116  // Methods to change the Path (initialisation)
    116117  void workOn(unsigned int trackID);
    117   void setCurveType(CurveType curveType);
     118  inline void setCurveType(CurveType curveType) { this->setCurveType (curveType, this->currentTrackElem);}
     119  void setCurveType(CurveType curveType, TrackElement* trackElem);
    118120  void setDuration(float time);
    119121  bool addPoint(Vector newPoint);
     
    126128  void join(unsigned int count, ...);
    127129  void joinV(unsigned int count, int* trackIDs);
     130  void finalize(void);
    128131
    129132  // Methods to calculate the position on the Path (runtime)
     
    134137  void choosePath(int graphID);
    135138
     139  void setBindSlave(PNode* bindSlave);
     140
    136141  // DEBUG //
    137142  void drawGraph(float dt) const;
  • orxonox/trunk/src/world.cc

    r3429 r3433  
    1919#include "collision.h"
    2020#include "track_manager.h"
    21 #include "track.h"
    2221#include "player.h"
    2322#include "command_node.h"
     
    143142void World::destroy()
    144143{
     144  delete trackManager;
    145145}
    146146
     
    180180      trackManager->addPoint(Vector(30,0,5));
    181181      trackManager->addPoint(Vector(40,0,5));
    182       trackManager->setDuration(.5);
     182      trackManager->setDuration(2);
    183183      trackManager->setSavePoint();
    184184      trackManager->addPoint(Vector(50,10,10));
     
    187187      trackManager->addPoint(Vector(80,0,-10));
    188188      trackManager->addPoint(Vector(90,0,-10));
    189       trackManager->setDuration(.5);
     189      trackManager->setDuration(5);
    190190      trackManager->setSavePoint();
    191191      trackManager->addPoint(Vector(110,0,5));
     
    194194      trackManager->addPoint(Vector(140,0,-10));
    195195      trackManager->addPoint(Vector(150,0,-10));
    196       trackManager->setDuration(.5);
     196      trackManager->setDuration(3);
    197197      int fork11, fork12, fork13, fork14;
    198198      trackManager->fork(4, &fork11, &fork12, &fork13, &fork14);
     
    200200      trackManager->addPoint(Vector(170, 0, -15));
    201201      trackManager->addPoint(Vector(180, 0, -15));
     202      trackManager->setDuration(3);
    202203      trackManager->workOn(fork12);
    203204      trackManager->addPoint(Vector(170, 0, 10));
     
    205206      trackManager->addPoint(Vector(190,2,5));
    206207      trackManager->addPoint(Vector(200,2,5));
     208      trackManager->setDuration(7);
    207209      int fork21, fork22;
    208210      trackManager->fork(2, &fork21, &fork22);
     
    213215      trackManager->addPoint(Vector(250, 0, 0));
    214216      trackManager->addPoint(Vector(260, 0, 5));
     217      trackManager->setDuration(3);
    215218      trackManager->join(2, fork12, fork11);
    216219      trackManager->workOn(fork22);
     
    219222      trackManager->addPoint(Vector(240, 0, 10));
    220223      trackManager->addPoint(Vector(250, 0, 5));
     224      trackManager->setDuration(6);
    221225      trackManager->workOn(fork13);
    222226      trackManager->addPoint(Vector(200,-10,5));
    223227      trackManager->addPoint(Vector(250,-10,5));
    224       printf("fork14: %d\n", fork14);
     228      trackManager->setDuration(3);
    225229      trackManager->workOn(fork14);
    226230      trackManager->addPoint(Vector(200,15,0));
    227231      trackManager->addPoint(Vector(210,0,10));
    228 
    229 
    230 
     232      trackManager->setDuration(1);
    231233      trackManager->join(4, fork21, fork22, fork13, fork14);
    232 
     234      trackManager->workOn(10);
     235      trackManager->addPoint(Vector(250,-10,5));
     236      trackManager->addPoint(Vector(260,-10,5));
     237      trackManager->finalize();
     238     
    233239      /*monitor progress*/
    234240      this->glmis->step();
    235241
    236242      /*
    237       tmpCurve->addNode(Vector(10,0,-10));
    238       //tmpCurve->addNode(Vector(10,2,5));
    239       //tmpCurve->addNode(Vector(10,3,-5));
    240       //      tmpCurve->addNode(Vector(10,1,5));
    241       tmpCurve->addNode(Vector(10,0,5));
     243        tmpCurve->addNode(Vector(10,  -1,  -1));
     244        tmpCurve->addNode(Vector(10,  -2,   2));
     245        tmpCurve->addNode(Vector(10,   3,   3));
     246        tmpCurve->addNode(Vector(10,   4,  -4), 0);
     247        tmpCurve->addNode(Vector(10,  -1,  -1));
     248        tmpCurve->addNode(Vector(10,  -2,   2));
     249        tmpCurve->addNode(Vector(10,   3,   3));
     250        tmpCurve->addNode(Vector(10,   4,  -4), 0);
     251        tmpCurve->debug();
    242252      */
    243253      switch(this->debugWorldNr)
     
    254264            this->nullParent->setName ("NullParent");
    255265
    256             // create some path nodes
    257             this->pathnodes = new Vector[6];
    258             this->pathnodes[0] = Vector(0, 0, 0);
    259             this->pathnodes[1] = Vector(1000, 0, 0);
    260             //      this->pathnodes[2] = Vector(-100, 140, 0);
    261             //      this->pathnodes[3] = Vector(0, 180, 0);
    262             //      this->pathnodes[4] = Vector(100, 140, 0);
    263             //      this->pathnodes[5] = Vector(100, 40, 0);
    264            
    265             // create the tracks
    266             this->tracklen = 2;
    267             this->track = new Track[2];
    268             for( int i = 0; i < this->tracklen; i++)
    269               {
    270                 this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
    271               }
    272266            // !\todo old track-system has to be removed
    273267
     
    281275            this->spawn (myPlayer);
    282276            this->localPlayer = myPlayer;
    283 
    284277            /*monitor progress*/
    285278            this->glmis->step();           
     
    309302            /*monitor progress*/
    310303            this->glmis->step();
     304
     305            trackManager->setBindSlave(env);
    311306
    312307            break;
     
    338333
    339334
    340 
    341             // create the tracks
    342             this->tracklen = 6;
    343             this->track = new Track[6];
    344             for( int i = 0; i < this->tracklen; i++)
    345               {
    346                 this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
    347               }
    348335
    349336            // create a player
     
    543530    }
    544531  */ 
    545   //draw track
    546   glBegin(GL_LINES);
    547   glColor3f(0.0, 1.0, 1.0);
    548   for( int i = 0; i < tracklen; i++)
    549     {
    550       glVertex3f(pathnodes[i].x,pathnodes[i].y,pathnodes[i].z);
    551       glVertex3f(pathnodes[(i+1)%tracklen].x,pathnodes[(i+1)%tracklen].y,pathnodes[(i+1)%tracklen].z);
    552     }
    553   glEnd();
    554  
    555532  /*
    556533  glBegin(GL_LINE_STRIP);
     
    565542  trackManager->drawGraph(.01);
    566543  trackManager->debug(2);
    567   delete trackManager;
    568  
    569   /*
     544  /* 
    570545  glBegin(GL_LINES);
    571546  float i;
     
    678653          t = loc->part;
    679654         
    680           if( t >= tracklen )
     655          if( t >= traclen )
    681656            {
    682657              printf("An entity is out of the game area\n");
     
    736711void World::unload()
    737712{
    738   if( pathnodes) delete []pathnodes;
    739   if( track) delete []pathnodes;
    740 }
    741 
    742 
    743 void World::setTrackLen(Uint32 len)
    744 {
    745   this->tracklen = len;
    746 }
    747 
    748 int World::getTrackLen()
    749 {
    750   return this->tracklen;
    751 }
    752 
     713
     714}
    753715
    754716
     
    910872      this->update ();
    911873      this->localCamera->timeSlice(dt);
     874      this->trackManager->tick(dt);
    912875    }
    913876  this->lastFrame = currentFrame;
  • orxonox/trunk/src/world.h

    r3419 r3433  
    1212
    1313class TrackManager;
    14 class Track;
    1514class WorldEntity;
    1615class Camera;
     
    4948  virtual void releaseLoadScreen();
    5049 
    51   void setTrackLen (Uint32 tracklen);
    52   int getTrackLen ();
    5350  //bool system_command (Command* cmd);
    5451  Camera* getCamera ();
     
    6158  // base level data
    6259  TrackManager* trackManager;
    63   Track* track;
    64   Uint32 tracklen;   // number of Tracks the World consist of
    6560  Vector* pathnodes;
    6661  Camera* localCamera; 
Note: See TracChangeset for help on using the changeset viewer.