Changeset 6078 in orxonox.OLD for trunk/src/lib/coord/p_node.h
- Timestamp:
- Dec 13, 2005, 2:55:08 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/p_node.h
r6075 r6078 43 43 44 44 // REPARENTING 45 PNODE_REPARENT_TO_NULL PARENT = 0x0010, //!< Reparents to the NullParent, if the Parent is Removed.45 PNODE_REPARENT_TO_NULL = 0x0010, //!< Reparents to the Null, if the Parent is Removed. Meaning the Node wont have a parent anymore. 46 46 PNODE_REPARENT_TO_PARENTS_PARENT = 0x0020, //!< Reparents the Node to the parents (old) parent it the parent gets removed. 47 ///////////////////////////////////////////// // ELSE: Reparents to the NullParent. 47 48 PNODE_REPARENT_DELETE_CHILDREN = 0x0040, //!< Deletes the Children of the node when This Node is Removed. (Use with care). 48 49 /// FIXME … … 54 55 PNODE_PROHIBIT_DELETE_WITH_PARENT = 0x0200, //!< Prohibits the Node to be deleted if the Parent is. Child will be reparented according to the Repaenting-Rules 55 56 PNODE_REPARENT_CHILDREN_ON_REMOVE = 0x0400, //!< Reparents the Children of the Node if the Node gets Removed. 57 PNODE_REPARENT_ON_PARENTS_REMOVE = 0x0800, //!< The Node gets Reparented if its Parent gets removed. Child will be reparented according to the Reparenting-Rules. 56 58 57 59 // VISIBILITY/ACTIVITY … … 65 67 //! The default mode of the translation-binding. 66 68 #define PNODE_PARENT_MODE_DEFAULT PNODE_ALL | \ 67 PNODE_REPARENT_CHILDREN_ON_REMOVE | \68 69 PNODE_REPARENT_KEEP_POSITION 69 70 … … 72 73 class PNode : virtual public BaseObject { 73 74 public: 74 PNode (PNode* parent = PNode::getNullParent() );75 PNode (PNode* parent = PNode::getNullParent(), long nodeFlags = PNODE_PARENT_MODE_DEFAULT); 75 76 virtual ~PNode (); 76 77 77 78 void loadParams(const TiXmlElement* root); 78 79 80 // ACTIVATION // 79 81 inline void activateNode() { this->bActive = true; }; 80 82 inline void deactivateNode() { this->bActive = false; }; 81 83 inline bool getNodeActiveState() { return this->bActive; }; 82 84 85 // POSITION // 83 86 void setRelCoor (const Vector& relCoord); 84 87 void setRelCoor (float x, float y, float z); … … 98 101 void shiftCoor (float x, float y, float z) { this->shiftCoor(Vector(x, y, z)); }; 99 102 103 // SPEED // 104 /** @returns the Speed of the Node */ 105 inline float getSpeed() const { return this->velocity.len(); }; 106 /** @returns the Velocity of the Node */ 107 inline const Vector& getVelocity() const { return this->velocity; }; 108 109 110 // ROTATION // 100 111 void setRelDir (const Quaternion& relDir); 101 112 void setRelDir (float x, float y, float z); … … 124 135 inline Vector getAbsDirZ() const { return this->absDirection.apply(Vector(0,0,1)); }; 125 136 126 /** @returns the Speed of the Node */ 127 inline float getSpeed() const { return this->velocity.len(); }; 128 /** @returns the Velocity of the Node */ 129 inline const Vector& getVelocity() const { return this->velocity; }; 130 131 137 138 // PARENTING // 132 139 void addChild (PNode* child); 133 140 void addChild (const char* childName); … … 146 153 void setParentSoft(const char* parentName, float bias = 1.0); 147 154 155 // PARENTING_MODE AND OTHER FLAGS // 148 156 void setParentMode (PARENT_MODE parentMode); 149 157 void setParentMode (const char* parentingMode); … … 151 159 int getParentMode() const { return 0x000f & this->parentMode; }; 152 160 153 void addNodeModeFlags(unsigned short nodeFlags); 154 void removeNodeModeFlags(unsigned short nodeFlags); 155 161 void addNodeFlags(unsigned short nodeFlags); 162 void removeNodeFlags(unsigned short nodeFlags); 163 164 // NULL_PARENT // 156 165 /** @returns the NullParent, the (main) ROOT of the PNode Tree. If it does not yet exist, it will be created. */ 157 static PNode* getNullParent() { return (PNode::nullParent != NULL || (PNode::nullParent = new PNode(NULL)) != NULL)? PNode::nullParent : NULL; }; 158 166 static PNode* getNullParent() { return (PNode::nullParent != NULL)? PNode::nullParent : PNode::createNullParent(); }; 167 168 // UPDATING // 159 169 void updateNode (float dt); 160 170 171 // DEBUG // 161 172 void countChildNodes(int& nodes) const; 162 173 void debugNode (unsigned int depth = 1, unsigned int level = 0) const; 163 174 void debugDraw(unsigned int depth = 1, float size = 1.0, const Vector& color = Vector(1, 0, 0), unsigned int level = 0) const; 164 175 165 166 // helper functions // 176 // HELPER_FUNCTIONS // 167 177 static const char* parentingModeToChar(int parentingMode); 168 178 static PARENT_MODE charToParentingMode(const char* parentingMode); … … 170 180 171 181 private: 172 void init();173 182 /** tells the child that the parent's Coordinate has changed */ 174 183 inline void parentCoorChanged () { this->bRelCoorChanged = true; } … … 178 187 inline Vector getLastAbsCoor() { return this->lastAbsCoordinate; } 179 188 189 static PNode* createNullParent(); 180 190 void reparent(); 181 191 bool checkIntegrity(const PNode* checkParent) const; 192 void eraseChild(PNode* child); 182 193 183 194 private:
Note: See TracChangeset
for help on using the changeset viewer.