- Timestamp:
- Apr 13, 2005, 7:20:38 PM (20 years ago)
- Location:
- orxonox/trunk/src/lib/coord
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/coord/p_node.cc
r3800 r3802 117 117 this->relDirection = new Quaternion(); 118 118 this->lastAbsCoordinate = new Vector(); 119 this->diffCoordinate = new Vector(); 119 120 } 120 121 … … 147 148 change it unless you realy know what you are doing. 148 149 */ 149 Vector* PNode::getRelCoor () 150 Vector* PNode::getRelCoor () const 150 151 { 151 152 //Vector r = *this->relCoordinate; /* return a copy, so it can't be modified */ … … 188 189 \returns absolute coordinates from (0,0,0) 189 190 */ 190 Vector PNode::getAbsCoor () 191 Vector PNode::getAbsCoor () const 191 192 { 192 193 return *this->absCoordinate; … … 299 300 \returns relative direction to its parent 300 301 */ 301 Quaternion PNode::getRelDir () 302 Quaternion PNode::getRelDir () const 302 303 { 303 304 return *this->relDirection; … … 331 332 \returns absolute coordinates 332 333 */ 333 Quaternion PNode::getAbsDir () 334 Quaternion PNode::getAbsDir () const 334 335 { 335 336 return *this->absDirection; … … 390 391 \todo implement this 391 392 */ 392 void PNode::shiftDir (Quaternion* shift) 393 {} 393 void PNode::shiftDir (const Quaternion& shift) 394 { 395 this->bRelDirChanged = true; 396 *this->relDirection = *this->relDirection * shift; 397 } 394 398 395 399 … … 422 426 \brief this calculates the current movement speed of the node 423 427 */ 424 float PNode::getSpeed() 428 float PNode::getSpeed() const 425 429 { 426 430 __UNLIKELY_IF( this->time == 0) 427 431 return 1000; 428 Vector diff; 429 diff = *this->absCoordinate - *this->lastAbsCoordinate; 430 float x = diff.len(); 431 return x / this->time; 432 } 433 434 435 /** 436 \brief adds a child and makes this node to a parent 437 \param pNode child reference 438 439 use this to add a child to this node. 440 */ 441 void PNode::addChild (PNode* pNode) 442 { 443 this->addChild(pNode, DEFAULT_MODE); 432 *this->diffCoordinate = *this->absCoordinate - *this->lastAbsCoordinate; 433 return this->diffCoordinate->len() / this->time; 444 434 } 445 435 -
orxonox/trunk/src/lib/coord/p_node.h
r3683 r3802 57 57 58 58 59 Vector* getRelCoor () ;59 Vector* getRelCoor () const; 60 60 void setRelCoor (Vector* relCoord); 61 61 void setRelCoor (Vector relCoord); 62 Vector getAbsCoor () ;62 Vector getAbsCoor () const; 63 63 void setAbsCoor (Vector* absCoord); 64 64 void setAbsCoor (Vector absCoord); … … 67 67 //void shiftCoor (Vector shift); 68 68 69 Quaternion getRelDir () ;69 Quaternion getRelDir () const; 70 70 void setRelDir (Quaternion* relDir); 71 71 void setRelDir (Quaternion relDir); 72 Quaternion getAbsDir () ;72 Quaternion getAbsDir () const; 73 73 void setAbsDir (Quaternion* absDir); 74 74 void setAbsDir (Quaternion absDir); 75 void shiftDir ( Quaternion*shift);75 void shiftDir (const Quaternion& shift); 76 76 void shiftDir (Quaternion shift); 77 77 78 float getSpeed() ;78 float getSpeed() const; 79 79 80 void addChild (PNode* pNode); 81 void addChild (PNode* pNode, int parentingMode); 80 void addChild (PNode* pNode, int parentingMode = DEFAULT_MODE); 82 81 void removeChild (PNode* pNode); 83 82 void remove(); … … 118 117 119 118 Vector* lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate 119 Vector* diffCoordinate; //!< this is stored here for performance reasons, difference to the last vector 120 120 float time; //!< time since last update 121 121 };
Note: See TracChangeset
for help on using the changeset viewer.