Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3321 in orxonox.OLD for orxonox/branches/parenting/src/curve.cc


Ignore:
Timestamp:
Jan 3, 2005, 12:25:49 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/parenting: derivation-curve implemented.

File:
1 edited

Legend:

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

    r3320 r3321  
    5050BezierCurve::BezierCurve (void)
    5151{
    52   nodeCount = 0;
    53   firstNode = new PathNode;
    54   currentNode = firstNode;
     52  this->derivation = 0;
     53  dirCurve = new BezierCurve(1);
     54  this->init();
     55}
    5556
    56   firstNode->position = Vector (.0, .0, .0);
    57   firstNode->number = 0;
    58   firstNode->next = 0; // not sure if this really points to NULL!!
    59 
    60   return;
     57/**
     58   \brief Creates a new BezierCurve-Derivation-Curve
     59*/
     60BezierCurve::BezierCurve (int derivation)
     61{
     62  this->derivation = derivation;
     63  dirCurve=NULL;
     64  this->init();
    6165}
    6266
     
    7680      delete tmpNode;
    7781    }
     82  if (dirCurve)
     83    delete dirCurve;
     84}
     85
     86/**
     87   \brief Initializes a BezierCurve
     88*/
     89void BezierCurve::init(void)
     90{
     91  nodeCount = 0;
     92  firstNode = new PathNode;
     93  currentNode = firstNode;
     94
     95  firstNode->position = Vector (.0, .0, .0);
     96  firstNode->number = 0;
     97  firstNode->next = 0; // not sure if this really points to NULL!!
     98
     99  return;
    78100}
    79101
     
    85107  PathNode* tmpNode = firstNode;
    86108
     109  // rebuilding the Curve itself
    87110  int k=0;
    88111  int binCoef = 1;
     
    96119      tmpNode->factor = binCoef;
    97120      tmpNode = tmpNode->next;
     121    }
     122
     123  // rebuilding the Derivation curve
     124  if(this->derivation == 0)
     125    {
     126      tmpNode = firstNode;
     127      delete dirCurve;
     128      dirCurve = new BezierCurve(1);
     129      while(tmpNode->next)
     130        {
     131          Vector tmpVector = (tmpNode->next->position)- (tmpNode->position);
     132          tmpVector.x*=(float)nodeCount;
     133          tmpVector.y*=(float)nodeCount;
     134          tmpVector.z*=(float)nodeCount;
     135          tmpVector.normalize();
     136          this->dirCurve->addNode(tmpVector);
     137          tmpNode = tmpNode->next;
     138        }
    98139    }
    99140}
     
    134175Vector BezierCurve::calcDir (float t)
    135176{
    136   PathNode* tmpNode = firstNode;
    137   BezierCurve* tmpCurve = new BezierCurve();
    138   Vector ret;
    139   Vector tmpVector;
    140 
    141   while (tmpNode->next != 0)
    142     {
    143       tmpVector = (tmpNode->next->position)- (tmpNode->position);
    144       tmpVector.x*=(float)nodeCount;
    145       tmpVector.y*=(float)nodeCount;
    146       tmpVector.z*=(float)nodeCount;
    147 
    148       tmpCurve->addNode(tmpVector);
    149       tmpNode = tmpNode->next;
    150     }
    151   ret = tmpCurve->calcPos(t);
    152   ret.normalize();
    153 
    154   return ret;
     177  return static_cast<BezierCurve*>(dirCurve)->calcPos(t);
    155178}
    156179
Note: See TracChangeset for help on using the changeset viewer.