Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5083 in orxonox.OLD


Ignore:
Timestamp:
Aug 19, 2005, 1:54:28 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: implemented the update function

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r5082 r5083  
    578578      {
    579579        /* update the current absCoordinate */
    580         this->prevRelDirection = this->relDirection;
     580        this->prevRelCoordinate = this->relCoordinate;
    581581        this->absCoordinate = this->parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);
    582582      }
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5082 r5083  
    235235}
    236236
    237 void Element2D::shiftCoor (const Vector& shift)
     237void Element2D::shiftCoor2D (const Vector& shift)
    238238{
    239239  this->relCoordinate += shift;
     
    268268}
    269269
    270 void Element2D::shiftDir (float shiftDir)
     270void Element2D::shiftDir2D (float shiftDir)
    271271{
    272272  this->relDirection = this->relDirection + shiftDir;
     
    378378void Element2D::update2D (float dt)
    379379{
    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;
    381473}
    382474
  • trunk/src/lib/graphics/render2D/element_2d.h

    r5082 r5083  
    110110    /** @returns the absolute position */
    111111    inline const Vector& getAbsCoor2D () const { return this->absCoordinate; };
    112     void shiftCoor (const Vector& shift);
     112    void shiftCoor2D (const Vector& shift);
    113113
    114114    void setRelDir2D (float relDir);
     
    119119    /** @returns the absolute Direction */
    120120    inline float getAbsDir2D () const { return this->absDirection; };
    121     void shiftDir (float shiftDir);
     121    void shiftDir2D (float shiftDir);
    122122
    123123    /** @returns the Speed of the Node */
  • trunk/src/util/shell.cc

    r5082 r5083  
    4242  this->bufferText = NULL;
    4343  this->setBufferSize(100);
    44   this->setBufferDisplaySize(8);
     44  this->setBufferDisplaySize(10);
    4545
    4646  this->inputLineText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 255, 0, 0);
Note: See TracChangeset for help on using the changeset viewer.