Changeset 4122 in orxonox.OLD for orxonox/branches/heightMap/src/lib/coord/p_node.cc
- Timestamp:
- May 9, 2005, 11:29:19 AM (20 years ago)
- Location:
- orxonox/branches/heightMap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/heightMap
- Property svn:externals
-
old new 1 data http://svn.orxonox.ethz.ch/data 1
-
- Property svn:externals
-
orxonox/branches/heightMap/src/lib/coord/p_node.cc
r3860 r4122 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 += shift; 214 199 } 215 200 else 216 201 { 217 *this->relCoordinate = *this->relCoordinate +shift;202 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; 307 } 308 290 return (this->absCoordinate - this->lastAbsCoordinate).len() / this->time; 291 } 292 293 /** 294 \returns the Velocity of the PNode 295 */ 296 Vector PNode::getVelocity() const 297 { 298 return (this->absCoordinate - this->lastAbsCoordinate) / this->time; 299 } 309 300 310 301 /** … … 432 423 void PNode::update (float dt) 433 424 { 434 *this->lastAbsCoordinate = *this->absCoordinate;425 this->lastAbsCoordinate = this->absCoordinate; 435 426 this->time = dt; 436 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); 437 428 438 429 … … 442 433 { 443 434 /* if you have set the absolute coordinates this overrides all other changes */ 444 *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();435 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 445 436 } 446 437 if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) … … 455 446 } 456 447 else */ 457 *this->absCoordinate = parent->getAbsCoor() + *this->relCoordinate; /* update the current absCoordinate */448 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate; /* update the current absCoordinate */ 458 449 } 459 450 } … … 464 455 { 465 456 /* if you have set the absolute coordinates this overrides all other changes */ 466 *this->relDirection = *this->absDirection - parent->getAbsDir();457 this->relDirection = this->absDirection - parent->getAbsDir(); 467 458 } 468 459 else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 469 460 { 470 461 /* update the current absDirection - remember * means rotation around sth.*/ 471 *this->absDirection = parent->getAbsDir() * *this->relDirection;462 this->absDirection = parent->getAbsDir() * this->relDirection; 472 463 } 473 464 } … … 478 469 { 479 470 /* if you have set the absolute coordinates this overrides all other changes */ 480 *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();471 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 481 472 } 482 473 else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) … … 486 477 *this->absCoordinate = *this->relCoordinate; 487 478 else*/ 488 *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 */ 489 480 } 490 481 } … … 540 531 { 541 532 PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n", 542 this->absCoordinate ->x,543 this->absCoordinate ->y,544 this->absCoordinate ->z);533 this->absCoordinate.x, 534 this->absCoordinate.y, 535 this->absCoordinate.z); 545 536 } 546 537 … … 551 542 for debug purposes realy usefull, not used to work properly 552 543 */ 553 void PNode::setName (c har* newName)544 void PNode::setName (const char* newName) 554 545 { 555 546 this->objectName = new char[strlen(newName)+1]; … … 561 552 \brief gets the name of the node 562 553 */ 563 c har* PNode::getName ()554 const char* PNode::getName () 564 555 { 565 556 return this->objectName;
Note: See TracChangeset
for help on using the changeset viewer.