Changeset 4440 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Jun 1, 2005, 9:57:19 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/coord/null_parent.cc
r3966 r4440 43 43 { 44 44 PRINTF(4)("NullParent::NullParent() - making new NullParent, there can only be one..\n"); 45 this->parent = this; 46 this->mode = PNODE_ALL; 45 this->setMode(PNODE_ALL); 47 46 this->setName("NullParent"); 48 47 } … … 52 51 { 53 52 singletonRef = this; 54 this->parent = this; 55 this->mode = PNODE_ALL; 56 this->absCoordinate = absCoordinate; 53 this->setMode(PNODE_ALL); 57 54 this->setName("NullParent"); 58 55 } … … 77 74 worry, normaly... 78 75 */ 79 void NullParent::update (float dt)80 {81 82 PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);83 this->absCoordinate = this->relCoordinate;84 this->absDirection = parent->getAbsDir () * this->relDirection;85 86 tIterator<PNode>* iterator = this->children->getIterator();87 //PNode* pn = this->children->enumerate ();88 PNode* pn = iterator->nextElement();89 while( pn != NULL)90 {91 /* if this node has changed, make sure, that all children are updated also */92 if( this->bRelCoorChanged || this->bAbsCoorChanged)93 pn->parentCoorChanged ();94 if( this->bRelDirChanged || this->bAbsDirChanged)95 pn->parentDirChanged ();96 pn->update (dt);97 //pn = this->children->nextElement ();98 pn = iterator->nextElement();99 }100 101 this->timeStamp = timeStamp;102 this->bRelCoorChanged = false;103 this->bAbsCoorChanged = false;104 this->bRelDirChanged = false;105 this->bAbsDirChanged = false;106 } -
orxonox/trunk/src/lib/coord/null_parent.h
r3809 r4440 19 19 20 20 21 virtual void update (float dt);22 23 21 private: 24 22 NullParent (); -
orxonox/trunk/src/lib/coord/p_node.cc
r4436 r4440 408 408 void PNode::update (float dt) 409 409 { 410 this->lastAbsCoordinate = this->absCoordinate; 411 412 PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 413 414 415 if( likely(this->mode & PNODE_MOVEMENT)) 410 if( likely(this->parent != NULL)) 416 411 { 417 if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 412 this->lastAbsCoordinate = this->absCoordinate; 413 414 PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 415 416 417 if( likely(this->mode & PNODE_MOVEMENT)) 418 418 { 419 /* if you have set the absolute coordinates this overrides all other changes */ 420 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 419 if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 420 { 421 /* if you have set the absolute coordinates this overrides all other changes */ 422 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 423 } 424 if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 425 426 { 427 /*this is bad style... must be deleted later - just for testing*/ 428 429 /* 430 if( unlikely(this->parent == NULL)) 431 { 432 *this->absCoordinate = *this->relCoordinate; 433 } 434 else */ 435 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate; /* update the current absCoordinate */ 436 } 421 437 } 422 if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)423 438 439 if( this->mode & PNODE_LOCAL_ROTATE) 424 440 { 425 /*this is bad style... must be deleted later - just for testing*/ 426 427 /* 428 if( unlikely(this->parent == NULL)) 441 if( unlikely(this->bAbsDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 429 442 { 430 *this->absCoordinate = *this->relCoordinate; 443 /* if you have set the absolute coordinates this overrides all other changes */ 444 this->relDirection = this->absDirection - parent->getAbsDir(); 431 445 } 432 else */ 433 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate; /* update the current absCoordinate */ 446 else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 447 { 448 /* update the current absDirection - remember * means rotation around sth.*/ 449 this->absDirection = parent->getAbsDir() * this->relDirection; 450 } 434 451 } 435 }436 452 437 if( this->mode & PNODE_LOCAL_ROTATE) 438 { 439 if( unlikely(this->bAbsDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 453 if( this->mode & PNODE_ROTATE_MOVEMENT) 440 454 { 441 /* if you have set the absolute coordinates this overrides all other changes */ 442 this->relDirection = this->absDirection - parent->getAbsDir(); 455 if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 456 { 457 /* if you have set the absolute coordinates this overrides all other changes */ 458 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 459 } 460 else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 461 { 462 /*this is bad style... must be deleted later - just for testing*/ 463 /*if( this->parent == NULL) 464 *this->absCoordinate = *this->relCoordinate; 465 else*/ 466 this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate); /* update the current absCoordinate */ 467 } 443 468 } 444 else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)445 {446 /* update the current absDirection - remember * means rotation around sth.*/447 this->absDirection = parent->getAbsDir() * this->relDirection;448 }449 }450 451 if( this->mode & PNODE_ROTATE_MOVEMENT)452 {453 if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)454 {455 /* if you have set the absolute coordinates this overrides all other changes */456 this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();457 }458 else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)459 {460 /*this is bad style... must be deleted later - just for testing*/461 /*if( this->parent == NULL)462 *this->absCoordinate = *this->relCoordinate;463 else*/464 this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate); /* update the current absCoordinate */465 }466 }467 469 468 470 469 tIterator<PNode>* iterator = this->children->getIterator(); 470 //PNode* pn = this->children->enumerate(); 471 PNode* pn = iterator->nextElement(); 472 while( pn != NULL) 473 { 474 /* if this node has changed, make sure, that all children are updated also */ 475 if( likely(this->bRelCoorChanged || this->bAbsCoorChanged)) 476 pn->parentCoorChanged (); 477 if( likely(this->bRelDirChanged || this->bAbsDirChanged)) 478 pn->parentDirChanged (); 479 480 pn->update(dt); 481 //pn = this->children->nextElement(); 482 pn = iterator->nextElement(); 483 } 484 delete iterator; 485 486 this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt; 487 this->timeStamp = timeStamp; 488 this->bRelCoorChanged = false; 489 this->bAbsCoorChanged = false; 490 this->bRelDirChanged = false; 491 this->bAbsDirChanged = false; 471 tIterator<PNode>* iterator = this->children->getIterator(); 472 //PNode* pn = this->children->enumerate(); 473 PNode* pn = iterator->nextElement(); 474 while( pn != NULL) 475 { 476 /* if this node has changed, make sure, that all children are updated also */ 477 if( likely(this->bRelCoorChanged || this->bAbsCoorChanged)) 478 pn->parentCoorChanged (); 479 if( likely(this->bRelDirChanged || this->bAbsDirChanged)) 480 pn->parentDirChanged (); 481 482 pn->update(dt); 483 //pn = this->children->nextElement(); 484 pn = iterator->nextElement(); 485 } 486 delete iterator; 487 488 this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt; 489 this->bRelCoorChanged = false; 490 this->bAbsCoorChanged = false; 491 this->bRelDirChanged = false; 492 this->bAbsDirChanged = false; 493 } 494 else 495 { 496 PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 497 this->absCoordinate = this->relCoordinate; 498 this->absDirection = this->getAbsDir () * this->relDirection; 499 500 tIterator<PNode>* iterator = this->children->getIterator(); 501 //PNode* pn = this->children->enumerate (); 502 PNode* pn = iterator->nextElement(); 503 while( pn != NULL) 504 { 505 /* if this node has changed, make sure, that all children are updated also */ 506 if( this->bRelCoorChanged || this->bAbsCoorChanged) 507 pn->parentCoorChanged (); 508 if( this->bRelDirChanged || this->bAbsDirChanged) 509 pn->parentDirChanged (); 510 pn->update (dt); 511 //pn = this->children->nextElement (); 512 pn = iterator->nextElement(); 513 } 514 515 this->bRelCoorChanged = false; 516 this->bAbsCoorChanged = false; 517 this->bRelDirChanged = false; 518 this->bAbsDirChanged = false; 519 } 492 520 } 493 521 -
orxonox/trunk/src/lib/coord/p_node.h
r4436 r4440 45 45 #define DEFAULT_MODE PNODE_ALL 46 46 47 47 48 //! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent. 48 49 class PNode : virtual public BaseObject { … … 55 56 56 57 void loadParams(const TiXmlElement* root); 57 58 59 PNode* parent; //!< a pointer to the parent node60 tList<PNode>* children; //!< list of the children61 62 63 58 64 59 void setRelCoor (const Vector& relCoord); … … 80 75 /** \returns a Vector pointing into the absolute Direction */ 81 76 inline Vector getAbsDirV() const { return this->absDirection.apply(Vector(0,1,0)); }; 82 83 77 void shiftDir (const Quaternion& shift); 84 78 85 79 /** \returns the Speed of the Node */ 86 inline float getSpeed() const {return this->velocity.len() /1000;} //! \FIX THIS SHOULD NOT BE /100080 inline float getSpeed() const {return this->velocity.len();} 87 81 /** \returns the Velocity of the Node */ 88 82 inline const Vector& getVelocity() const {return this->velocity;} 89 /** \returns the last calculated coordinate */ 90 inline Vector getLastAbsCoor(void) {return this->lastAbsCoordinate;} 83 91 84 92 85 void addChild (PNode* pNode, int parentingMode = DEFAULT_MODE); … … 94 87 void remove(); 95 88 96 97 89 void setParent (PNode* parent); 98 inline void parentCoorChanged () { this->bRelCoorChanged = true; }99 inline void parentDirChanged () { this->bRelDirChanged = true; }100 90 void setMode (int parentingMode); 101 91 int getMode() const; 102 92 103 v irtual void update (float dt);93 void update (float dt); 104 94 void processTick (float dt); 105 95 106 96 void debug (); 107 97 108 protected:109 float timeStamp; //!< this the timeStamp of when the abs{Coordinat, Direction} has been calculated110 bool bAbsCoorChanged; //!< If Absolute Coordinate has changed since last time we checked111 bool bRelCoorChanged; //!< If Relative Coordinate has changed since last time we checked112 bool bAbsDirChanged; //!< If Absolute Direction has changed since last time we checked113 bool bRelDirChanged; //!< If Relative Direction has changed since last time we checked114 115 Vector relCoordinate; //!< coordinates relative to the parent116 Vector absCoordinate; //!< absolute coordinates in the world ( from (0,0,0) )117 Quaternion relDirection; //!< direction relative to the parent118 Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) )119 120 int mode; //!< the mode of the binding121 98 122 99 private: 123 100 void init(PNode* parent); 101 inline void parentCoorChanged () { this->bRelCoorChanged = true; } 102 inline void parentDirChanged () { this->bRelDirChanged = true; } 103 /** \returns the last calculated coordinate */ 104 inline Vector getLastAbsCoor(void) {return this->lastAbsCoordinate;} 124 105 125 Vector velocity; //!< Saves the velocity. 126 Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate 106 107 private: 108 bool bAbsCoorChanged; //!< If Absolute Coordinate has changed since last time we checked 109 bool bRelCoorChanged; //!< If Relative Coordinate has changed since last time we checked 110 bool bAbsDirChanged; //!< If Absolute Direction has changed since last time we checked 111 bool bRelDirChanged; //!< If Relative Direction has changed since last time we checked 112 113 Vector relCoordinate; //!< coordinates relative to the parent 114 Vector absCoordinate; //!< absolute coordinates in the world ( from (0,0,0) ) 115 Quaternion relDirection; //!< direction relative to the parent 116 Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) ) 117 118 Vector velocity; //!< Saves the velocity. 119 Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate 120 121 PNode* parent; //!< a pointer to the parent node 122 tList<PNode>* children; //!< list of the children 123 124 unsigned int mode; //!< the mode of the binding 127 125 }; 128 126 -
orxonox/trunk/src/lib/physics/physics_interface.cc
r4397 r4440 65 65 void PhysicsInterface::recalcMass() 66 66 { 67 /* 67 68 PNode* massCalcPNode = dynamic_cast<PNode*>(this); //! \todo not sure if this will work .... 68 69 float massSum = 0; … … 87 88 this->massChildren = massSum; 88 89 } 90 */ 89 91 } 90 92 … … 95 97 this->forceSum += field->calcForce(tmp->getAbsCoor()); 96 98 } 99 97 100 98 101 void PhysicsInterface::tickPhys( float dt ) -
orxonox/trunk/src/util/track/track_node.cc
r4320 r4440 43 43 TrackNode::TrackNode (const Vector& absCoordinate) 44 44 { 45 this->parent = NullParent::getInstance();46 45 this->trackManager = TrackManager::getInstance(); 47 46 this->setMode(PNODE_ALL);
Note: See TracChangeset
for help on using the changeset viewer.