Changeset 3321 in orxonox.OLD for orxonox/branches/parenting/src
- Timestamp:
- Jan 3, 2005, 12:25:49 PM (20 years ago)
- Location:
- orxonox/branches/parenting/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/parenting/src/curve.cc
r3320 r3321 50 50 BezierCurve::BezierCurve (void) 51 51 { 52 nodeCount = 0; 53 firstNode = new PathNode; 54 currentNode = firstNode; 52 this->derivation = 0; 53 dirCurve = new BezierCurve(1); 54 this->init(); 55 } 55 56 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 */ 60 BezierCurve::BezierCurve (int derivation) 61 { 62 this->derivation = derivation; 63 dirCurve=NULL; 64 this->init(); 61 65 } 62 66 … … 76 80 delete tmpNode; 77 81 } 82 if (dirCurve) 83 delete dirCurve; 84 } 85 86 /** 87 \brief Initializes a BezierCurve 88 */ 89 void 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; 78 100 } 79 101 … … 85 107 PathNode* tmpNode = firstNode; 86 108 109 // rebuilding the Curve itself 87 110 int k=0; 88 111 int binCoef = 1; … … 96 119 tmpNode->factor = binCoef; 97 120 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 } 98 139 } 99 140 } … … 134 175 Vector BezierCurve::calcDir (float t) 135 176 { 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); 155 178 } 156 179 -
orxonox/branches/parenting/src/curve.h
r3320 r3321 20 20 Vector curvePoint; //!< The point on the Cureve at a local Time. 21 21 float localTime; //!< If the time of one point is asked more than once the programm will not calculate it again. 22 Curve* dirCurve; //!< The derivation-curve of this Curve. 23 int derivation; //!< Which derivation of a Curve is this. 22 24 23 25 //! Handles the curve-points (dynamic List) … … 52 54 public: 53 55 BezierCurve(void); 56 BezierCurve(int derivation); 54 57 ~BezierCurve(void); 58 void init(void); 55 59 56 60 Vector calcPos(float t); -
orxonox/branches/parenting/src/world.cc
r3319 r3321 159 159 testCurve->addNode(Vector(20, 0,10)); 160 160 testCurve->addNode(Vector(50, 7,-5)); 161 testCurve->addNode(Vector(60, -20,0)); 162 testCurve->addNode(Vector(60, 10,0)); 161 163 162 164 this->nullParent = NullParent::getInstance (); … … 448 450 for(float i=0.0; i<1; i+=.01) 449 451 { 452 printf("%f %f %f\n",testCurve->calcDir(i).x,testCurve->calcDir(i).y,testCurve->calcDir(i).z); 450 453 glVertex3f(testCurve->calcPos(i).x, testCurve->calcPos(i).y, testCurve->calcPos(i).z); 454 glVertex3f(testCurve->calcPos(i).x+testCurve->calcDir(i).x, testCurve->calcPos(i).y+testCurve->calcDir(i).y, testCurve->calcPos(i).z+testCurve->calcDir(i).z); 451 455 } 452 456 glEnd();
Note: See TracChangeset
for help on using the changeset viewer.