Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3644 in orxonox.OLD for orxonox/trunk/src/lib


Ignore:
Timestamp:
Mar 23, 2005, 2:32:06 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: pnode speed function implemented

Location:
orxonox/trunk/src/lib/coord
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/coord/null_parent.cc

    r3608 r3644  
    7777   worry, normaly...
    7878*/
    79 void NullParent::update ()
     79void NullParent::update (float dt)
    8080{
    8181
     
    9292      if( this->bRelDirChanged || this->bAbsDirChanged)
    9393        pn->parentDirChanged ();
    94       pn->update ();
     94      pn->update (dt);
    9595      pn = this->children->nextElement ();
    9696    }
  • orxonox/trunk/src/lib/coord/null_parent.h

    r3607 r3644  
    1919
    2020
    21   virtual void update ();
    22 
     21  virtual void update (float dt);
     22 
    2323 private:
    2424  NullParent ();
  • orxonox/trunk/src/lib/coord/p_node.cc

    r3617 r3644  
    115115  this->absDirection = new Quaternion();
    116116  this->relDirection = new Quaternion();
     117  this->lastAbsCoordinate = new Vector();
    117118}
    118119
     
    297298{}
    298299
     300
     301/**
     302   \brief this calculates the current movement speed of the node
     303*/
     304float PNode::getSpeed()
     305{
     306  if(this->time == 0)
     307    return 0;
     308  Vector* diff = new Vector();
     309  *diff = *this->absCoordinate - *this->lastAbsCoordinate;
     310  float x = diff->len();
     311  return x / this->time;
     312}
     313
     314
    299315/**
    300316   \brief adds a child and makes this node to a parent
     
    422438   worry, normaly...
    423439*/
    424 void PNode::update ()
    425 {
     440void PNode::update (float dt)
     441{
     442  this->time = dt;
    426443  PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate->x, this->absCoordinate->y, this->absCoordinate->z);
    427444  // printf("%s", this->objectName);
     
    486503        pn->parentDirChanged ();
    487504
    488       pn->update();
     505      pn->update(dt);
    489506      pn = this->children->nextElement();
    490507    }
  • orxonox/trunk/src/lib/coord/p_node.h

    r3608 r3644  
    7272  void shiftDir (Quaternion* shift);
    7373
     74  float getSpeed();
     75
    7476  void addChild (PNode* pNode);
    7577  void addChild (PNode* pNode, int parentingMode);
     
    8486  int getMode();
    8587
    86   virtual void update ();
     88  virtual void update (float dt);
    8789  void processTick (float dt);
    8890
     
    9294
    9395  void debug ();
    94 
    95  private:
    96   void init(PNode* parent);
    9796
    9897 protected:
     
    111110  int mode;                //!< the mode of the binding
    112111
     112 private:
     113  void init(PNode* parent);
     114
     115  Vector* lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate
     116  float time;                //!< time since last update
    113117};
    114118
Note: See TracChangeset for help on using the changeset viewer.