Changeset 5083 in orxonox.OLD for trunk/src/lib/graphics
- Timestamp:
- Aug 19, 2005, 1:54:28 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/render2D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/render2D/element_2d.cc
r5082 r5083 235 235 } 236 236 237 void Element2D::shiftCoor (const Vector& shift)237 void Element2D::shiftCoor2D (const Vector& shift) 238 238 { 239 239 this->relCoordinate += shift; … … 268 268 } 269 269 270 void Element2D::shiftDir (float shiftDir)270 void Element2D::shiftDir2D (float shiftDir) 271 271 { 272 272 this->relDirection = this->relDirection + shiftDir; … … 378 378 void Element2D::update2D (float dt) 379 379 { 380 380 if( likely(this->parent != NULL)) 381 { 382 // movement for nodes with smoothMove enabled 383 if (unlikely(this->toCoordinate != NULL)) 384 { 385 Vector moveVect = (*this->toCoordinate - this->getRelCoor2D()) *dt*bias; 386 387 if (likely(moveVect.len() >= .001))//PNODE_ITERATION_DELTA)) 388 { 389 this->shiftCoor2D(moveVect); 390 } 391 else 392 { 393 delete this->toCoordinate; 394 this->toCoordinate = NULL; 395 PRINTF(5)("SmoothMove of %s finished\n", this->getName()); 396 } 397 } 398 if (unlikely(this->toDirection != NULL)) 399 { 400 float rotFlot = (*this->toDirection - this->getRelDir2D()) *dt*bias; 401 if (likely(rotFlot >= .001))//PNODE_ITERATION_DELTA)) 402 { 403 this->shiftDir2D(rotFlot); 404 } 405 else 406 { 407 delete this->toDirection; 408 this->toDirection = NULL; 409 PRINTF(5)("SmoothRotate of %s finished\n", this->getName()); 410 } 411 } 412 413 // MAIN UPDATE ///////////////////////////////////// 414 this->lastAbsCoordinate = this->absCoordinate; 415 416 PRINTF(5)("PNode::update - %s - (%f, %f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 417 418 419 if( this->parentMode & PNODE_LOCAL_ROTATE && this->bRelDirChanged) 420 { 421 /* update the current absDirection - remember * means rotation around sth.*/ 422 this->prevRelCoordinate = this->relCoordinate; 423 this->absDirection = this->relDirection + parent->getAbsDir2D();; 424 } 425 426 if(likely(this->parentMode & PNODE_MOVEMENT)) 427 { 428 /* update the current absCoordinate */ 429 this->prevRelCoordinate = this->relCoordinate; 430 this->absCoordinate = this->parent->getAbsCoor2D() + this->relCoordinate; 431 } 432 else if( this->parentMode & PNODE_ROTATE_MOVEMENT) 433 { 434 /* update the current absCoordinate */ 435 this->prevRelCoordinate = this->relCoordinate; 436 //this->absCoordinate = this->parent->getAbsCoor2D(); 437 this->absCoordinate.x = this->parent->getAbsCoor2D().x + (this->relCoordinate.x*cos(this->parent->getAbsDir2D()) - this->relCoordinate.y * sin(this->parent->getAbsDir2D())); 438 this->absCoordinate.y = this->parent->getAbsCoor2D().y + (this->relCoordinate.x*sin(this->parent->getAbsDir2D()) + this->relCoordinate.y * cos(this->parent->getAbsDir2D())); 439 440 } 441 ///////////////////////////////////////////////// 442 } 443 else 444 { 445 PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 446 if (this->bRelCoorChanged) 447 this->absCoordinate = this->relCoordinate; 448 if (this->bRelDirChanged) 449 this->absDirection = this->getAbsDir2D() * this->relDirection; 450 } 451 452 if(this->children->getSize() > 0) 453 { 454 tIterator<Element2D>* iterator = this->children->getIterator(); 455 Element2D* pn = iterator->nextElement(); 456 while( pn != NULL) 457 { 458 /* if this node has changed, make sure, that all children are updated also */ 459 if( likely(this->bRelCoorChanged)) 460 pn->parentCoorChanged (); 461 if( likely(this->bRelDirChanged)) 462 pn->parentDirChanged (); 463 464 pn->update2D(dt); 465 //pn = this->children->nextElement(); 466 pn = iterator->nextElement(); 467 } 468 delete iterator; 469 } 470 this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt; 471 this->bRelCoorChanged = false; 472 this->bRelDirChanged = false; 381 473 } 382 474 -
trunk/src/lib/graphics/render2D/element_2d.h
r5082 r5083 110 110 /** @returns the absolute position */ 111 111 inline const Vector& getAbsCoor2D () const { return this->absCoordinate; }; 112 void shiftCoor (const Vector& shift);112 void shiftCoor2D (const Vector& shift); 113 113 114 114 void setRelDir2D (float relDir); … … 119 119 /** @returns the absolute Direction */ 120 120 inline float getAbsDir2D () const { return this->absDirection; }; 121 void shiftDir (float shiftDir);121 void shiftDir2D (float shiftDir); 122 122 123 123 /** @returns the Speed of the Node */
Note: See TracChangeset
for help on using the changeset viewer.