= !ParentNode (PNode) = [[ArchivePage]] The !ParentNode is one element of a Tree spanning all the 3D-elements that have a position and rotation inside of the world. source:orxonox.OLD/trunk/src/lib/coord/p_node.h#HEAD Dependencies: * [wiki:BaseObject BaseObject] == Description == !ParentNode has a ... * __Parent__ (another PNode it is connected to) * the '''topmost''' is '''!NullParent''' * if the '''Parent''' is '''Null''', the Node is __free__ (or the !NullParent) * list of __Children__. * each child is again a !ParentNode * each child will be updated acordingly if the Parent is moved/rotated. * __Position__ (absolute in the world and relative to its parent) * __Rotation__ (absolute in the world and relative to its parent) !ParentNode is not able to ... * draw itself (this can be done for example with extension [wiki:WorldEntity WorldEntity]) * tick itself (this can be done for example with extension [wiki:WorldEntity WorldEntity]) == Usage == Whenever you create a new Entity in the World, that is a PNode (ex. !WorldEntity Player...), it will automatically be added to the PNode tree. By default each PNode is added to the !NullParent as a child. Now, what is this good for? The cool trick about PNodes is, that whenever you update a PNode in positional or rotational settings, all its Children will be updated as well, as they are linkey to their parent with relative coordinates/rotations. So as the Parent moves the Children will move too. __Functions__ {{{ #!cpp void setRelCoor (const Vector& relCoord); void setAbsCoor (const Vector& absCoord); void setRelDir (const Quaternion& relDir); void setAbsDir (const Quaternion& absDir); void addChild (PNode* child); void setParent (PNode* parent); void setParentMode (PARENT_MODE parentMode); }}} These are the main functions of !ParentNode, if you understand them you understand PNode :)[[br]] Most of the functions speak for themselves, but '''setParentMode''' maybe needs some explanation: There are __different modes__ to connect Children to their Parents: * PNODE_LOCAL_ROTATE //!< Rotates all the children around their centers. * PNODE_ROTATE_MOVEMENT //!< Moves all the children around the center of their parent, without the rotation around their own centers. * PNODE_MOVEMENT //!< Moves all children along with the parent. * // combined linkage modes * PNODE_ALL //!< Moves all children around the center of their parent, and also rotates their centers * PNODE_ROTATE_AND_MOVE //!< Rotates all children around their axis, and moves them as the Parent Moves, but does not rotate around the center of their parent. __DEBUG__ Functions, that are really usefull when debug !ParentNode's, they can put out nice output or paint the nodes of the selected !ParentNode, and of all its Children and children's children if you'd like. {{{ #!cpp void debug (unsigned int depth = 1, unsigned int level = 0) const; void debugDraw(unsigned int depth = 1, float size = 1.0, const Vector& color = Vector(1, 0, 0), unsigned int level = 0) const; }}} == Advanced Topics == The main updating function that is responsible for the whole parent-child-update process is handled in the following function: {{{ #!cpp void update (float dt); }}} This is pure matemathics, with many cases, that you just have understand, if you are developing on the PNode-internal level.