Go to the documentation of this file.00001
00002
00003 #ifndef _NODE_H_
00004 #define _NODE_H_
00005
00006 #include <EngineConfig.h>
00007 #include <core/Types.h>
00008 #include <core/Vector3d.h>
00009 #include <core/Quaternion.h>
00010 #include <core/Matrix4.h>
00011 #include <engine/Object.h>
00012 #include <scene/NodeDefines.h>
00013
00014 #include <map>
00015
00016 namespace scene
00017 {
00018
00024 class ENGINE_PUBLIC_EXPORT Node: public engine::Object
00025 {
00026
00027
00028 public:
00029
00030 Node();
00031 Node(const std::string& name);
00032
00033 virtual ~Node();
00034
00036 const NodeType& getNodeType() const;
00037
00039 virtual void setPosition(f32 x, f32 y, f32 z);
00040 virtual void setPosition(const core::vector3d& pos);
00041
00043 const core::vector3d& getPosition();
00044
00046 virtual void setOrientation(const core::quaternion& q);
00047
00049 const core::quaternion& getOrientation();
00050
00052 void setScale(f32 x, f32 y, f32 z);
00053 void setScale(const core::vector3d& scale);
00054
00056 const core::vector3d& getScale();
00057
00059 const core::vector3d getDirection();
00060
00062 const core::vector3d getUp();
00063
00065 const core::vector3d getRight();
00066
00068 void setInheritOrientation(bool inherit);
00070 bool getInheritOrientation();
00071
00073 void setInheritScale(bool inherit);
00075 bool getInheritScale();
00076
00077
00078 virtual void scale(const core::vector3d& scale);
00079 virtual void translate(const core::vector3d& d, TransformSpace relativeTo = TS_LOCAL);
00080 virtual void rotate(const core::quaternion& q, TransformSpace relativeTo = TS_LOCAL);
00081
00082 virtual void rotate(const f32& degrees, const core::vector3d& axis, TransformSpace relativeTo = TS_LOCAL);
00083 virtual void rotateX(f32 degrees, TransformSpace relativeTo = TS_LOCAL);
00084 virtual void rotateY(f32 degrees, TransformSpace relativeTo = TS_LOCAL);
00085 virtual void rotateZ(f32 degrees, TransformSpace relativeTo = TS_LOCAL);
00086
00088 void setParent(Node* parent);
00089
00091 Node* getParent();
00092
00094 Node* createChild(const core::vector3d& pos = core::vector3d::ORIGIN_3D, const core::quaternion& rot = core::quaternion::IDENTITY, const core::vector3d& scale = core::vector3d::UNIT_SCALE);
00095
00097 void addChild(Node* child);
00098
00100 Node* getChild(const u32& id) const;
00101
00103 u16 getNumberOfChildren();
00104
00105 const std::map<u32, Node*>& getChildren();
00106
00107
00108
00109 void removeChild(Node* child);
00110 Node* removeChild(const u32& id);
00111
00113
00114 void removeAllChildren();
00115
00117 const core::vector3d& getAbsolutePosition();
00118
00120 const core::quaternion& getAbsoluteOrientation();
00121
00123 const core::vector3d& getAbsoluteScale();
00124
00126 const core::vector3d getAbsoluteDirection();
00127
00129 const core::vector3d getAbsoluteUp();
00130
00132 const core::vector3d getAbsoluteRight();
00133
00134 protected:
00135
00137 static u32 msNextGeneratedNodeIndex;
00138
00139 void initProperties();
00140
00141 NodeType mNodeType;
00142
00143 Node* mParent;
00144
00146 bool mModifiedAbsoluteTransform;
00147
00148 virtual void updateTransformImpl();
00149
00150 virtual void updateImpl(f32 elapsedTime);
00151
00153 core::vector3d mPosition;
00154
00156 core::quaternion mOrientation;
00157
00159 core::vector3d mScale;
00160
00164 core::quaternion mAbsoluteOrientation;
00165
00167 core::vector3d mAbsolutePosition;
00168
00170 core::vector3d mAbsoluteScale;
00171
00173 bool mInheritOrientation;
00174
00176 bool mInheritScale;
00177
00179 std::map<u32, Node*> mChildren;
00180 };
00181
00183 class ENGINE_PRIVATE_EXPORT RootNode: public Node
00184 {
00185 public:
00186
00187 RootNode();
00188 ~RootNode();
00189 };
00190
00192 class ENGINE_PRIVATE_EXPORT GroupNode: public Node
00193 {
00194 public:
00195
00196 GroupNode();
00197 GroupNode(const std::string& name);
00198
00199 ~GroupNode();
00200
00202 void addNode(Node* node);
00203
00205 Node* getNode(const u32& id) const;
00206
00208 u16 getNumberOfNodes();
00209
00210
00211
00212 void removeNode(Node* node);
00213 Node* removeNode(const u32& id);
00214
00216 void removeAllNodes();
00217
00218 protected:
00219
00221 static u32 msNextGeneratedGroupNodeIndex;
00222 };
00223
00224 }
00225
00226 #endif