Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4570 in orxonox.OLD


Ignore:
Timestamp:
Jun 10, 2005, 12:42:35 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: now PNodes can be rendered in Debug-Mode

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

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

    r4448 r4570  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    1313   ### File Specific:
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: 
     15   co-programmer:
    1616
    1717   \todo Smooth-Parent: delay, speed
     
    4040   \brief standard constructor
    4141*/
    42 PNode::PNode () 
     42PNode::PNode ()
    4343{
    4444  init(NULL);
     
    5454  this->init(NULL);
    5555  this->loadParams(root);
    56  
     56
    5757  NullParent::getInstance()->addChild(this);
    5858}
     
    8080   \brief standard deconstructor
    8181*/
    82 PNode::~PNode () 
     82PNode::~PNode ()
    8383{
    8484  tIterator<PNode>* iterator = this->children->getIterator();
    8585  PNode* pn = iterator->nextElement();
    86   while( pn != NULL) 
    87     { 
     86  while( pn != NULL)
     87    {
    8888      delete pn;
    8989      pn = iterator->nextElement();
     
    106106  this->bRelDirChanged = true;
    107107  this->bAbsDirChanged = false;
    108   this->parent = parent; 
     108  this->parent = parent;
    109109}
    110110
     
    161161   Vector newCoor = currentCoor + objectMovement;
    162162   someNode->setRelCoor(newCoor);
    163    
     163
    164164   yea right... shorter...
    165165
     
    172172      this->absCoordinate += shift;
    173173    }
    174   else 
     174  else
    175175    {
    176176      this->relCoordinate += shift;
     
    223223   Quaternion newCoor = currentCoor + objectMovement;
    224224   someNode->setRelCoor(newCoor);
    225    
     225
    226226   yea right... shorter...
    227227
     
    278278  tIterator<PNode>* iterator = this->children->getIterator();
    279279  PNode* pn = iterator->nextElement();
    280  
    281   while( pn != NULL) 
    282     { 
     280
     281  while( pn != NULL)
     282    {
    283283      nullParent->addChild(pn, pn->getParentMode());
    284284      pn = iterator->nextElement();
     
    311311/**
    312312   \brief has to be called, if the parent coordinate has changed
    313    
     313
    314314   normaly this will be done by the parent itself automaticaly. If you call this, you
    315315   will force an update of the coordinated of the node.
     
    327327
    328328   this is used to go through the parent-tree to update all the absolute coordinates
    329    and directions. this update should be done by the engine, so you don't have to 
     329   and directions. this update should be done by the engine, so you don't have to
    330330   worry, normaly...
    331331*/
     
    340340
    341341      if( likely(this->parentMode & PNODE_MOVEMENT))
    342         {
    343           if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
    344             {
    345               /* if you have set the absolute coordinates this overrides all other changes */
    346               this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
    347             }
    348           if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
    349 
    350             {
    351               /*this is bad style... must be deleted later - just for testing*/
    352 
    353               /*
    354                 if( unlikely(this->parent == NULL))
    355                 {
    356                 *this->absCoordinate = *this->relCoordinate;
    357                 }
    358                 else */
    359               this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;       /* update the current absCoordinate */
    360             }
    361         }
    362  
     342        {
     343          if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     344            {
     345              /* if you have set the absolute coordinates this overrides all other changes */
     346              this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
     347            }
     348          if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     349
     350            {
     351              /*this is bad style... must be deleted later - just for testing*/
     352
     353              /*
     354                if( unlikely(this->parent == NULL))
     355                {
     356                *this->absCoordinate = *this->relCoordinate;
     357                }
     358                else */
     359              this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;       /* update the current absCoordinate */
     360            }
     361        }
     362
    363363      if( this->parentMode & PNODE_LOCAL_ROTATE)
    364         {
    365           if( unlikely(this->bAbsDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
    366             {
    367               /* if you have set the absolute coordinates this overrides all other changes */
    368               this->relDirection = this->absDirection - parent->getAbsDir();
    369             }
    370           else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
    371             {
    372               /* update the current absDirection - remember * means rotation around sth.*/
    373               this->absDirection = parent->getAbsDir() * this->relDirection;
    374             }
    375         }
    376  
     364        {
     365          if( unlikely(this->bAbsDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     366            {
     367              /* if you have set the absolute coordinates this overrides all other changes */
     368              this->relDirection = this->absDirection - parent->getAbsDir();
     369            }
     370          else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     371            {
     372              /* update the current absDirection - remember * means rotation around sth.*/
     373              this->absDirection = parent->getAbsDir() * this->relDirection;
     374            }
     375        }
     376
    377377      if( this->parentMode & PNODE_ROTATE_MOVEMENT)
    378         {
    379           if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
    380             {
    381               /* if you have set the absolute coordinates this overrides all other changes */
    382               this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
    383             }
    384           else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
    385             {
    386               /*this is bad style... must be deleted later - just for testing*/
    387               /*if( this->parent == NULL)
    388                *this->absCoordinate = *this->relCoordinate;
    389                else*/
    390               this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);            /* update the current absCoordinate */
    391             }
    392         }
    393  
    394  
     378        {
     379          if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     380            {
     381              /* if you have set the absolute coordinates this overrides all other changes */
     382              this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
     383            }
     384          else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     385            {
     386              /*this is bad style... must be deleted later - just for testing*/
     387              /*if( this->parent == NULL)
     388               *this->absCoordinate = *this->relCoordinate;
     389               else*/
     390              this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);            /* update the current absCoordinate */
     391            }
     392        }
     393
     394
    395395      tIterator<PNode>* iterator = this->children->getIterator();
    396396      //PNode* pn = this->children->enumerate();
    397397      PNode* pn = iterator->nextElement();
    398       while( pn != NULL) 
    399         {
    400           /* if this node has changed, make sure, that all children are updated also */
    401           if( likely(this->bRelCoorChanged || this->bAbsCoorChanged))
    402             pn->parentCoorChanged ();
    403           if( likely(this->bRelDirChanged || this->bAbsDirChanged))
    404             pn->parentDirChanged ();
    405 
    406           pn->update(dt);
    407           //pn = this->children->nextElement();
    408           pn = iterator->nextElement();
    409         }
     398      while( pn != NULL)
     399        {
     400          /* if this node has changed, make sure, that all children are updated also */
     401          if( likely(this->bRelCoorChanged || this->bAbsCoorChanged))
     402            pn->parentCoorChanged ();
     403          if( likely(this->bRelDirChanged || this->bAbsDirChanged))
     404            pn->parentDirChanged ();
     405
     406          pn->update(dt);
     407          //pn = this->children->nextElement();
     408          pn = iterator->nextElement();
     409        }
    410410      delete iterator;
    411411
     
    425425      //PNode* pn = this->children->enumerate ();
    426426      PNode* pn = iterator->nextElement();
    427       while( pn != NULL) 
    428         {
    429           /* if this node has changed, make sure, that all children are updated also */
    430           if( this->bRelCoorChanged || this->bAbsCoorChanged)
    431             pn->parentCoorChanged ();
    432           if( this->bRelDirChanged || this->bAbsDirChanged)
    433             pn->parentDirChanged ();
    434           pn->update (dt);
    435           //pn = this->children->nextElement ();
    436           pn = iterator->nextElement();
    437         }
     427      while( pn != NULL)
     428        {
     429          /* if this node has changed, make sure, that all children are updated also */
     430          if( this->bRelCoorChanged || this->bAbsCoorChanged)
     431            pn->parentCoorChanged ();
     432          if( this->bRelDirChanged || this->bAbsDirChanged)
     433            pn->parentDirChanged ();
     434          pn->update (dt);
     435          //pn = this->children->nextElement ();
     436          pn = iterator->nextElement();
     437        }
    438438
    439439      this->bRelCoorChanged = false;
     
    449449void PNode::debug()
    450450{
    451   PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n",
    452          this->absCoordinate.x,
    453          this->absCoordinate.y,
    454          this->absCoordinate.z);
    455 }
    456 
     451  PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n",
     452         this->absCoordinate.x,
     453         this->absCoordinate.y,
     454         this->absCoordinate.z);
     455}
     456
     457/**
     458  @brief displays the PNode at its position with its rotation as a cube.
     459*/
     460void PNode::debugDraw(float size) const
     461{
     462  glMatrixMode(GL_MODELVIEW);
     463  glPushMatrix();
     464  float matrix[4][4];
     465
     466  /* translate */
     467  glTranslatef (this->getAbsCoor ().x,
     468                this->getAbsCoor ().y,
     469                this->getAbsCoor ().z);
     470  /* rotate */
     471  this->getAbsDir ().matrix (matrix);
     472  glMultMatrixf((float*)matrix);
     473  {
     474    glBegin(GL_LINE_STRIP);
     475    glVertex3f( .5,  .5, -.5);
     476    glVertex3f( .5,  .5,  .5);
     477    glVertex3f(-.5,  .5,  .5);
     478    glVertex3f(-.5, -.5,  .5);
     479    glVertex3f( .5,  .5, -.5);
     480    glVertex3f( .5, -.5, -.5);
     481    glVertex3f(-.5, -.5, -.5);
     482    glVertex3f(-.5,  .5, -.5);
     483    glEnd();
     484    glBegin(GL_LINE_STRIP);
     485    glVertex3f(-.5, -.5, -.5);
     486    glVertex3f(-.5, -.5,  .5);
     487    glVertex3f( .5, -.5,  .5);
     488    glVertex3f( .5, -.5, -.5);
     489    glEnd();
     490    glBegin(GL_LINES);
     491    glVertex3f( .5, -.5,  .5);
     492    glVertex3f( .5,  .5,  .5);
     493    glVertex3f(-.5, -.5,  .5);
     494    glVertex3f(-.5,  .5,  .5);
     495    glEnd();
     496  }
     497
     498  glPopMatrix();
     499}
  • orxonox/trunk/src/lib/coord/p_node.h

    r4448 r4570  
    1 /*! 
     1/*!
    22    \file p_node.h
    33    \brief Definition of a parenting node
     
    99
    1010    absCoordinate, absDirection have to be recalculated as soon as there was a change in
    11     place or ortientation. this is only the case if 
     11    place or ortientation. this is only the case if
    1212    o bDirChanged is true (so changed) AND timeStamp != now
    1313    o bCoorChanged is true (so moved) AND timeStamp != now
     
    7878
    7979  /** \returns the Speed of the Node */
    80   inline float getSpeed() const {return this->velocity.len();} 
     80  inline float getSpeed() const {return this->velocity.len();}
    8181  /** \returns the Velocity of the Node */
    8282  inline const Vector& getVelocity() const {return this->velocity;}
     
    9595
    9696  void debug ();
    97 
     97  void debugDraw(float size = 1.0) const;
    9898
    9999 private:
     
    128128
    129129#endif /* _P_NODE_H */
    130  
     130
  • orxonox/trunk/src/story_entities/world.cc

    r4564 r4570  
    856856  WorldEntity* entity;
    857857  glLoadIdentity();
    858 
    859858  //entity = this->entities->enumerate();
    860859  tIterator<WorldEntity>* iterator = this->entities->getIterator();
  • orxonox/trunk/src/world_entities/world_entity.cc

    r4436 r4570  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    8989   \brief set the WorldEntity's collision hull
    9090   \param newhull: a pointer to a completely assembled CollisionCluster
    91    
     91
    9292   Any previously assigned collision hull will be deleted on reassignment
    9393*/
     
    102102
    103103
    104 /** 
    105     \brief process draw function 
     104/**
     105    \brief process draw function
    106106*/
    107107void WorldEntity::processDraw ()
     
    143143/**
    144144   \brief this is called immediately after the Entity has been constructed and initialized
    145    
     145
    146146   Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
    147147   DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
     
    154154/**
    155155   \brief this method is called by the world if the WorldEntity leaves valid gamespace
    156    
     156
    157157   For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
    158158   place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
     
    166166   \brief this method is called every frame
    167167   \param time: the time in seconds that has passed since the last tick
    168    
     168
    169169   Handle all stuff that should update with time inside this method (movement, animation, etc.)
    170170*/
    171 void WorldEntity::tick(float time) 
     171void WorldEntity::tick(float time)
    172172{
    173173}
     
    176176/**
    177177   \brief the entity is drawn onto the screen with this function
    178    
     178
    179179   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
    180180*/
    181 void WorldEntity::draw() 
     181void WorldEntity::draw()
    182182{
    183183  glMatrixMode(GL_MODELVIEW);
    184184  glPushMatrix();
    185185  float matrix[4][4];
    186  
     186
    187187  /* translate */
    188   glTranslatef (this->getAbsCoor ().x, 
    189                 this->getAbsCoor ().y,
    190                 this->getAbsCoor ().z);
     188  glTranslatef (this->getAbsCoor ().x,
     189                this->getAbsCoor ().y,
     190                this->getAbsCoor ().z);
    191191  /* rotate */
    192192  this->getAbsDir ().matrix (matrix);
     
    202202   \brief this handles incoming command messages
    203203   \param cmd: a pointer to the incoming Command structure
    204    
     204
    205205   Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
    206206   to send commands from one WorldEntity to another.
Note: See TracChangeset for help on using the changeset viewer.