Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Mar 15, 2005, 7:27:44 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: patched the pNode, now there exists the ability for advanced linkage-modes

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

Legend:

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

    r3554 r3565  
    4040  printf("NullParent::NullParent() - making new NullParent, there can only be one..\n");
    4141  this->parent = this;
    42   this->mode = ALL;
     42  this->mode = PNODE_ALL;
    4343  this->setName("NullParent");
    4444}
     
    4949  singletonRef = this;
    5050  this->parent = this;
    51   this->mode = ALL;
     51  this->mode = PNODE_ALL;
    5252  this->absCoordinate = *absCoordinate;
    5353  this->setName("NullParent");
  • orxonox/trunk/src/lib/coord/p_node.cc

    r3560 r3565  
    301301   use this to add a child to this node.
    302302*/
    303 void PNode::addChild (PNode* pNode, parentingMode mode)
     303void PNode::addChild (PNode* pNode, int parentingMode)
    304304{
    305305  if( pNode->parent != NULL )
     
    308308      pNode->parent->children->remove(pNode);
    309309    }
    310   pNode->mode = mode;
     310  pNode->mode = parentingMode;
    311311  pNode->parent = this;
    312312  this->children->add(pNode);
     
    360360   \param mode the mode of the bind-type.
    361361*/
    362 void PNode::setMode (parentingMode mode)
    363 {
    364   this->mode = mode;
     362void PNode::setMode (int parentingMode)
     363{
     364  this->mode = parentingMode;
    365365}
    366366
     
    370370   \return the mode of the bind-type.
    371371*/
    372 parentingMode PNode::getMode()
     372int PNode::getMode()
    373373{
    374374  return this->mode;
     
    411411  PRINTF(2)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
    412412  // printf("%s", this->objectName);
    413 
    414       if( this->mode == MOVEMENT )
     413  printf("%d:", this->mode);
     414  if(this->mode & PNODE_MOVEMENT )
     415    {
     416      printf("4\n");
     417      if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    415418        {
    416           if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     419          /* if you have set the absolute coordinates this overrides all other changes */
     420          this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
     421        }
     422      else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     423        {
     424          /*this is bad style... must be deleted later - just for testing*/
     425          if( this->parent == NULL)
    417426            {
    418               /* if you have set the absolute coordinates this overrides all other changes */
    419               this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
     427              this->absCoordinate = this->relCoordinate;
    420428            }
    421           else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    422             {
    423               /*this is bad style... must be deleted later - just for testing*/
    424               if( this->parent == NULL)
    425                 {
    426                 this->absCoordinate = this->relCoordinate;
    427                 }
    428               else
    429                 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;             /* update the current absCoordinate */
    430             }
     429          else
     430            this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;         /* update the current absCoordinate */
    431431        }
    432      
    433       if( this->mode == ROTATION || this->mode == ALL)
     432    }
     433 
     434  if( this->mode & PNODE_LOCAL_ROTATE)
     435    {
     436      printf("1\n");
     437      if( this->bAbsDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    434438        {
    435           if( this->bAbsDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    436             {
    437               /* if you have set the absolute coordinates this overrides all other changes */
    438               this->relDirection = this->absDirection - parent->getAbsDir();
    439             }
    440           else if( this->bRelDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    441             {
    442               /* update the current absDirection - remember * means rotation around sth.*/
    443               this->absDirection = parent->getAbsDir() * this->relDirection;
    444             }
     439          /* if you have set the absolute coordinates this overrides all other changes */
     440          this->relDirection = this->absDirection - parent->getAbsDir();
    445441        }
    446      
    447       if( this->mode == ALL)
     442      else if( this->bRelDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    448443        {
    449           if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    450             {
    451               /* if you have set the absolute coordinates this overrides all other changes */
    452               this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
    453             }
    454           else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    455             {
    456               /*this is bad style... must be deleted later - just for testing*/
    457               if( this->parent == NULL)
    458                 this->absCoordinate = this->relCoordinate;
    459               else
    460                 this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);          /* update the current absCoordinate */
    461             }
     444          /* update the current absDirection - remember * means rotation around sth.*/
     445          this->absDirection = parent->getAbsDir() * this->relDirection;
    462446        }
    463 
    464 
     447    }
     448 
     449  if( this->mode & PNODE_ROTATE_MOVEMENT)
     450    {
     451      printf("2\n");
     452      if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     453        {
     454          /* if you have set the absolute coordinates this overrides all other changes */
     455          this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
     456        }
     457      else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     458        {
     459          /*this is bad style... must be deleted later - just for testing*/
     460          if( this->parent == NULL)
     461            this->absCoordinate = this->relCoordinate;
     462          else
     463            this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);              /* update the current absCoordinate */
     464        }
     465    }
     466 
     467 
    465468  PNode* pn = this->children->enumerate();
    466469  while( pn != NULL)
  • orxonox/trunk/src/lib/coord/p_node.h

    r3554 r3565  
    3030
    3131//! enumeration for the different translation-binding-types
    32 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
    3341//! The default mode of the translation-binding.
    34 #define DEFAULT_MODE ALL
     42#define DEFAULT_MODE PNODE_ALL
    3543
    3644//! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent.
     
    6371
    6472  void addChild (PNode* pNode);
    65   void addChild (PNode* pNode, parentingMode mode);
     73  void addChild (PNode* pNode, int parentingMode);
    6674  void removeChild (PNode* pNode);
    6775  void remove();
     
    7179  void parentCoorChanged ();
    7280  void parentDirChanged ();
    73   void setMode (parentingMode mode);
    74   parentingMode getMode();
     81  void setMode (int parentingMode);
     82  int getMode();
    7583
    7684  virtual void update ();
     
    99107  Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
    100108
    101   parentingMode mode;       //!< the mode of the binding
     109  int mode;                //!< the mode of the binding
    102110
    103111};
Note: See TracChangeset for help on using the changeset viewer.