Changeset 3373 in orxonox.OLD for orxonox/branches
- Timestamp:
- Jan 7, 2005, 5:17:27 PM (20 years ago)
- Location:
- orxonox/branches/trackManager/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/trackManager/src/track_manager.cc
r3372 r3373 38 38 this->startingTime = 0; //!< \todo eventually set this to the max time of TrackManager. 39 39 this->duration = 1; 40 this->endTime = 1; 41 this->jumpTime = 0; 40 42 this->curveType = BEZIERCURVE; 41 43 this->nodeCount = 0; 42 44 this->childCount = 0; 43 45 this->name = NULL; 44 this->startPoint = Vector(0,0,0);45 this->startTangentPoint = Vector(0,0,0);46 46 this->curve = NULL; 47 47 this->children = NULL; … … 157 157 this->currentTrackElem->children[i] = new TrackElement(); 158 158 this->currentTrackElem->children[i]->ID = ++trackElemCount; 159 this->currentTrackElem->children[i]->startingTime = this->currentTrackElem-> startingTime+this->currentTrackElem->duration;160 this-> currentTrackElem->children[i]->startPoint = this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount());161 this-> currentTrackElem->children[i]->startTangentPoint = (this->currentTrackElem->children[i]->startPoint *2) - this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()-1);159 this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->endTime; 160 this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->children[i]); 161 this->addPoint((this->currentTrackElem->children[i]->curve->getNode(0) *2) - this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()-1), this->currentTrackElem->children[i]); 162 162 } 163 163 } … … 194 194 \brief curveType The Type to set 195 195 */ 196 void TrackManager::setCurveType(CurveType curveType )197 { 198 if (!t his->currentTrackElem->isFresh)196 void TrackManager::setCurveType(CurveType curveType, TrackElement* trackElem) 197 { 198 if (!trackElem->isFresh) 199 199 { 200 200 PRINTF(2)("It is not possible to change the type of a Curve after you have have appended some points to it\n"); 201 201 return; 202 202 } 203 t his->currentTrackElem->curveType = curveType;203 trackElem->curveType = curveType; 204 204 switch (curveType) 205 205 { 206 206 case BEZIERCURVE: 207 t his->currentTrackElem->curve = new BezierCurve();207 trackElem->curve = new BezierCurve(); 208 208 break; 209 209 case UPOINTCURVE: 210 t his->currentTrackElem->curve = new UPointCurve();210 trackElem->curve = new UPointCurve(); 211 211 break; 212 212 } … … 221 221 { 222 222 this->currentTrackElem->duration = time; 223 this->currentTrackElem->endTime = this->currentTrackElem->startingTime + time; 223 224 } 224 225 … … 241 242 if (trackElem->isFresh) 242 243 { 243 this->setCurveType(BEZIERCURVE );244 this->setCurveType(BEZIERCURVE, trackElem); 244 245 trackElem->isFresh = false; 245 if(trackElem != this->firstTrackElem)246 {247 this->addPoint(trackElem->startPoint);248 this->addPoint(trackElem->startTangentPoint);249 }250 246 } 251 247 trackElem->curve->addNode(newPoint); … … 380 376 int tmpCurrentWorkingID = this->currentTrackElem->ID; 381 377 this->workOn(trackIDs[0]); 378 float tmpLatestTime = this->currentTrackElem->endTime; 382 379 383 380 TrackElement* firstJoint = this->currentTrackElem; … … 388 385 if(!firstJoint->isHotPoint) 389 386 this->setSavePoint(); 390 387 // Timing: 388 for (int i = 0; i < count; i++) 389 { 390 TrackElement* tmpJoinElem = this->findTrackElementByID(trackIDs[i]); 391 if (tmpJoinElem->childCount == 0 392 && tmpJoinElem->endTime > tmpLatestTime) 393 tmpLatestTime = tmpJoinElem->endTime; 394 } 395 // Joining: 391 396 for (int i = 1; i < count; i++) 392 397 { … … 398 403 this->addPoint(tmpTangentPoint, tmpJoinElem); 399 404 this->addPoint(tmpEndPoint, tmpJoinElem); 405 tmpJoinElem->jumpTime = tmpLatestTime - tmpJoinElem->endTime; 400 406 401 407 //Copying Joint-Info … … 404 410 tmpJoinElem->isSavePoint = firstJoint->isSavePoint; 405 411 tmpJoinElem->isFork = firstJoint->isFork; 406 412 407 413 tmpJoinElem->isJoined = true; 408 414 } 409 415 } 416 if(currentTrackElem->children) 417 for(int i = 0; i > currentTrackElem->childCount; i++) 418 currentTrackElem->children[i]->startingTime = tmpLatestTime; 419 410 420 // returning to the TrackElement we were working on. 411 421 this->workOn(tmpCurrentWorkingID); … … 430 440 Vector TrackManager::calcDir() const 431 441 { 432 return this->currentTrackElem->curve->calcDir((this->localTime -this->currentTrackElem->startingTime)/this->currentTrackElem->duration);442 return this->currentTrackElem->curve->calcDir((this->localTime - this->currentTrackElem->startingTime)/this->currentTrackElem->duration); 433 443 } 434 444 … … 442 452 { 443 453 dt /= 1000; 444 printf(" LocalTime is: %f, timestep is: %f\n", this->localTime, dt);454 printf("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt); 445 455 if (this->localTime <= this->firstTrackElem->duration) 446 456 this->jumpTo(this->localTime); 447 457 this->localTime += dt; 448 if (this->localTime > this->currentTrackElem->startingTime + this->currentTrackElem->duration && this->currentTrackElem->childCount > 0) 449 this->currentTrackElem = this->currentTrackElem->children[0]; 458 if (this->localTime > this->currentTrackElem->endTime 459 && this->currentTrackElem->children) 460 { 461 if (this->currentTrackElem->jumpTime > 0) 462 this->jumpTo(this->localTime + this->currentTrackElem->jumpTime); 463 this->currentTrackElem = this->currentTrackElem->children[0]; 464 } 450 465 if (this->bindSlave) 451 466 { … … 535 550 if(tmpElem->isFresh) 536 551 printf(" has not jet eddited in any way\n"); 537 printf("\n TimeTable: starting at = %f; ends at = %f; duration = %f\n", tmpElem->startingTime, tmpElem->startingTime+tmpElem->duration, tmpElem->duration);552 printf("\n TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", tmpElem->startingTime, tmpElem->endTime, tmpElem->duration, tmpElem->jumpTime); 538 553 printf(" consists of %d Points\n", tmpElem->nodeCount); 539 554 if (tmpElem->childCount == 0) -
orxonox/branches/trackManager/src/track_manager.h
r3371 r3373 46 46 float startingTime; //!< The time at which this Track begins. 47 47 float duration; //!< The time used to cross this TrackElement (curve). 48 float endTime; //!< The time at which this Track ends. 49 float jumpTime; //!< The Time this Track has to jump to its preceding Track (only >0 if Track isJoined==true) 48 50 CurveType curveType; //!< The CurveType this will have. 49 51 int nodeCount; //!< The count of points this TrackElement has. 50 52 char* name; //!< A name for the Trac. 51 Vector startPoint; //!< A Vector that Points to the first point of the containing Curve. (for c1-steadiness)52 Vector startTangentPoint; //!< A Vector that points into the direction of the previous Curve. (for c1-steadiness)53 53 Curve* curve; //!< The Curve of this TrackElement 54 54 int childCount; //!< The number of Children This TrackElement has. … … 117 117 // Methods to change the Path (initialisation) 118 118 void workOn(unsigned int trackID); 119 void setCurveType(CurveType curveType); 119 inline void setCurveType(CurveType curveType) { this->setCurveType (curveType, this->currentTrackElem);} 120 void setCurveType(CurveType curveType, TrackElement* trackElem); 120 121 void setDuration(float time); 121 122 bool addPoint(Vector newPoint); -
orxonox/branches/trackManager/src/world.cc
r3371 r3373 226 226 trackManager->addPoint(Vector(210,0,10)); 227 227 trackManager->setDuration(1); 228 229 230 228 trackManager->join(4, fork21, fork22, fork13, fork14); 231 229 trackManager->workOn(10); 230 trackManager->addPoint(Vector(250,-10,5)); 231 232 232 /* 233 233 tmpCurve->addNode(Vector(10,0,-10));
Note: See TracChangeset
for help on using the changeset viewer.