Changeset 4194 in orxonox.OLD for orxonox/branches/openAL/src/lib/coord/p_node.cc
- Timestamp:
- May 16, 2005, 1:33:19 PM (19 years ago)
- Location:
- orxonox/branches/openAL
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/openAL
- Property svn:externals
-
old new 1 data http://svn.orxonox.ethz.ch/data 1
-
- Property svn:externals
-
orxonox/branches/openAL/src/lib/coord/p_node.cc
r3860 r4194 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 … … 107 99 this->parent = parent; 108 100 this->objectName = NULL; 109 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 101 } 118 102 … … 158 142 { 159 143 this->bRelCoorChanged = true; 160 *this->relCoordinate = relCoord;144 this->relCoordinate = relCoord; 161 145 } 162 146 … … 182 166 { 183 167 this->bAbsCoorChanged = true; 184 *this->absCoordinate = absCoord;168 this->absCoordinate = absCoord; 185 169 } 186 170 … … 211 195 if( unlikely(this->bAbsCoorChanged)) 212 196 { 213 *this->absCoordinate = *this->absCoordinate +shift;197 this->absCoordinate += shift; 214 198 } 215 199 else 216 200 { 217 *this->relCoordinate = *this->relCoordinate +shift;201 this->relCoordinate += shift; 218 202 this->bRelCoorChanged = true; 219 203 } … … 241 225 { 242 226 this->bRelCoorChanged = true; 243 *this->relDirection = relDir;227 this->relDirection = relDir; 244 228 } 245 229 … … 264 248 { 265 249 this->bAbsDirChanged = true; 266 *this->absDirection = absDir;250 this->absDirection = absDir; 267 251 } 268 252 … … 293 277 { 294 278 this->bRelDirChanged = true; 295 *this->relDirection = *this->relDirection * shift; 296 } 297 298 299 300 /** 301 \brief this calculates the current movement speed of the node 302 */ 303 float PNode::getSpeed() const 304 { 305 *this->diffCoordinate = *this->absCoordinate - *this->lastAbsCoordinate; 306 return this->diffCoordinate->len() / this->time; 307 } 308 279 this->relDirection = this->relDirection * shift; 280 } 309 281 310 282 /** … … 432 404 void PNode::update (float dt) 433 405 { 434 *this->lastAbsCoordinate = *this->absCoordinate;435 this->time = dt; 436 PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate ->x, this->absCoordinate->y, this->absCoordinate->z);406 this->lastAbsCoordinate = this->absCoordinate; 407 408 PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 437 409 438 410 … … 442 414 { 443 415 /* if you have set the absolute coordinates this overrides all other changes */ 444 *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();416 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 445 417 } 446 418 if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) … … 455 427 } 456 428 else */ 457 *this->absCoordinate = parent->getAbsCoor() + *this->relCoordinate; /* update the current absCoordinate */429 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate; /* update the current absCoordinate */ 458 430 } 459 431 } … … 464 436 { 465 437 /* if you have set the absolute coordinates this overrides all other changes */ 466 *this->relDirection = *this->absDirection - parent->getAbsDir();438 this->relDirection = this->absDirection - parent->getAbsDir(); 467 439 } 468 440 else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 469 441 { 470 442 /* update the current absDirection - remember * means rotation around sth.*/ 471 *this->absDirection = parent->getAbsDir() * *this->relDirection;443 this->absDirection = parent->getAbsDir() * this->relDirection; 472 444 } 473 445 } … … 478 450 { 479 451 /* if you have set the absolute coordinates this overrides all other changes */ 480 *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();452 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 481 453 } 482 454 else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) … … 486 458 *this->absCoordinate = *this->relCoordinate; 487 459 else*/ 488 *this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(*this->relCoordinate); /* update the current absCoordinate */460 this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate); /* update the current absCoordinate */ 489 461 } 490 462 } … … 508 480 delete iterator; 509 481 482 this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt; 510 483 this->timeStamp = timeStamp; 511 484 this->bRelCoorChanged = false; … … 540 513 { 541 514 PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n", 542 this->absCoordinate ->x,543 this->absCoordinate ->y,544 this->absCoordinate ->z);515 this->absCoordinate.x, 516 this->absCoordinate.y, 517 this->absCoordinate.z); 545 518 } 546 519 … … 551 524 for debug purposes realy usefull, not used to work properly 552 525 */ 553 void PNode::setName (c har* newName)526 void PNode::setName (const char* newName) 554 527 { 555 528 this->objectName = new char[strlen(newName)+1]; … … 561 534 \brief gets the name of the node 562 535 */ 563 c har* PNode::getName ()536 const char* PNode::getName () 564 537 { 565 538 return this->objectName;
Note: See TracChangeset
for help on using the changeset viewer.