Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3375 in orxonox.OLD for orxonox/branches/trackManager/src


Ignore:
Timestamp:
Jan 8, 2005, 4:00:29 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/trackManager: now curve-points can be inserted wherever you want.

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

Legend:

Unmodified
Added
Removed
  • orxonox/branches/trackManager/src/curve.cc

    r3374 r3375  
    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);
     44  this->rebuild();
     45  return;
     46}
     47
     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;
    4485  this->rebuild();
    4586  return;
     
    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///////////////////////////////////
  • orxonox/branches/trackManager/src/curve.h

    r3374 r3375  
    4343  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;}
     
    5152  virtual Quaternion calcQuat(float t) = 0;
    5253 
     54  // DEBUG
     55  void debug(void);
    5356};
    5457
  • orxonox/branches/trackManager/src/track_manager.cc

    r3374 r3375  
    466466    {
    467467      Vector tmp = this->calcPos();
    468       Quaternion quat = Quaternion(this->calcDir(), Vector(0,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
     468      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));
    469469      this->bindSlave->setAbsCoor(&tmp);
    470470      this->bindSlave->setAbsDir(&quat);
  • orxonox/branches/trackManager/src/world.cc

    r3374 r3375  
    230230     
    231231      /*
    232       tmpCurve->addNode(Vector(10,0,-10));
    233       //tmpCurve->addNode(Vector(10,2,5));
    234       //tmpCurve->addNode(Vector(10,3,-5));
    235       //      tmpCurve->addNode(Vector(10,1,5));
    236       tmpCurve->addNode(Vector(10,0,5));
     232        tmpCurve->addNode(Vector(10,  -1,  -1));
     233        tmpCurve->addNode(Vector(10,  -2,   2));
     234        tmpCurve->addNode(Vector(10,   3,   3));
     235        tmpCurve->addNode(Vector(10,   4,  -4), 0);
     236        tmpCurve->addNode(Vector(10,  -1,  -1));
     237        tmpCurve->addNode(Vector(10,  -2,   2));
     238        tmpCurve->addNode(Vector(10,   3,   3));
     239        tmpCurve->addNode(Vector(10,   4,  -4), 0);
     240        tmpCurve->debug();
    237241      */
    238242      switch(this->debugWorldNr)
     
    509513  trackManager->drawGraph(.01);
    510514  trackManager->debug(2);
    511  
    512   /*
     515  /* 
    513516  glBegin(GL_LINES);
    514517  float i;
Note: See TracChangeset for help on using the changeset viewer.