Changeset 3321 in orxonox.OLD for orxonox/branches/parenting/src/curve.cc
- Timestamp:
- Jan 3, 2005, 12:25:49 PM (19 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.