Changeset 3355 in orxonox.OLD for orxonox/branches
- Timestamp:
- Jan 6, 2005, 1:52:47 PM (20 years ago)
- Location:
- orxonox/branches/parenting/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/parenting/src/curve.cc
r3351 r3355 164 164 \param t The position on the Curve (0<=t<=1) 165 165 \return the Position on the Path 166 \todo implement nodeCount 0,1,2,3167 166 */ 168 167 Vector BezierCurve::calcPos(float t) 169 168 { 170 if (nodeCount < 4)171 {172 // if (verbose >= 1)173 // printf ("Please define at least 4 nodes, until now you have only defined %i.\n", nodeCount);174 return Vector(0,0,0);175 }176 PathNode* tmpNode = firstNode;177 169 Vector ret = Vector(0.0,0.0,0.0); 178 double factor = pow(1.0-t,nodeCount-1); 179 while(tmpNode) 180 { 181 ret.x += tmpNode->factor * factor * tmpNode->position.x; 182 ret.y += tmpNode->factor * factor * tmpNode->position.y; 183 ret.z += tmpNode->factor * factor * tmpNode->position.z; 184 factor *= t/(1.0-t); // same as pow but much faster. 185 186 tmpNode = tmpNode->next; 187 } 170 if (this->nodeCount >= 3) 171 { 172 PathNode* tmpNode = this->firstNode; 173 double factor = pow(1.0-t,nodeCount-1); 174 while(tmpNode) 175 { 176 ret.x += tmpNode->factor * factor * tmpNode->position.x; 177 ret.y += tmpNode->factor * factor * tmpNode->position.y; 178 ret.z += tmpNode->factor * factor * tmpNode->position.z; 179 factor *= t/(1.0-t); // same as pow but much faster. 180 181 tmpNode = tmpNode->next; 182 } 183 } 184 else if (nodeCount == 2) 185 { 186 ret = this->firstNode->position *(1.0-t); 187 ret = ret + this->firstNode->next->position * t; 188 } 189 else if (nodeCount == 1) 190 ret = this->firstNode->position; 188 191 return ret; 189 192 } -
orxonox/branches/parenting/src/track_manager.cc
r3354 r3355 180 180 void TrackManager::workOn(unsigned int trackID) 181 181 { 182 this->currentTrackElem = findTrackElementByID(trackID); 183 printf("now Working on %d\n", trackID); 182 TrackElement* tmpElem = findTrackElementByID(trackID); 183 if (tmpElem) 184 this->currentTrackElem = tmpElem; 185 else 186 printf("TrackElement not Found, leaving unchanged\n"); 187 printf("now Working on %d\n", this->currentTrackElem->ID); 188 184 189 } 185 190 -
orxonox/branches/parenting/src/world.cc
r3354 r3355 244 244 trackManager->addPoint(Vector(150,0,-10)); 245 245 trackManager->setDuration(.5); 246 int fork11, fork12 ;247 trackManager->fork( 2, &fork11, &fork12);246 int fork11, fork12, fork13; 247 trackManager->fork(3, &fork11, &fork12, &fork13); 248 248 trackManager->workOn(fork11); 249 249 trackManager->addPoint(Vector(170, 0, -15)); … … 254 254 trackManager->addPoint(Vector(190,2,5)); 255 255 trackManager->addPoint(Vector(200,2,5)); 256 trackManager->setSavePoint(); 256 int fork21, fork22; 257 trackManager->fork(2, &fork21, &fork22); 258 trackManager->workOn(fork21); 257 259 trackManager->addPoint(Vector(220, 10,-10)); 258 260 trackManager->addPoint(Vector(230, 0,-10)); 259 261 trackManager->addPoint(Vector(240, 0, 2)); 260 262 trackManager->addPoint(Vector(250, 0, 0)); 263 trackManager->addPoint(Vector(260, 0, 5)); 261 264 trackManager->join(2, fork12, fork11); 262 265 trackManager->workOn(fork22); 266 trackManager->addPoint(Vector(220, -10,10)); 267 trackManager->addPoint(Vector(230, 0, 10)); 268 trackManager->addPoint(Vector(240, 0, 10)); 269 trackManager->addPoint(Vector(250, 0, 5)); 270 trackManager->workOn(fork13); 271 trackManager->addPoint(Vector(200,-10,5)); 272 trackManager->addPoint(Vector(250,-10,5)); 273 trackManager->join(3, fork21, fork22, fork13); 263 274 /* 264 275 tmpCurve->addNode(Vector(10,0,-10)); 265 tmpCurve->addNode(Vector(10,2,5));266 tmpCurve->addNode(Vector(10,3,-5));267 tmpCurve->addNode(Vector(10,1,5));276 //tmpCurve->addNode(Vector(10,2,5)); 277 //tmpCurve->addNode(Vector(10,3,-5)); 278 // tmpCurve->addNode(Vector(10,1,5)); 268 279 tmpCurve->addNode(Vector(10,0,5)); 269 280 */ … … 563 574 } 564 575 glEnd(); 565 576 566 577 /* 567 578 glBegin(GL_LINE_STRIP); … … 576 587 trackManager->drawGraph(.01); 577 588 trackManager->debug(2); 589 // delete trackManager; 590 578 591 /* 579 592 glBegin(GL_LINES); … … 584 597 glVertex3f(tmpCurve->calcPos(i).x, tmpCurve->calcPos(i).y, tmpCurve->calcPos(i).z); 585 598 } 599 glEnd(); 586 600 */ 587 glEnd();588 601 glEndList(); 589 602 }
Note: See TracChangeset
for help on using the changeset viewer.