- Timestamp:
- Apr 15, 2005, 5:51:17 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/math/curve.h
r3595 r3836 13 13 14 14 //! An Enumerator that defines what sort of Curves are availible 15 enum CurveType { BEZIERCURVE};15 enum CurveType {CURVE_BEZIER}; 16 16 17 17 -
orxonox/trunk/src/track_manager.cc
r3835 r3836 372 372 this->setClassName("TrackManager"); 373 373 374 TrackManager::singletonRef = this; 374 TrackManager::singletonRef = this; // do this because otherwise the TrackNode cannot get The instance of the TrackManager 375 375 376 376 PRINTF(3)("Initializing the TrackManager\n"); 377 // setting up the First TrackElement 377 378 this->firstTrackElem = new TrackElement(); 378 379 this->firstTrackElem->ID = 1; 379 380 this->currentTrackElem = firstTrackElem; 381 382 this->curveType = CURVE_BEZIER; 380 383 this->localTime = 0; 381 384 this->maxTime = 0; 382 385 this->trackElemCount = 1; 383 this-> setBindSlave(this->trackNode = new TrackNode());384 } 385 386 this->trackNode = new TrackNode(); 387 this->setBindSlave(this->trackNode); 388 } 386 389 387 390 /** … … 394 397 PRINTF(4)("Deleting all the TrackElements\n"); 395 398 delete this->firstTrackElem; 399 400 // the tracknode should be deleted here, but is deleted by pNode: -> null_parent 396 401 397 402 // we do not have a TrackManager anymore … … 414 419 } 415 420 421 422 // INITIALIZE // 416 423 /** 417 424 \brief reserves Space for childCount children 418 425 \param childCount The Count of children to make space for. 419 */ 420 void TrackManager::initChildren(unsigned int childCount) 421 { 422 this->currentTrackElem->childCount = childCount; 423 this->currentTrackElem->mainJoin = true; 424 this->currentTrackElem->children = new tList<TrackElement>(); 426 \param trackElem The TrackElement to appy this to. (if NULL chose this->currentTrackElement) 427 */ 428 void TrackManager::initChildren(unsigned int childCount, TrackElement* trackElem) 429 { 430 if (!trackElem) 431 trackElem = this->currentTrackElem; 432 433 trackElem->childCount = childCount; 434 trackElem->mainJoin = true; // this tells join, that this one is the Main Join, if it tries to join multiple Tracks 435 trackElem->children = new tList<TrackElement>(); 425 436 for (int i = 0; i < childCount; i++) 426 437 { 438 // create a new Element 427 439 TrackElement* newElem = new TrackElement(); 428 this->currentTrackElem->children->add(newElem);440 // setting up the new ID 429 441 newElem->ID = ++trackElemCount; 430 newElem->startingTime = this->currentTrackElem->endTime + this->currentTrackElem->jumpTime; 431 this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->getChild(i)); 432 } 442 // setting up the Time 443 newElem->startingTime = trackElem->endTime + trackElem->jumpTime; 444 // adds the conection Point 445 this->addPoint(trackElem->curve->getNode(trackElem->curve->getNodeCount()), 446 newElem); 447 // add the new child to the childList. 448 trackElem->children->add(newElem); 449 } 450 451 // setting the Name of the new TrackElement to the name of the last one, if the childCount is one 433 452 if (childCount == 1) 434 this->currentTrackElem->getChild(0)->setName(this->currentTrackElem->getName()); 435 } 436 437 /** 438 \brief Searches for a given trackID. 439 \param trackID the trackID to search for. 440 \returns The TrackElement #trackID if found, NULL otherwise. 441 */ 442 TrackElement* TrackManager::findTrackElementByID(unsigned int trackID) const 443 { 444 return firstTrackElem->findByID(trackID); 445 } 446 447 // INITIALIZE // 453 trackElem->getChild(0)->setName(trackElem->getName()); 454 } 455 448 456 449 457 /** … … 453 461 void TrackManager::workOn(unsigned int trackID) 454 462 { 455 TrackElement* tmpElem = findTrackElementByID(trackID);463 TrackElement* tmpElem = this->firstTrackElem->findByID(trackID); 456 464 if (tmpElem) 457 465 this->currentTrackElem = tmpElem; 458 466 else 459 PRINTF(2)("TrackElement not Found, leaving unchanged\n");467 PRINTF(2)("TrackElement %d not Found, leaving unchanged\n", trackID); 460 468 PRINTF(4)("now Working on %d\n", this->currentTrackElem->ID); 461 469 } 470 471 /** 472 \brief Sets the TrackElement to work on 473 \param trackName the Name of the Track to work on 474 */ 475 void TrackManager::workOn(const char* trackName) 476 { 477 TrackElement* tmpElem = this->firstTrackElem->findByName(trackName); 478 if (tmpElem) 479 this->currentTrackElem = tmpElem; 480 else 481 PRINTF(2)("TrackElement %s not Found, leaving unchanged\n", trackName); 482 PRINTF(4)("now Working on %d\n", this->currentTrackElem->ID); 462 483 } 463 484 … … 466 487 \param curveType The Type to set 467 488 \param trackElem the TrackElement that should get a new Curve. 489 490 \brief this will possibly get obsolete during the process. 468 491 */ 469 492 void TrackManager::setCurveType(CurveType curveType, TrackElement* trackElem) … … 477 500 switch (curveType) 478 501 { 479 case BEZIERCURVE:502 case CURVE_BEZIER: 480 503 trackElem->curve = new BezierCurve(); 481 504 break; 482 483 505 } 484 506 } … … 486 508 /** 487 509 \brief Sets the duration of the current path in seconds. 488 \param time The duration in seconds. 489 */ 490 491 void TrackManager::setDuration(float time) 492 { 493 this->currentTrackElem->duration = time; 494 this->currentTrackElem->endTime = this->currentTrackElem->startingTime + time; 495 } 496 497 /** 498 \brief adds a point to the current TrackElement 499 \param newPoint The point to add. 500 */ 501 bool TrackManager::addPoint(Vector newPoint) 502 { 503 return this->addPoint(newPoint, this->currentTrackElem); 510 \param duration The duration in seconds. 511 \param trackElem The TrackElement to apply this to. 512 */ 513 void TrackManager::setDuration(float duration, TrackElement* trackElem) 514 { 515 if (!trackElem) 516 trackElem = this->currentTrackElem; 517 518 trackElem->duration = duration; 519 trackElem->endTime = trackElem->startingTime + duration; 504 520 } 505 521 … … 511 527 bool TrackManager::addPoint(Vector newPoint, TrackElement* trackElem) 512 528 { 529 if (!trackElem) 530 trackElem = this->currentTrackElem; 531 513 532 if (trackElem->isFresh) 514 533 { … … 525 544 \returns A Pointer to a newly appended Curve 526 545 */ 527 int TrackManager::addHotPoint(Vector newPoint) 528 { 546 int TrackManager::addHotPoint(Vector newPoint, TrackElement* trackElem) 547 { 548 if (!trackElem) 549 trackElem = this->currentTrackElem; 550 529 551 PRINTF(4)("setting up a HotPoint\n"); 530 if (this->currentTrackElem->isFresh) 531 { 532 this->setCurveType(BEZIERCURVE); 533 this->currentTrackElem->isFresh = false; 552 if (trackElem->isFresh) 553 { 554 trackElem->isFresh = false; 534 555 } 535 556 536 557 // \todo HotPoint Handling. 537 t his->currentTrackElem->curve->addNode(newPoint);538 t his->currentTrackElem->nodeCount++;558 trackElem->curve->addNode(newPoint); 559 trackElem->nodeCount++; 539 560 this->initChildren(1); 540 561 this->currentTrackElem = this->currentTrackElem->getChild(0); … … 622 643 void TrackManager::condition(unsigned int groupID, CONDITION cond, void* subject) 623 644 { 624 TrackElement* tmpElem = this->fi ndTrackElementByID(groupID);645 TrackElement* tmpElem = this->firstTrackElem->findByID(groupID); 625 646 if (!tmpElem->isFork) 626 647 { … … 688 709 689 710 // checking if there is a back-loop-connection and ERROR if it is. 690 TrackElement* tmpTrackElem = this->fi ndTrackElementByID(trackIDs[0]);711 TrackElement* tmpTrackElem = this->firstTrackElem->findByID(trackIDs[0]); 691 712 if (!tmpTrackElem->backLoopCheck(tmpTrackElem)) 692 713 PRINTF(2)("Backloop connection detected at joining trackElements\n"); … … 708 729 for (int i = 0; i < count; i++) 709 730 { 710 TrackElement* tmpJoinElem = this->fi ndTrackElementByID(trackIDs[i]);731 TrackElement* tmpJoinElem = this->firstTrackElem->findByID(trackIDs[i]); 711 732 if (tmpJoinElem->childCount == 0 712 733 && tmpJoinElem->endTime > tmpLatestTime) … … 719 740 for (int i = 1; i < count; i++) 720 741 { 721 TrackElement* tmpJoinElem = this->fi ndTrackElementByID(trackIDs[i]);742 TrackElement* tmpJoinElem = this->firstTrackElem->findByID(trackIDs[i]); 722 743 if (tmpJoinElem->childCount > 0) 723 744 printf("!!This Curve has children, and as such will not be joined!!\n You can try joining other childless TrackElements to this one!"); … … 767 788 for (int i = 1; i<= trackElemCount ;i++) 768 789 { 769 TrackElement* tmpElem = findTrackElementByID(i);790 TrackElement* tmpElem = this->firstTrackElem->findByID(i); 770 791 if( tmpElem->childCount > 0 && tmpElem->mainJoin) 771 792 { … … 799 820 } 800 821 for (int i = 1; i <=trackElemCount;i++) 801 if (this->fi ndTrackElementByID(i)->endTime > this->maxTime)802 this->maxTime = findTrackElementByID(i)->endTime; // very bad implemented :/822 if (this->firstTrackElem->findByID(i)->endTime > this->maxTime) 823 this->maxTime = this->firstTrackElem->findByID(i)->endTime; // very bad implemented :/ 803 824 } 804 825 … … 925 946 { 926 947 glBegin(GL_LINE_STRIP); 927 TrackElement* tmpElem = this->fi ndTrackElementByID(i);948 TrackElement* tmpElem = this->firstTrackElem->findByID(i); 928 949 if (tmpElem->curve) 929 950 for(float f = 0.0; f < 1.0; f+=dt) … … 953 974 for (int i = 1; i <= trackElemCount; i++) 954 975 { 955 TrackElement* tmpElem = this->fi ndTrackElementByID(i);976 TrackElement* tmpElem = this->firstTrackElem->findByID(i); 956 977 tmpElem->debug(); 957 978 } -
orxonox/trunk/src/track_manager.h
r3835 r3836 21 21 22 22 //! The Default Curve-Type to set for the whole path (if not chosen otherwise). 23 #define TMAN_DEFAULT_CURVETYPE BEZIERCURVE23 #define TMAN_DEFAULT_CURVETYPE CURVE_BEZIER 24 24 #define TMAN_DEFAULT_DURATION 10 25 25 #define TMAN_DEFAULT_WIDTH 10 … … 139 139 PNode* trackNode; //!< The main TrackNode of this Track. 140 140 141 void initChildren(unsigned int childCount );141 void initChildren(unsigned int childCount, TrackElement* trackElem = NULL); 142 142 143 TrackElement* findTrackElementByID(unsigned int trackID) const;144 145 143 public: 146 144 virtual ~TrackManager(void); … … 150 148 // Methods to change the Path (initialisation) 151 149 void workOn(unsigned int trackID); 150 void workOn(const char* trackName); 151 152 152 /** \see setCurveType(CurveType curveType, TrackElement* trackElem); \param curveType the type of the Curve */ 153 153 inline void setCurveType(CurveType curveType) { this->setCurveType (curveType, this->currentTrackElem);}; 154 154 void setCurveType(CurveType curveType, TrackElement* trackElem); 155 void setDuration(float time); 156 bool addPoint(Vector newPoint); 157 bool addPoint(Vector newPoint, TrackElement* trackElem); 158 int addHotPoint(Vector newPoint); 155 void setDuration(float duration, TrackElement* trackElem = NULL); 156 bool addPoint(Vector newPoint, TrackElement* trackElem = NULL); 157 int addHotPoint(Vector newPoint, TrackElement* trackElem = NULL); 159 158 int setSavePoint(void); 160 159 void fork(unsigned int count, ...); -
orxonox/trunk/src/track_node.h
r3556 r3836 17 17 class TrackManager; 18 18 19 class TrackNode : public PNode { 19 class TrackNode : public PNode 20 { 20 21 21 22 public:
Note: See TracChangeset
for help on using the changeset viewer.