Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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
Files:
6 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
  • orxonox/trunk/src/story_entities/world.cc

    r3643 r3644  
    128128World::World (int worldID)
    129129{
    130   printf(">>>>>>>>>>>>>>>>>WORLD::WORLD called NEW WORLD created\n");
    131130  this->init(NULL, worldID);
    132131}
     
    604603  p4->debug ();
    605604 
    606   p1->update ();
     605  p1->update (0);
    607606
    608607  printf ("World::debug() - update\n");
     
    613612
    614613  p2->shiftCoor (new Vector(-1, -1, -1));
    615   p1->update ();
     614  p1->update (0);
    616615
    617616  p1->debug ();
     
    623622
    624623
    625  p1->update ();
     624 p1->update (0);
    626625
    627626  p1->debug ();
     
    720719  if(!this->bPause)
    721720    {
    722       Uint32 dt = currentFrame - this->lastFrame;
     721      this->dt = currentFrame - this->lastFrame;
    723722     
    724723      if(dt > 0)
     
    765764void World::update()
    766765{
    767   this->nullParent->update ();
     766  this->nullParent->update (dt);
    768767}
    769768
  • orxonox/trunk/src/story_entities/world.h

    r3634 r3644  
    8787
    8888  Uint32 lastFrame;             //!< last time of frame
     89  Uint32 dt;                    //!< time needed to calculate this frame
    8990  bool bQuitOrxonox;            //!< quit this application
    9091  bool bQuitCurrentGame;        //!< quit only the current game and return to menu
Note: See TracChangeset for help on using the changeset viewer.