Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of ~archive/ParentNode


Ignore:
Timestamp:
Nov 27, 2007, 11:15:02 PM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • ~archive/ParentNode

    v1 v1  
     1= ParentNode (PNode) =
     2The ParentNode is one element of a Tree spanning all the 3D-elements that have a position and rotation inside of the world.
     3
     4source:/trunk/src/lib/coord/p_node.h#HEAD
     5Dependencies:
     6  * BaseObject
     7
     8== Description ==
     9ParentNode has a ...
     10  * __Parent__ (another PNode it is connected to)
     11   * the '''topmost''' is '''NullParent'''
     12   * if the '''Parent''' is '''Null''', the Node is __free__ (or the NullParent)
     13  * list of __Children__.
     14   * each child is again a ParentNode
     15   * each child will be updated acordingly if the Parent is moved/rotated.
     16  * __Position__ (absolute in the world and relative to its parent)
     17  * __Rotation__ (absolute in the world and relative to its parent)
     18
     19ParentNode is not able to ...
     20  * draw itself (this can be done for example with extension WorldEntity)
     21  * tick itself (this can be done for example with extension WorldEntity)
     22
     23== Usage ==
     24Whenever you create a new Entity in the World, that is a PNode (ex. WorldEntity Player...), it will automatically be added to the PNode tree.
     25By default each PNode is added to the NullParent as a child.
     26
     27Now, what is this good for?
     28The 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.
     29
     30__Functions__
     31{{{
     32#!cpp
     33  void setRelCoor (const Vector& relCoord);
     34  void setAbsCoor (const Vector& absCoord);
     35
     36  void setRelDir (const Quaternion& relDir);
     37  void setAbsDir (const Quaternion& absDir);
     38
     39  void addChild (PNode* child);
     40  void setParent (PNode* parent);
     41  void setParentMode (PARENT_MODE parentMode);
     42}}}
     43These are the main functions of ParentNode, if you understand them you understand PNode :)[[br]]
     44Most of the functions speak for themselves, but '''setParentMode''' maybe needs some explanation:
     45There are __different modes__ to connect Children to their Parents:
     46  * PNODE_LOCAL_ROTATE    //!< Rotates all the children around their centers.
     47  * PNODE_ROTATE_MOVEMENT //!< Moves all the children around the center of their parent, without the rotation around their own centers.
     48  * PNODE_MOVEMENT        //!< Moves all children along with the parent.
     49  * // combined linkage modes
     50  * PNODE_ALL             //!< Moves all children around the center of their parent, and also rotates their centers
     51  * 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.
     52
     53
     54
     55__DEBUG__
     56Functions, 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.
     57{{{
     58#!cpp
     59  void debug (unsigned int depth = 1, unsigned int level = 0) const;
     60  void debugDraw(unsigned int depth = 1, float size = 1.0, const Vector& color = Vector(1, 0, 0), unsigned int level = 0) const;
     61}}}
     62
     63== Advanced Topics ==
     64The main updating function that is responsible for the whole parent-child-update process is handled in the following function:
     65{{{
     66#!cpp
     67  void update (float dt);
     68}}}
     69This is pure matemathics, with many cases, that you just have understand, if you are developing on the PNode-internal level.