- Timestamp:
- Aug 12, 2005, 4:12:15 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/coord/p_node.cc
r4955 r4987 111 111 this->bAbsDirChanged = false; 112 112 this->parent = parent; 113 114 this->toPosition = NULL; 113 115 } 114 116 … … 179 181 } 180 182 183 void PNode::setRelCoorSoft(const Vector& relCoordSoft) 184 { 185 if (likely(this->toPosition == NULL)) 186 this->toPosition = new Vector(); 187 188 *this->toPosition = relCoordSoft; 189 190 this->toPosition->debug(); 191 printf("=-==============\n"); 192 } 193 181 194 /** 182 195 * @param absCoord set absolute coordinate … … 196 209 * @param y y-coordinate. 197 210 * @param z z-coordinate. 198 * \see void PNode::setAbsCoor (const Vector& absCoord)211 * @see void PNode::setAbsCoor (const Vector& absCoord) 199 212 */ 200 213 void PNode::setAbsCoor(float x, float y, float z) … … 221 234 222 235 yea right... shorter... 236 * 237 * @todo this is ambiguous, from the outside one does not know it absCoor has been changed 238 * this might lead to strange artefacts !! 223 239 224 240 */ … … 404 420 parentNode->addChild(this); 405 421 } 422 423 void PNode::softReparent(PNode* parentNode) 424 { 425 if (likely(this->toPosition == NULL)) 426 this->toPosition = new Vector(); 427 428 *this->toPosition = parentNode->getAbsCoor() + this->getRelCoor(); 429 430 Vector tmp = this->getAbsCoor(); 431 432 parentNode->addChild(this); 433 434 this->setRelCoor(tmp - parentNode->getAbsCoor()); 435 } 436 437 void PNode::softReparent(const char* parentName) 438 { 439 PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE)); 440 if (parentNode != NULL) 441 this->softReparent(parentNode); 442 } 443 406 444 407 445 /** … … 456 494 void PNode::update (float dt) 457 495 { 496 497 458 498 if( likely(this->parent != NULL)) 459 499 { 500 // movement for nodes with smoothMove enabled 501 if (unlikely(this->toPosition != NULL)) 502 { 503 Vector moveVect = (*this->toPosition - this->getRelCoor()) *dt; 504 505 if (likely(moveVect.len() >= .001)) 506 { 507 this->shiftCoor(moveVect); 508 moveVect.debug(); 509 } 510 else 511 { 512 delete this->toPosition; 513 this->toPosition = NULL; 514 PRINTF(0)("SmoothMove of %s finished\n", this->getName()); 515 } 516 } 517 460 518 this->lastAbsCoordinate = this->absCoordinate; 461 519 462 PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 463 520 PRINTF(5)("PNode::update - %s - (%f, %f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 464 521 465 522 if( likely(this->parentMode & PNODE_MOVEMENT)) 466 523 { 467 if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)524 if( unlikely(this->bAbsCoorChanged)) 468 525 { 469 526 /* if you have set the absolute coordinates this overrides all other changes */ 470 527 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 471 528 } 472 if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 473 529 if( likely(this->bRelCoorChanged)) 474 530 { 475 /*this is bad style... must be deleted later - just for testing*/ 476 477 /* 478 if( unlikely(this->parent == NULL)) 479 { 480 *this->absCoordinate = *this->relCoordinate; 481 } 482 else */ 483 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate; /* update the current absCoordinate */ 531 /* update the current absCoordinate */ 532 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate; 484 533 } 485 534 } … … 487 536 if( this->parentMode & PNODE_LOCAL_ROTATE) 488 537 { 489 if( unlikely(this->bAbsDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)538 if( unlikely(this->bAbsDirChanged)) 490 539 { 491 540 /* if you have set the absolute coordinates this overrides all other changes */ 492 541 this->relDirection = this->absDirection - parent->getAbsDir(); 493 542 } 494 else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)543 else if( likely(this->bRelDirChanged)) 495 544 { 496 545 /* update the current absDirection - remember * means rotation around sth.*/ … … 501 550 if( this->parentMode & PNODE_ROTATE_MOVEMENT) 502 551 { 503 if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)552 if( unlikely(this->bAbsCoorChanged)) 504 553 { 505 554 /* if you have set the absolute coordinates this overrides all other changes */ 506 555 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 507 556 } 508 else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)557 else if( likely(this->bRelCoorChanged)) 509 558 { 510 /*this is bad style... must be deleted later - just for testing*/ 511 /*if( this->parent == NULL) 512 *this->absCoordinate = *this->relCoordinate; 513 else*/ 514 this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate); /* update the current absCoordinate */ 559 /* update the current absCoordinate */ 560 this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate); 515 561 } 516 562 } … … 518 564 519 565 tIterator<PNode>* iterator = this->children->getIterator(); 520 //PNode* pn = this->children->enumerate();521 566 PNode* pn = iterator->nextElement(); 522 567 while( pn != NULL) -
orxonox/trunk/src/lib/coord/p_node.h
r4966 r4987 62 62 void setRelCoor (const Vector& relCoord); 63 63 void setRelCoor (float x, float y, float z); 64 void setRelCoorSoft(const Vector& softRelCoord); 64 65 /** @returns the relative position */ 65 66 inline const Vector& getRelCoor () const { return this->relCoordinate; }; … … 96 97 97 98 void setParent (PNode* parent); 98 void setParent (const char* name);99 void setParent (const char* parentName); 99 100 /** @returns the parent of this PNode */ 100 101 PNode* getParent () const { return this->parent; }; 102 103 void softReparent(PNode* parentNode); 104 void softReparent(const char* parentName); 101 105 102 106 void setParentMode (PARENT_MODE parentMode); … … 112 116 private: 113 117 void init(PNode* parent); 114 /** \brieftells the child that the parent's Coordinate has changed */118 /** tells the child that the parent's Coordinate has changed */ 115 119 inline void parentCoorChanged () { this->bRelCoorChanged = true; } 116 /** \brieftells the child that the parent's Direction has changed */120 /** tells the child that the parent's Direction has changed */ 117 121 inline void parentDirChanged () { this->bRelDirChanged = true; } 118 122 /** @returns the last calculated coordinate */ … … 134 138 Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate 135 139 140 141 Vector* toPosition; //!< a position to wich to iterate. (This is used in conjunction with softReparent.) 142 136 143 PNode* parent; //!< a pointer to the parent node 137 tList<PNode>* children; //!< list of the children 144 tList<PNode>* children; //!< list of the children of this PNode 138 145 139 146 unsigned int parentMode; //!< the mode of the binding -
orxonox/trunk/src/lib/math/vector.cc
r4966 r4987 56 56 void Vector::debug() const 57 57 { 58 PRINT(0)("Vector Debug information\n");59 58 PRINT(0)("x: %f; y: %f; z: %f", x, y, z); 60 PRINT( 3)(" lenght: %f", len());59 PRINT(0)(" lenght: %f", len()); 61 60 PRINT(0)("\n"); 62 61 } -
orxonox/trunk/src/world_entities/camera.cc
r4986 r4987 36 36 { 37 37 this->setClassID(CL_CAMERA, "Camera"); 38 this->setName("camera"); 38 39 this->target = new CameraTarget(); 39 40 … … 50 51 51 52 this->setViewMode(VIEW_NORMAL); 53 54 this->setParentMode(PNODE_MOVEMENT); 52 55 } 53 56 … … 116 119 case VIEW_NORMAL: 117 120 this->toFovy = 60.0; 118 this->toRelCoor = Vector(-10, 5, 0); 121 this->setRelCoorSoft(Vector(-10, 5, 0)); 122 this->target->setRelCoorSoft(Vector(0,0,0)); 119 123 break; 120 124 case VIEW_BEHIND: 121 this->toFovy = 120.0; 122 this->toRelCoor = Vector(3.5, 0, 0); 123 this->target->setRelCoor(4,0,0); 124 /* this->setParent("main-Turret"); 125 // this->toFovy = 120.0; 126 this->setRelCoorSoft(Vector(3.5, 0, 0)); 127 this->target->setRelCoorSoft(Vector(10,0,0)); 128 129 /*this->target->softReparent("main-Turret"); 130 this->setParent("main-Turret"); 125 131 this->setParentMode(PNODE_ALL); 126 132 this->target->setParent("Crosshair");*/ … … 128 134 case VIEW_FRONT: 129 135 this->toFovy = 95.0; 130 this->toRelCoor = Vector(12, 5, 0); 136 this->setRelCoorSoft(Vector(10, 2, 0)); 137 this->target->setRelCoorSoft(Vector(0,0,0)); 131 138 break; 132 139 case VIEW_LEFT: 133 140 this->toFovy = 90; 134 this->toRelCoor = Vector(0, 2, -10); 141 this->setRelCoorSoft(Vector(0, 1, -10)); 142 this->target->setRelCoorSoft(Vector(0,0,0)); 135 143 break; 136 144 case VIEW_RIGHT: 137 145 this->toFovy = 90; 138 this->toRelCoor = Vector(0, 2, 10); 146 this->setRelCoorSoft(Vector(0, 1, 10)); 147 this->target->setRelCoorSoft(Vector(0,0,0)); 139 148 break; 140 149 case VIEW_TOP: 141 150 this->toFovy= 120; 142 this->toRelCoor = Vector(0, 4, 0); 151 this->setRelCoorSoft(Vector(0, 10, 0)); 152 this->target->setRelCoorSoft(Vector(0,0,0)); 143 153 } 144 154 } … … 154 164 if (tmpFovy > .001) 155 165 this->fovy += (this->toFovy - this->fovy) * dt; 156 Vector tmpPos = (this->toRelCoor - this->getRelCoor()) * dt;157 if (tmpPos.len() >= .001)158 {159 tmpPos = tmpPos + this->getRelCoor();160 this->setRelCoor(tmpPos);161 }162 166 } 163 167 -
orxonox/trunk/src/world_entities/camera.h
r4986 r4987 57 57 float farClip; //!< The far clipping plane. 58 58 59 Vector toRelCoor; //!< The relativeCoordinate to move the camera to.60 59 float toFovy; //!< The fovy-mode to iterate to. 61 60 };
Note: See TracChangeset
for help on using the changeset viewer.