Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3605 in orxonox.OLD for orxonox/branches/levelloader/src/lib/coord


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

Location:
orxonox/branches/levelloader/src/lib/coord
Files:
6 edited

Legend:

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

    r3499 r3605  
    3939   \todo this deconstructor is not jet implemented - do it
    4040*/
    41 HelperParent::~HelperParent () {}
     41HelperParent::~HelperParent ()
     42{
    4243
     44}
  • orxonox/branches/levelloader/src/lib/coord/helper_parent.h

    r3499 r3605  
    1717 public:
    1818  HelperParent ();
    19   ~HelperParent ();
    20 
     19  virtual ~HelperParent ();
    2120
    2221};
  • orxonox/branches/levelloader/src/lib/coord/null_parent.cc

    r3499 r3605  
    1616*/
    1717
     18#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_NULL_PARENT
    1819
    1920#include "null_parent.h"
     
    2627NullParent* NullParent::getInstance ()
    2728{
    28   if( singletonRef == NULL)
     29  if(!singletonRef)
    2930    singletonRef = new NullParent ();
    3031  return singletonRef;
     
    3637   \todo this constructor is not jet implemented - do it
    3738*/
    38 NullParent::NullParent ()
     39NullParent::NullParent () : PNode (new Vector(0,0,0), NULL)
    3940{
     41  PRINTF(4)("NullParent::NullParent() - making new NullParent, there can only be one..\n");
    4042  this->parent = this;
    41   this->mode = ALL;
     43  this->mode = PNODE_ALL;
     44  this->setName("NullParent");
    4245}
    4346
    4447
    45 NullParent::NullParent (Vector* absCoordinate)
     48NullParent::NullParent (Vector* absCoordinate) : PNode (new Vector(0,0,0), NULL)
    4649{
     50  singletonRef = this;
    4751  this->parent = this;
    48   this->mode = ALL;
     52  this->mode = PNODE_ALL;
    4953  this->absCoordinate = *absCoordinate;
     54  this->setName("NullParent");
    5055}
    5156
     
    5863NullParent::~NullParent ()
    5964{
    60   delete singletonRef;
     65  //delete singletonRef;
    6166  singletonRef = NULL;
    6267}
    63 
    64 
    65 
    6668
    6769/**
     
    7274   worry, normaly...
    7375*/
    74 void NullParent::update (float timeStamp)
     76void NullParent::update ()
    7577{
     78
     79  PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
    7680  this->absCoordinate = this->relCoordinate;
    7781  this->absDirection = parent->getAbsDir () * this->relDirection;
     
    8589      if( this->bRelDirChanged || this->bAbsDirChanged)
    8690        pn->parentDirChanged ();
    87       pn->update (timeStamp);
     91      pn->update ();
    8892      pn = this->children->nextElement ();
    8993    }
  • orxonox/branches/levelloader/src/lib/coord/null_parent.h

    r3499 r3605  
    1616 public:
    1717  static NullParent* getInstance ();
    18   ~NullParent ();
    19  
    20   static NullParent* singletonRef;
     18  virtual ~NullParent ();
    2119
    22   virtual void update (float timeStamp);
     20
     21  virtual void update ();
    2322
    2423 private:
    2524  NullParent ();
    2625  NullParent (Vector* absCoordinate);
     26  static NullParent* singletonRef;
    2727
    2828};
  • 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
  • orxonox/branches/levelloader/src/lib/coord/p_node.h

    r3557 r3605  
    2222#define _P_NODE_H
    2323
    24 #include "stdincl.h"
     24#include "base_object.h"
    2525
     26// FORWARD DEFINITION \\
    2627class PNode; /* forward decleration, so that parentEntry has access to PNode */
     28class Quaternion;
     29class Vector;
    2730
    2831//! enumeration for the different translation-binding-types
    29 typedef enum parentingMode {MOVEMENT = 0, ROTATION, ALL};
     32//typedef enum parentingMode {PNODE_LOCAL_ROTATE, PNODE_ROTATE_MOVEMENT, PNODE_ALL, PNODE_MOVEMENT, PNODE_ROTATE_AND_MOVE};
     33// linkage modes
     34#define PNODE_LOCAL_ROTATE       1    //!< Rotates all the children around their centers.
     35#define PNODE_ROTATE_MOVEMENT    2    //!< Moves all the children around the center of their parent, without the rotation around their own centers.
     36#define PNODE_MOVEMENT           4    //!< Moves all children along with the parent.
     37// special linkage modes
     38#define PNODE_ALL                3    //!< Moves all children around the center of their parent, and also rotates their centers
     39#define PNODE_ROTATE_AND_MOVE    5    //!< Rotates all children around their axis, and moves them as the Parent Moves, but does not rotate around the center of their parent.
     40
    3041//! The default mode of the translation-binding.
    31 #define DEFAULT_MODE ALL
     42#define DEFAULT_MODE PNODE_ALL
    3243
    3344//! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent.
     
    3950  virtual ~PNode ();
    4051
    41   void destroy ();
    42 
    4352  PNode* parent;            //!< a pointer to the parent node
    4453  tList<PNode>* children;   //!< list of the children
    4554
    46   parentingMode mode;       //!< the mode of the binding
     55
    4756
    4857  Vector getRelCoor ();
     
    6271
    6372  void addChild (PNode* pNode);
    64   void addChild (PNode* pNode, parentingMode mode);
     73  void addChild (PNode* pNode, int parentingMode);
    6574  void removeChild (PNode* pNode);
     75  void remove();
     76
     77
    6678  void setParent (PNode* parent);
    6779  void parentCoorChanged ();
    6880  void parentDirChanged ();
    69   void setMode (parentingMode mode);
     81  void setMode (int parentingMode);
     82  int getMode();
    7083
    71   virtual void update (float timeStamp);
     84  virtual void update ();
    7285  void processTick (float dt);
    73   virtual void tick (float dt);
    7486
    7587  void setName (const char* newName);
     
    7991  void debug ();
    8092
     93 private:
     94  void init(PNode* parent);
     95
     96 protected:
    8197  float timeStamp;         //!< this the timeStamp of when the abs{Coordinat, Direction} has been calculated
    8298  char* objectName;        //!< The name of the Object
     
    91107  Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
    92108
     109  int mode;                //!< the mode of the binding
     110
    93111};
    94112
    95113#endif /* _P_NODE_H */
     114 
Note: See TracChangeset for help on using the changeset viewer.