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/lib/math/curve.cc

    r3499 r3605  
    1919     local-Time implementation
    2020     NURBS
     21     tList implementation
    2122     
    2223*/
    2324
     25#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_MATH
     26
    2427#include "curve.h"
    25 #include "matrix.h"
     28
    2629#include "debug.h"
    2730
    2831#include <math.h>
    2932#include <stdio.h>
     33
     34
     35/**
     36    \brief default constructor for a Curve
     37*/
     38Curve::Curve(void)
     39{
     40  nodeCount = 0;
     41  firstNode = new PathNode;
     42  currentNode = firstNode;
     43
     44  firstNode->position = Vector (.0, .0, .0);
     45  firstNode->number = 0;
     46  firstNode->next = 0; // not sure if this really points to NULL!!
     47}
    3048
    3149/**
     
    131149  this->derivation = 0;
    132150  dirCurve = new BezierCurve(1);
    133   this->init();
    134151}
    135152
     
    141158  this->derivation = derivation;
    142159  dirCurve=NULL;
    143   this->init();
    144160}
    145161
     
    161177  if (dirCurve)
    162178    delete dirCurve;
    163 }
    164 
    165 /**
    166    \brief Initializes a BezierCurve
    167 */
    168 void BezierCurve::init(void)
    169 {
    170   nodeCount = 0;
    171   firstNode = new PathNode;
    172   currentNode = firstNode;
    173 
    174   firstNode->position = Vector (.0, .0, .0);
    175   firstNode->number = 0;
    176   firstNode->next = 0; // not sure if this really points to NULL!!
    177 
    178   return;
    179179}
    180180
     
    285285  return curvePoint;
    286286}
    287 
    288 
    289 
    290 ///////////////////////////////////
    291 //// Uniform Point curve  /////////
    292 ///////////////////////////////////
    293 /**
    294    \brief Creates a new UPointCurve
    295 */
    296 UPointCurve::UPointCurve (void)
    297 {
    298   this->derivation = 0;
    299   this->init();
    300 }
    301 
    302 /**
    303    \brief Creates a new UPointCurve-Derivation-Curve of deriavation'th degree
    304 */
    305 UPointCurve::UPointCurve (int derivation)
    306 {
    307   this->derivation = derivation;
    308   dirCurve=NULL;
    309   this->init();
    310 }
    311 
    312 /**
    313    \brief Deletes a UPointCurve.
    314 
    315    It does this by freeing all the space taken over from the nodes
    316 */
    317 UPointCurve::~UPointCurve(void)
    318 {
    319   PathNode* tmpNode;
    320   currentNode = firstNode;
    321   while (tmpNode != 0)
    322     {
    323       tmpNode = currentNode;
    324       currentNode = currentNode->next;
    325       delete tmpNode;
    326     }
    327   if (dirCurve)
    328     delete dirCurve;
    329 }
    330 
    331 /**
    332    \brief Initializes a UPointCurve
    333 */
    334 void UPointCurve::init(void)
    335 {
    336   nodeCount = 0;
    337   firstNode = new PathNode;
    338   currentNode = firstNode;
    339 
    340   firstNode->position = Vector (.0, .0, .0);
    341   firstNode->number = 0;
    342   firstNode->next = 0; // not sure if this really points to NULL!!
    343 
    344   return;
    345 }
    346 
    347 /**
    348    \brief Rebuilds a UPointCurve
    349    
    350    \todo very bad algorithm
    351 */
    352 void UPointCurve::rebuild(void)
    353 {
    354   // rebuilding the Curve itself
    355   PathNode* tmpNode = this->firstNode;
    356   int i=0;
    357   Matrix xTmpMat = Matrix(this->nodeCount, this->nodeCount);
    358   Matrix yTmpMat = Matrix(this->nodeCount, this->nodeCount);
    359   Matrix zTmpMat = Matrix(this->nodeCount, this->nodeCount);
    360   Matrix xValMat = Matrix(this->nodeCount, 3);
    361   Matrix yValMat = Matrix(this->nodeCount, 3);
    362   Matrix zValMat = Matrix(this->nodeCount, 3);
    363   while(tmpNode)
    364     {
    365       Vector fac = Vector(1,1,1);
    366       for (int j = 0; j < this->nodeCount; j++)
    367         {
    368           xTmpMat(i,j) = fac.x; fac.x *= (float)i/(float)this->nodeCount;//tmpNode->position.x;
    369           yTmpMat(i,j) = fac.y; fac.y *= (float)i/(float)this->nodeCount;//tmpNode->position.y;
    370           zTmpMat(i,j) = fac.z; fac.z *= (float)i/(float)this->nodeCount;//tmpNode->position.z;
    371         }
    372       xValMat(i,0) = tmpNode->position.x;
    373       yValMat(i,0) = tmpNode->position.y;
    374       zValMat(i,0) = tmpNode->position.z;
    375       ++i;
    376       tmpNode = tmpNode->next;
    377     }
    378   tmpNode = this->firstNode;
    379   xValMat = xTmpMat.Inv() *= xValMat;
    380   yValMat = yTmpMat.Inv() *= yValMat;
    381   zValMat = zTmpMat.Inv() *= zValMat;
    382   i = 0;
    383   while(tmpNode)
    384     {
    385       tmpNode->vFactor.x = xValMat(i,0);
    386       tmpNode->vFactor.y = yValMat(i,0);
    387       tmpNode->vFactor.z = zValMat(i,0);
    388 
    389       i++;
    390       tmpNode = tmpNode->next;
    391     }
    392 }
    393 
    394 /**
    395    \brief calculates the Position on the curve
    396    \param t The position on the Curve (0<=t<=1)
    397    \return the Position on the Path
    398 */
    399 Vector UPointCurve::calcPos(float t)
    400 {
    401   PathNode* tmpNode = firstNode;
    402   Vector ret = Vector(0.0,0.0,0.0);
    403   float factor = 1.0;
    404   while(tmpNode)
    405     {
    406       ret.x += tmpNode->vFactor.x * factor;
    407       ret.y += tmpNode->vFactor.y * factor;
    408       ret.z += tmpNode->vFactor.z * factor;
    409       factor *= t;
    410 
    411       tmpNode = tmpNode->next;
    412     }
    413   return ret;
    414 }
    415 
    416 /**
    417    \brief Calulates the direction of the Curve at time t.
    418    \param The time at which to evaluate the curve.
    419    \returns The vvaluated Vector.
    420 */
    421 Vector UPointCurve::calcDir (float t)
    422 {
    423   PathNode* tmpNode = firstNode;
    424   Vector ret = Vector(0.0,0.0,0.0);
    425   float factor = 1.0/t;
    426   int k=0;
    427   while(tmpNode)
    428     {
    429       ret.x += tmpNode->vFactor.x * factor *k;
    430       ret.y += tmpNode->vFactor.y * factor *k;
    431       ret.z += tmpNode->vFactor.z * factor *k;
    432       factor *= t;
    433       k++;
    434       tmpNode = tmpNode->next;
    435     }
    436   ret.normalize();
    437   return ret;
    438 }
    439 
    440 Vector UPointCurve::calcAcc (float t)
    441 {
    442 }
    443 
    444 /**
    445    \brief Calculates the Quaternion needed for our rotations
    446    \param t The time at which to evaluate the cuve.
    447    \returns The evaluated Quaternion.
    448 */
    449 Quaternion UPointCurve::calcQuat (float t)
    450 {
    451   return Quaternion (calcDir(t), Vector(0,0,1));
    452 }
    453 
    454 
    455 /**
    456   \brief returns the Position of the point calculated on the Curve
    457   \return a Vector to the calculated position
    458 */
    459 Vector UPointCurve::getPos(void) const
    460 {
    461   return curvePoint;
    462 }
Note: See TracChangeset for help on using the changeset viewer.