Changeset 3957 in orxonox.OLD for orxonox/branches/particleEngine/src/lib
- Timestamp:
- Apr 25, 2005, 2:25:27 PM (20 years ago)
- Location:
- orxonox/branches/particleEngine/src/lib/coord
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/particleEngine/src/lib/coord/null_parent.cc
r3809 r3957 54 54 this->parent = this; 55 55 this->mode = PNODE_ALL; 56 *this->absCoordinate = absCoordinate;56 this->absCoordinate = absCoordinate; 57 57 this->setName("NullParent"); 58 58 } … … 80 80 { 81 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;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 85 86 86 tIterator<PNode>* iterator = this->children->getIterator(); -
orxonox/branches/particleEngine/src/lib/coord/p_node.cc
r3938 r3957 60 60 this->init(parent); 61 61 62 *this->absCoordinate = absCoordinate;62 this->absCoordinate = absCoordinate; 63 63 64 64 if (likely(parent != NULL)) 65 65 { 66 *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor();66 this->relCoordinate = this->absCoordinate - parent->getAbsCoor(); 67 67 parent->addChild (this); 68 68 } 69 else70 this->relCoordinate = new Vector();71 69 } 72 70 … … 89 87 delete []this->objectName; 90 88 91 delete this->relCoordinate;92 delete this->absCoordinate;93 delete this->relDirection;94 delete this->absDirection;95 delete this->lastAbsCoordinate;96 delete this->diffCoordinate;97 89 } 98 90 … … 108 100 this->objectName = NULL; 109 101 this->time = 1.0; /* set time to 1 to make divisions by zero impossible */ 110 111 this->absCoordinate = new Vector();112 this->relCoordinate = new Vector();113 this->absDirection = new Quaternion();114 this->relDirection = new Quaternion();115 this->lastAbsCoordinate = new Vector();116 this->diffCoordinate = new Vector();117 102 } 118 103 … … 158 143 { 159 144 this->bRelCoorChanged = true; 160 *this->relCoordinate = relCoord;145 this->relCoordinate = relCoord; 161 146 } 162 147 … … 182 167 { 183 168 this->bAbsCoorChanged = true; 184 *this->absCoordinate = absCoord;169 this->absCoordinate = absCoord; 185 170 } 186 171 … … 211 196 if( unlikely(this->bAbsCoorChanged)) 212 197 { 213 *this->absCoordinate = *this->absCoordinate + shift;198 this->absCoordinate = this->absCoordinate + shift; 214 199 } 215 200 else 216 201 { 217 *this->relCoordinate = *this->relCoordinate + shift;202 this->relCoordinate = this->relCoordinate + shift; 218 203 this->bRelCoorChanged = true; 219 204 } … … 241 226 { 242 227 this->bRelCoorChanged = true; 243 *this->relDirection = relDir;228 this->relDirection = relDir; 244 229 } 245 230 … … 264 249 { 265 250 this->bAbsDirChanged = true; 266 *this->absDirection = absDir;251 this->absDirection = absDir; 267 252 } 268 253 … … 293 278 { 294 279 this->bRelDirChanged = true; 295 *this->relDirection = *this->relDirection * shift;280 this->relDirection = this->relDirection * shift; 296 281 } 297 282 … … 303 288 float PNode::getSpeed() const 304 289 { 305 *this->diffCoordinate = *this->absCoordinate - *this->lastAbsCoordinate; 306 return this->diffCoordinate->len() / this->time; 290 return (this->absCoordinate - this->lastAbsCoordinate).len() / this->time; 307 291 } 308 292 … … 312 296 Vector PNode::getVelocity() const 313 297 { 314 return ( *this->absCoordinate - *this->lastAbsCoordinate) / this->time;298 return (this->absCoordinate - this->lastAbsCoordinate) / this->time; 315 299 } 316 300 … … 439 423 void PNode::update (float dt) 440 424 { 441 *this->lastAbsCoordinate = *this->absCoordinate;425 this->lastAbsCoordinate = this->absCoordinate; 442 426 this->time = dt; 443 PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate ->x, this->absCoordinate->y, this->absCoordinate->z);427 PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 444 428 445 429 … … 449 433 { 450 434 /* if you have set the absolute coordinates this overrides all other changes */ 451 *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();435 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 452 436 } 453 437 if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) … … 462 446 } 463 447 else */ 464 *this->absCoordinate = parent->getAbsCoor() + *this->relCoordinate; /* update the current absCoordinate */448 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate; /* update the current absCoordinate */ 465 449 } 466 450 } … … 471 455 { 472 456 /* if you have set the absolute coordinates this overrides all other changes */ 473 *this->relDirection = *this->absDirection - parent->getAbsDir();457 this->relDirection = this->absDirection - parent->getAbsDir(); 474 458 } 475 459 else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 476 460 { 477 461 /* update the current absDirection - remember * means rotation around sth.*/ 478 *this->absDirection = parent->getAbsDir() * *this->relDirection;462 this->absDirection = parent->getAbsDir() * this->relDirection; 479 463 } 480 464 } … … 485 469 { 486 470 /* if you have set the absolute coordinates this overrides all other changes */ 487 *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();471 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 488 472 } 489 473 else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) … … 493 477 *this->absCoordinate = *this->relCoordinate; 494 478 else*/ 495 *this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(*this->relCoordinate); /* update the current absCoordinate */479 this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate); /* update the current absCoordinate */ 496 480 } 497 481 } … … 547 531 { 548 532 PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n", 549 this->absCoordinate ->x,550 this->absCoordinate ->y,551 this->absCoordinate ->z);533 this->absCoordinate.x, 534 this->absCoordinate.y, 535 this->absCoordinate.z); 552 536 } 553 537 … … 558 542 for debug purposes realy usefull, not used to work properly 559 543 */ 560 void PNode::setName (c har* newName)544 void PNode::setName (const char* newName) 561 545 { 562 546 this->objectName = new char[strlen(newName)+1]; … … 568 552 \brief gets the name of the node 569 553 */ 570 c har* PNode::getName ()554 const char* PNode::getName () 571 555 { 572 556 return this->objectName; -
orxonox/branches/particleEngine/src/lib/coord/p_node.h
r3938 r3957 57 57 58 58 59 inline Vector *getRelCoor () const { return this->relCoordinate; }59 inline Vector getRelCoor () const { return this->relCoordinate; } 60 60 void setRelCoor (const Vector& relCoord); 61 inline Vector getAbsCoor () const { return *this->absCoordinate; }61 inline Vector getAbsCoor () const { return this->absCoordinate; } 62 62 void setAbsCoor (const Vector& absCoord); 63 63 void shiftCoor (const Vector& shift); 64 64 65 inline Quaternion getRelDir () const { return *this->relDirection; }65 inline Quaternion getRelDir () const { return this->relDirection; } 66 66 void setRelDir (const Quaternion& relDir); 67 inline Quaternion getAbsDir () const { return *this->absDirection; }67 inline Quaternion getAbsDir () const { return this->absDirection; } 68 68 void setAbsDir (const Quaternion& absDir); 69 69 void shiftDir (const Quaternion& shift); … … 86 86 void processTick (float dt); 87 87 88 void setName (c har* newName);89 c har* getName ();88 void setName (const char* newName); 89 const char* getName (); 90 90 91 91 … … 100 100 bool bRelDirChanged; //!< If Relative Direction has changed since last time we checked 101 101 102 Vector *relCoordinate; //!< coordinates relative to the parent103 Vector *absCoordinate; //!< absolute coordinates in the world ( from (0,0,0) )104 Quaternion *relDirection; //!< direction relative to the parent105 Quaternion *absDirection; //!< absolute direvtion in the world ( from (0,0,1) )102 Vector relCoordinate; //!< coordinates relative to the parent 103 Vector absCoordinate; //!< absolute coordinates in the world ( from (0,0,0) ) 104 Quaternion relDirection; //!< direction relative to the parent 105 Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) ) 106 106 107 107 int mode; //!< the mode of the binding … … 110 110 void init(PNode* parent); 111 111 112 Vector *lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate113 Vector *diffCoordinate; //!< this is stored here for performance reasons, difference to the last vector112 Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate 113 Vector diffCoordinate; //!< this is stored here for performance reasons, difference to the last vector 114 114 float time; //!< time since last update 115 115 };
Note: See TracChangeset
for help on using the changeset viewer.