Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 18, 2005, 11:52:15 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: merged trunk back to levelloader
merged with command:
svn merge -r 3499:HEAD trunk branches/levelloader

Conflicts in
C track_manager.h
C world_entities/player.cc
C world_entities/player.h
C world_entities/environment.h
C lib/coord/p_node.cc
C defs/debug.h
C track_manager.cc
C story_entities/campaign.h

solved in merge-favouring. It was quite easy because Chris only worked on the headers, and he didi it quite clean. Thats the spirit :)

Conflits in world.cc are a MESS: fix it

File:
1 edited

Legend:

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

    r3557 r3605  
    1313   ### File Specific:
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: ...
    16 
    17    \todo Null-Parent => center of the coord system - singleton
     15   co-programmer:
     16
    1817   \todo Smooth-Parent: delay, speed
    19    \todo destroy the stuff again, delete...
    20 */
    21 
     18*/
     19
     20#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PNODE
    2221
    2322#include "p_node.h"
    2423
     24#include "null_parent.h"
     25#include "vector.h"
    2526
    2627using namespace std;
     
    3435PNode::PNode ()
    3536{
    36   this->children = new tList<PNode>();
    37   this->bRelCoorChanged = true;
    38   this->bAbsCoorChanged = false;
    39   this->bRelDirChanged = true;
    40   this->bAbsDirChanged = false;
    41   this->parent = NULL;
     37  init(NULL);
     38
     39  NullParent* np = NullParent::getInstance();
     40  np->addChild(this);
    4241  this->objectName = NULL;
    4342}
     
    5150PNode::PNode (Vector* absCoordinate, PNode* parent )
    5251{
     52  this->init(parent);
     53
    5354  this->absCoordinate = *absCoordinate;
    54   this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
    55  
    56   this->children = new tList<PNode>();
    57   this->bRelCoorChanged = true;
    58   this->bAbsCoorChanged = false;
    59   this->bRelDirChanged = true;
    60   this->bAbsDirChanged = false;
    61   this->parent = parent;
    62   this->objectName = NULL;
    63  
    64   parent->addChild (this);
    65 }
    66 
     55  if (parent != NULL)
     56    {
     57      this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
     58      parent->addChild (this);
     59    }
     60  else
     61    this->relCoordinate = Vector(0,0,0);
     62}
    6763
    6864/**
     
    8076  delete &this->absDirection;
    8177  */
    82   this->parent = NULL;
     78  //this->parent = NULL;
    8379  if( this->objectName) delete this->objectName;
    8480  /* there is currently a problem with cleaning up - fix*/
    85 }
    86 
     81
     82  PNode* pn = this->children->enumerate();
     83  while( pn != NULL)
     84    {
     85      delete pn;
     86      pn = this->children->nextElement();
     87
     88    }
     89   
     90  /* this deletes all children in the list */
     91  delete this->children;
     92
     93  delete []this->objectName;
     94}
     95
     96void PNode::init(PNode* parent)
     97{
     98  this->children = new tList<PNode>();
     99  this->bRelCoorChanged = true;
     100  this->bAbsCoorChanged = false;
     101  this->bRelDirChanged = true;
     102  this->bAbsDirChanged = false;
     103  this->parent = parent;
     104  this->objectName = NULL;
     105}
    87106
    88107/**
     
    91110   cleans up all pnodes
    92111*/
     112/*
    93113void PNode::destroy ()
    94114{
     
    99119      pn = this->children->nextElement();
    100120    }
     121  // this deletes all children in the list
    101122  this->children->destroy ();
    102 }
    103 
     123
     124  static_cast<BaseObject*>(this)->destroy();
     125}
     126*/
    104127
    105128/**
     
    262285{}
    263286
    264 
    265 
    266287/**
    267288   \brief adds a child and makes this node to a parent
     
    283304   use this to add a child to this node.
    284305*/
    285 void PNode::addChild (PNode* pNode, parentingMode mode)
    286 {
    287   pNode->mode = mode;
     306void PNode::addChild (PNode* pNode, int parentingMode)
     307{
     308  if( pNode->parent != NULL )
     309    {
     310      PRINTF(2)("PNode::addChild() - reparenting node: removing it and adding it again\n");
     311      pNode->parent->children->remove(pNode);
     312    }
     313  pNode->mode = parentingMode;
    288314  pNode->parent = this;
    289   this->children->add (pNode);
     315  this->children->add(pNode);
    290316}
    291317
     
    294320   \brief removes a child from the node
    295321   \param pNode the child to remove from this pNode.
     322
     323   Children from pNode will not be lost, they are referenced to NullPointer
    296324*/
    297325void PNode::removeChild (PNode* pNode)
    298326{
     327  pNode->remove();
    299328  this->children->remove (pNode);
     329  pNode->parent = NULL;
     330}
     331
     332
     333/**
     334   \brief remove this pnode from the tree and adds all following to NullParent
     335
     336   this can be the case, if an entity in the world is been destroyed.
     337*/
     338void PNode::remove()
     339{
     340  NullParent* np = NullParent::getInstance();
     341  PNode* pn = this->children->enumerate();
     342  while( pn != NULL)
     343    {
     344      this->children->remove(pn);
     345      np->addChild(pn, pn->getMode());
     346      pn = this->children->nextElement();
     347    }
    300348}
    301349
     
    307355void PNode::setParent (PNode* parent)
    308356{
    309   this->parent = parent;
    310 }
     357  parent->addChild(this);
     358}
     359
    311360
    312361/**
     
    314363   \param mode the mode of the bind-type.
    315364*/
    316 void PNode::setMode (parentingMode mode)
    317 {
    318   this->mode = mode;
     365void PNode::setMode (int parentingMode)
     366{
     367  this->mode = parentingMode;
     368}
     369
     370
     371/**
     372   \brief gets the mode of this parent manualy
     373   \return the mode of the bind-type.
     374*/
     375int PNode::getMode()
     376{
     377  return this->mode;
    319378}
    320379
     
    351410   worry, normaly...
    352411*/
    353 void PNode::update (float timeStamp)
    354 {
    355   printf ("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
    356 
    357       if( this->mode == MOVEMENT || this->mode == ALL)
     412void PNode::update ()
     413{
     414  PRINTF(2)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
     415  // printf("%s", this->objectName);
     416  if(this->mode & PNODE_MOVEMENT )
     417    {
     418      if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    358419        {
    359           if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     420          /* if you have set the absolute coordinates this overrides all other changes */
     421          this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
     422        }
     423      else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     424        {
     425          /*this is bad style... must be deleted later - just for testing*/
     426          if( this->parent == NULL)
    360427            {
    361               printf("PNode::update () - this->bAbsCoorChanged = true\n");
    362               /* if you have set the absolute coordinates this overrides all other changes */
    363               this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
     428              this->absCoordinate = this->relCoordinate;
    364429            }
    365           else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    366             {
    367               /*this is bad style... must be deleted later - just for testing*/
    368               if( this->parent == NULL)
    369                 {
    370                 this->absCoordinate = this->relCoordinate;
    371                 }
    372               else
    373                 this->absCoordinate = parent->getAbsCoor () + this->relCoordinate;            /* update the current absCoordinate */
    374             }
     430          else
     431            this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;         /* update the current absCoordinate */
    375432        }
    376      
    377       if( this->mode == ROTATION && this->mode == ALL)
     433    }
     434 
     435  if( this->mode & PNODE_LOCAL_ROTATE)
     436    {
     437      if( this->bAbsDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    378438        {
    379           if( this->bAbsDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    380             {
    381               /* if you have set the absolute coordinates this overrides all other changes */
    382               this->relDirection = this->absDirection - parent->getAbsDir ();
    383             }
    384           else if( this->bRelDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    385             {
    386               /* update the current absDirection - remember * means rotation around sth.*/
    387               this->absDirection = parent->getAbsDir () * this->relDirection;
    388             }
    389         }   
    390       // }
     439          /* if you have set the absolute coordinates this overrides all other changes */
     440          this->relDirection = this->absDirection - parent->getAbsDir();
     441        }
     442      else if( this->bRelDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     443        {
     444          /* update the current absDirection - remember * means rotation around sth.*/
     445          this->absDirection = parent->getAbsDir() * this->relDirection;
     446        }
     447    }
     448 
     449  if( this->mode & PNODE_ROTATE_MOVEMENT)
     450    {
     451      if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     452        {
     453          /* if you have set the absolute coordinates this overrides all other changes */
     454          this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
     455        }
     456      else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     457        {
     458          /*this is bad style... must be deleted later - just for testing*/
     459          if( this->parent == NULL)
     460            this->absCoordinate = this->relCoordinate;
     461          else
     462            this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);              /* update the current absCoordinate */
     463        }
     464    }
     465 
     466 
    391467  PNode* pn = this->children->enumerate();
    392468  while( pn != NULL)
     
    397473      if( this->bRelDirChanged || this->bAbsDirChanged)
    398474        pn->parentDirChanged ();
    399       pn->update(timeStamp);
     475      pn->update();
    400476      pn = this->children->nextElement();
    401477    }
     
    415491void PNode::processTick (float dt)
    416492{
    417   this->tick (dt);
     493  //this->tick (dt);
    418494  PNode* pn = this->children->enumerate();
    419495  while( pn != NULL)
     
    424500}
    425501
    426 /**
    427    \param dt time to tick
    428 */
    429 void PNode::tick (float dt)
    430 {}
    431502
    432503/**
     
    435506void PNode::debug()
    436507{
    437   printf("PNode::debug() - absCoord: (%f, %f, %f)\n",
     508  PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n",
    438509         this->absCoordinate.x,
    439510         this->absCoordinate.y,
     
    451522void PNode::setName (const char* newName)
    452523{
    453         int l = strlen( newName);
    454        
    455         if( this->objectName != NULL) delete this->objectName;
    456         this->objectName = NULL;
    457        
    458         if( newName != NULL)
    459         {
    460                 this->objectName = new char[l+1];
    461                
    462                 for( int i = 0; i < l+1; i++)
    463                         this->objectName[i] = newName[i];
    464         }
     524  if (this->objectName)
     525    delete []this->objectName;
     526  this->objectName = new char[strlen(newName)+1];
     527  strcpy(this->objectName,newName);
    465528}
    466529
     
    473536  return this->objectName;
    474537}
     538
Note: See TracChangeset for help on using the changeset viewer.