Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4765 in orxonox.OLD


Ignore:
Timestamp:
Jul 2, 2005, 2:23:41 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: addChild and setParentMode via XML-loading

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

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

    r4761 r4765  
    128128  LoadParam<PNode>(root, "parent", this, &PNode::setParent)
    129129      .describe("the Name of the Parent of this PNode");
     130
     131  LoadParam<PNode>(root, "parent-mode", this, &PNode::setParentMode)
     132      .describe("the mode to connect this node to its parent ()");
     133
     134  // cycling properties
     135  const TiXmlElement* element = root->FirstChildElement();
     136  while (element != NULL)
     137  {
     138    LoadParam<PNode>(root, "parent", this, &PNode::addChild, true)
     139        .describe("adds a new Child to the current Node.");
     140
     141    element = element->NextSiblingElement();
     142  }
    130143}
    131144
     
    289302
    290303/**
     304 * @see PNode::addChild(PNode* parent);
     305 * @param childName the name of the child to add to this PNode
     306 */
     307void PNode::addChild (const char* childName)
     308{
     309  PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
     310  if (childNode != NULL)
     311    this->addChild(childNode);
     312}
     313
     314
     315/**
    291316   \brief removes a child from the node
    292317   \param pNode the child to remove from this pNode.
     
    340365{
    341366  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
    342 
    343 
    344   printf("%p\n", parentNode);
    345   printf("%s\n", parentNode->getName());
    346 
    347367  if (parentNode != NULL)
    348368    parentNode->addChild(this);
     
    353373   \param parentMode the mode of the bind-type.
    354374*/
    355 void PNode::setParentMode (unsigned int parentMode)
     375void PNode::setParentMode (PARENT_MODE parentMode)
    356376{
    357377  this->parentMode = parentMode;
     378}
     379
     380/**
     381 * @brief sets the mode of this parent manually
     382 * @param parentMode a String representing this parentingMode
     383 */
     384void PNode::setParentMode (const char* parentingMode)
     385{
     386  if (!strcmp(parentingMode, "local-rotate"))
     387    this->setParentMode(PNODE_LOCAL_ROTATE);
     388  else  if (!strcmp(parentingMode, "rotate-movement"))
     389    this->setParentMode(PNODE_ROTATE_MOVEMENT);
     390  else  if (!strcmp(parentingMode, "movement"))
     391    this->setParentMode(PNODE_MOVEMENT);
     392  else  if (!strcmp(parentingMode, "all"))
     393    this->setParentMode(PNODE_ALL);
     394  else  if (!strcmp(parentingMode, "rotate-and-move"))
     395    this->setParentMode(PNODE_ROTATE_AND_MOVE);
    358396}
    359397
  • orxonox/trunk/src/lib/coord/p_node.h

    r4761 r4765  
    3232template<class T> class tList;
    3333
    34 // linkage modes
    35 #define PNODE_LOCAL_ROTATE       1    //!< Rotates all the children around their centers.
    36 #define PNODE_ROTATE_MOVEMENT    2    //!< Moves all the children around the center of their parent, without the rotation around their own centers.
    37 #define PNODE_MOVEMENT           4    //!< Moves all children along with the parent.
     34//! Parental linkage modes
     35typedef enum
     36{
     37  PNODE_LOCAL_ROTATE          =   1,    //!< Rotates all the children around their centers.
     38  PNODE_ROTATE_MOVEMENT       =   2,    //!< Moves all the children around the center of their parent, without the rotation around their own centers.
     39
     40  PNODE_MOVEMENT              =   4,    //!< Moves all children along with the parent.
    3841// special linkage modes
    39 #define PNODE_ALL                3    //!< Moves all children around the center of their parent, and also rotates their centers
    40 #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.
     42  PNODE_ALL                   =   3,    //!< Moves all children around the center of their parent, and also rotates their centers
     43  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.
     44
     45} PARENT_MODE;
    4146
    4247//! The default mode of the translation-binding.
     
    8489
    8590  void addChild (PNode* pNode, int parentingMode = DEFAULT_MODE);
     91  void addChild (const char* childName);
    8692  void removeChild (PNode* pNode);
    8793  void remove();
     
    9096  void setParent (const char* name);
    9197
    92   void setParentMode (unsigned int parentingMode);
     98  void setParentMode (PARENT_MODE parentMode);
     99  void setParentMode (const char* parentingMode);
    93100  /** \returns the Parenting mode of this node */
    94101  int getParentMode() const { return this->parentMode; };
  • orxonox/trunk/src/story_entities/world.cc

    r4763 r4765  
    11641164*/
    11651165void World::spawn(WorldEntity* entity, PNode* parentNode,
    1166                   Vector* relCoor, Quaternion* relDir,
    1167                   int parentingMode)
     1166                  Vector* relCoor, Quaternion* relDir)
    11681167{
    11691168  this->nullParent = NullParent::getInstance();
     
    11741173      entity->setRelCoor (*relCoor);
    11751174      entity->setRelDir (*relDir);
    1176       entity->setParentMode(parentingMode);
    11771175
    11781176      this->entities->add (entity);
  • orxonox/trunk/src/story_entities/world.h

    r4746 r4765  
    9090  void spawn (WorldEntity* entity);
    9191  void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir);
    92   void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir,
    93              int parentingMode);
     92  void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir);
    9493
    9594  const char* getPath();
Note: See TracChangeset for help on using the changeset viewer.