diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/include/ISceneNode.h | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2 SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz |
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/include/ISceneNode.h | 1716 |
1 files changed, 858 insertions, 858 deletions
diff --git a/libraries/irrlicht-1.8/include/ISceneNode.h b/libraries/irrlicht-1.8/include/ISceneNode.h index ecaad4a..63d74f0 100644 --- a/libraries/irrlicht-1.8/include/ISceneNode.h +++ b/libraries/irrlicht-1.8/include/ISceneNode.h | |||
@@ -1,858 +1,858 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #ifndef __I_SCENE_NODE_H_INCLUDED__ | 5 | #ifndef __I_SCENE_NODE_H_INCLUDED__ |
6 | #define __I_SCENE_NODE_H_INCLUDED__ | 6 | #define __I_SCENE_NODE_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IAttributeExchangingObject.h" | 8 | #include "IAttributeExchangingObject.h" |
9 | #include "ESceneNodeTypes.h" | 9 | #include "ESceneNodeTypes.h" |
10 | #include "ECullingTypes.h" | 10 | #include "ECullingTypes.h" |
11 | #include "EDebugSceneTypes.h" | 11 | #include "EDebugSceneTypes.h" |
12 | #include "ISceneNodeAnimator.h" | 12 | #include "ISceneNodeAnimator.h" |
13 | #include "ITriangleSelector.h" | 13 | #include "ITriangleSelector.h" |
14 | #include "SMaterial.h" | 14 | #include "SMaterial.h" |
15 | #include "irrString.h" | 15 | #include "irrString.h" |
16 | #include "aabbox3d.h" | 16 | #include "aabbox3d.h" |
17 | #include "matrix4.h" | 17 | #include "matrix4.h" |
18 | #include "irrList.h" | 18 | #include "irrList.h" |
19 | #include "IAttributes.h" | 19 | #include "IAttributes.h" |
20 | 20 | ||
21 | namespace irr | 21 | namespace irr |
22 | { | 22 | { |
23 | namespace scene | 23 | namespace scene |
24 | { | 24 | { |
25 | class ISceneManager; | 25 | class ISceneManager; |
26 | 26 | ||
27 | //! Typedef for list of scene nodes | 27 | //! Typedef for list of scene nodes |
28 | typedef core::list<ISceneNode*> ISceneNodeList; | 28 | typedef core::list<ISceneNode*> ISceneNodeList; |
29 | //! Typedef for list of scene node animators | 29 | //! Typedef for list of scene node animators |
30 | typedef core::list<ISceneNodeAnimator*> ISceneNodeAnimatorList; | 30 | typedef core::list<ISceneNodeAnimator*> ISceneNodeAnimatorList; |
31 | 31 | ||
32 | //! Scene node interface. | 32 | //! Scene node interface. |
33 | /** A scene node is a node in the hierarchical scene graph. Every scene | 33 | /** A scene node is a node in the hierarchical scene graph. Every scene |
34 | node may have children, which are also scene nodes. Children move | 34 | node may have children, which are also scene nodes. Children move |
35 | relative to their parent's position. If the parent of a node is not | 35 | relative to their parent's position. If the parent of a node is not |
36 | visible, its children won't be visible either. In this way, it is for | 36 | visible, its children won't be visible either. In this way, it is for |
37 | example easily possible to attach a light to a moving car, or to place | 37 | example easily possible to attach a light to a moving car, or to place |
38 | a walking character on a moving platform on a moving ship. | 38 | a walking character on a moving platform on a moving ship. |
39 | */ | 39 | */ |
40 | class ISceneNode : virtual public io::IAttributeExchangingObject | 40 | class ISceneNode : virtual public io::IAttributeExchangingObject |
41 | { | 41 | { |
42 | public: | 42 | public: |
43 | 43 | ||
44 | //! Constructor | 44 | //! Constructor |
45 | ISceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id=-1, | 45 | ISceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id=-1, |
46 | const core::vector3df& position = core::vector3df(0,0,0), | 46 | const core::vector3df& position = core::vector3df(0,0,0), |
47 | const core::vector3df& rotation = core::vector3df(0,0,0), | 47 | const core::vector3df& rotation = core::vector3df(0,0,0), |
48 | const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) | 48 | const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) |
49 | : RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale), | 49 | : RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale), |
50 | Parent(0), SceneManager(mgr), TriangleSelector(0), ID(id), | 50 | Parent(0), SceneManager(mgr), TriangleSelector(0), ID(id), |
51 | AutomaticCullingState(EAC_BOX), DebugDataVisible(EDS_OFF), | 51 | AutomaticCullingState(EAC_BOX), DebugDataVisible(EDS_OFF), |
52 | IsVisible(true), IsDebugObject(false) | 52 | IsVisible(true), IsDebugObject(false) |
53 | { | 53 | { |
54 | if (parent) | 54 | if (parent) |
55 | parent->addChild(this); | 55 | parent->addChild(this); |
56 | 56 | ||
57 | updateAbsolutePosition(); | 57 | updateAbsolutePosition(); |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | //! Destructor | 61 | //! Destructor |
62 | virtual ~ISceneNode() | 62 | virtual ~ISceneNode() |
63 | { | 63 | { |
64 | // delete all children | 64 | // delete all children |
65 | removeAll(); | 65 | removeAll(); |
66 | 66 | ||
67 | // delete all animators | 67 | // delete all animators |
68 | ISceneNodeAnimatorList::Iterator ait = Animators.begin(); | 68 | ISceneNodeAnimatorList::Iterator ait = Animators.begin(); |
69 | for (; ait != Animators.end(); ++ait) | 69 | for (; ait != Animators.end(); ++ait) |
70 | (*ait)->drop(); | 70 | (*ait)->drop(); |
71 | 71 | ||
72 | if (TriangleSelector) | 72 | if (TriangleSelector) |
73 | TriangleSelector->drop(); | 73 | TriangleSelector->drop(); |
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
77 | //! This method is called just before the rendering process of the whole scene. | 77 | //! This method is called just before the rendering process of the whole scene. |
78 | /** Nodes may register themselves in the render pipeline during this call, | 78 | /** Nodes may register themselves in the render pipeline during this call, |
79 | precalculate the geometry which should be renderered, and prevent their | 79 | precalculate the geometry which should be renderered, and prevent their |
80 | children from being able to register themselves if they are clipped by simply | 80 | children from being able to register themselves if they are clipped by simply |
81 | not calling their OnRegisterSceneNode method. | 81 | not calling their OnRegisterSceneNode method. |
82 | If you are implementing your own scene node, you should overwrite this method | 82 | If you are implementing your own scene node, you should overwrite this method |
83 | with an implementation code looking like this: | 83 | with an implementation code looking like this: |
84 | \code | 84 | \code |
85 | if (IsVisible) | 85 | if (IsVisible) |
86 | SceneManager->registerNodeForRendering(this); | 86 | SceneManager->registerNodeForRendering(this); |
87 | 87 | ||
88 | ISceneNode::OnRegisterSceneNode(); | 88 | ISceneNode::OnRegisterSceneNode(); |
89 | \endcode | 89 | \endcode |
90 | */ | 90 | */ |
91 | virtual void OnRegisterSceneNode() | 91 | virtual void OnRegisterSceneNode() |
92 | { | 92 | { |
93 | if (IsVisible) | 93 | if (IsVisible) |
94 | { | 94 | { |
95 | ISceneNodeList::Iterator it = Children.begin(); | 95 | ISceneNodeList::Iterator it = Children.begin(); |
96 | for (; it != Children.end(); ++it) | 96 | for (; it != Children.end(); ++it) |
97 | (*it)->OnRegisterSceneNode(); | 97 | (*it)->OnRegisterSceneNode(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | //! OnAnimate() is called just before rendering the whole scene. | 102 | //! OnAnimate() is called just before rendering the whole scene. |
103 | /** Nodes may calculate or store animations here, and may do other useful things, | 103 | /** Nodes may calculate or store animations here, and may do other useful things, |
104 | depending on what they are. Also, OnAnimate() should be called for all | 104 | depending on what they are. Also, OnAnimate() should be called for all |
105 | child scene nodes here. This method will be called once per frame, independent | 105 | child scene nodes here. This method will be called once per frame, independent |
106 | of whether the scene node is visible or not. | 106 | of whether the scene node is visible or not. |
107 | \param timeMs Current time in milliseconds. */ | 107 | \param timeMs Current time in milliseconds. */ |
108 | virtual void OnAnimate(u32 timeMs) | 108 | virtual void OnAnimate(u32 timeMs) |
109 | { | 109 | { |
110 | if (IsVisible) | 110 | if (IsVisible) |
111 | { | 111 | { |
112 | // animate this node with all animators | 112 | // animate this node with all animators |
113 | 113 | ||
114 | ISceneNodeAnimatorList::Iterator ait = Animators.begin(); | 114 | ISceneNodeAnimatorList::Iterator ait = Animators.begin(); |
115 | while (ait != Animators.end()) | 115 | while (ait != Animators.end()) |
116 | { | 116 | { |
117 | // continue to the next node before calling animateNode() | 117 | // continue to the next node before calling animateNode() |
118 | // so that the animator may remove itself from the scene | 118 | // so that the animator may remove itself from the scene |
119 | // node without the iterator becoming invalid | 119 | // node without the iterator becoming invalid |
120 | ISceneNodeAnimator* anim = *ait; | 120 | ISceneNodeAnimator* anim = *ait; |
121 | ++ait; | 121 | ++ait; |
122 | anim->animateNode(this, timeMs); | 122 | anim->animateNode(this, timeMs); |
123 | } | 123 | } |
124 | 124 | ||
125 | // update absolute position | 125 | // update absolute position |
126 | updateAbsolutePosition(); | 126 | updateAbsolutePosition(); |
127 | 127 | ||
128 | // perform the post render process on all children | 128 | // perform the post render process on all children |
129 | 129 | ||
130 | ISceneNodeList::Iterator it = Children.begin(); | 130 | ISceneNodeList::Iterator it = Children.begin(); |
131 | for (; it != Children.end(); ++it) | 131 | for (; it != Children.end(); ++it) |
132 | (*it)->OnAnimate(timeMs); | 132 | (*it)->OnAnimate(timeMs); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | //! Renders the node. | 137 | //! Renders the node. |
138 | virtual void render() = 0; | 138 | virtual void render() = 0; |
139 | 139 | ||
140 | 140 | ||
141 | //! Returns the name of the node. | 141 | //! Returns the name of the node. |
142 | /** \return Name as character string. */ | 142 | /** \return Name as character string. */ |
143 | virtual const c8* getName() const | 143 | virtual const c8* getName() const |
144 | { | 144 | { |
145 | return Name.c_str(); | 145 | return Name.c_str(); |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | //! Sets the name of the node. | 149 | //! Sets the name of the node. |
150 | /** \param name New name of the scene node. */ | 150 | /** \param name New name of the scene node. */ |
151 | virtual void setName(const c8* name) | 151 | virtual void setName(const c8* name) |
152 | { | 152 | { |
153 | Name = name; | 153 | Name = name; |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | //! Sets the name of the node. | 157 | //! Sets the name of the node. |
158 | /** \param name New name of the scene node. */ | 158 | /** \param name New name of the scene node. */ |
159 | virtual void setName(const core::stringc& name) | 159 | virtual void setName(const core::stringc& name) |
160 | { | 160 | { |
161 | Name = name; | 161 | Name = name; |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | //! Get the axis aligned, not transformed bounding box of this node. | 165 | //! Get the axis aligned, not transformed bounding box of this node. |
166 | /** This means that if this node is an animated 3d character, | 166 | /** This means that if this node is an animated 3d character, |
167 | moving in a room, the bounding box will always be around the | 167 | moving in a room, the bounding box will always be around the |
168 | origin. To get the box in real world coordinates, just | 168 | origin. To get the box in real world coordinates, just |
169 | transform it with the matrix you receive with | 169 | transform it with the matrix you receive with |
170 | getAbsoluteTransformation() or simply use | 170 | getAbsoluteTransformation() or simply use |
171 | getTransformedBoundingBox(), which does the same. | 171 | getTransformedBoundingBox(), which does the same. |
172 | \return The non-transformed bounding box. */ | 172 | \return The non-transformed bounding box. */ |
173 | virtual const core::aabbox3d<f32>& getBoundingBox() const = 0; | 173 | virtual const core::aabbox3d<f32>& getBoundingBox() const = 0; |
174 | 174 | ||
175 | 175 | ||
176 | //! Get the axis aligned, transformed and animated absolute bounding box of this node. | 176 | //! Get the axis aligned, transformed and animated absolute bounding box of this node. |
177 | /** \return The transformed bounding box. */ | 177 | /** \return The transformed bounding box. */ |
178 | virtual const core::aabbox3d<f32> getTransformedBoundingBox() const | 178 | virtual const core::aabbox3d<f32> getTransformedBoundingBox() const |
179 | { | 179 | { |
180 | core::aabbox3d<f32> box = getBoundingBox(); | 180 | core::aabbox3d<f32> box = getBoundingBox(); |
181 | AbsoluteTransformation.transformBoxEx(box); | 181 | AbsoluteTransformation.transformBoxEx(box); |
182 | return box; | 182 | return box; |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
186 | //! Get the absolute transformation of the node. Is recalculated every OnAnimate()-call. | 186 | //! Get the absolute transformation of the node. Is recalculated every OnAnimate()-call. |
187 | /** NOTE: For speed reasons the absolute transformation is not | 187 | /** NOTE: For speed reasons the absolute transformation is not |
188 | automatically recalculated on each change of the relative | 188 | automatically recalculated on each change of the relative |
189 | transformation or by a transformation change of an parent. Instead the | 189 | transformation or by a transformation change of an parent. Instead the |
190 | update usually happens once per frame in OnAnimate. You can enforce | 190 | update usually happens once per frame in OnAnimate. You can enforce |
191 | an update with updateAbsolutePosition(). | 191 | an update with updateAbsolutePosition(). |
192 | \return The absolute transformation matrix. */ | 192 | \return The absolute transformation matrix. */ |
193 | virtual const core::matrix4& getAbsoluteTransformation() const | 193 | virtual const core::matrix4& getAbsoluteTransformation() const |
194 | { | 194 | { |
195 | return AbsoluteTransformation; | 195 | return AbsoluteTransformation; |
196 | } | 196 | } |
197 | 197 | ||
198 | 198 | ||
199 | //! Returns the relative transformation of the scene node. | 199 | //! Returns the relative transformation of the scene node. |
200 | /** The relative transformation is stored internally as 3 | 200 | /** The relative transformation is stored internally as 3 |
201 | vectors: translation, rotation and scale. To get the relative | 201 | vectors: translation, rotation and scale. To get the relative |
202 | transformation matrix, it is calculated from these values. | 202 | transformation matrix, it is calculated from these values. |
203 | \return The relative transformation matrix. */ | 203 | \return The relative transformation matrix. */ |
204 | virtual core::matrix4 getRelativeTransformation() const | 204 | virtual core::matrix4 getRelativeTransformation() const |
205 | { | 205 | { |
206 | core::matrix4 mat; | 206 | core::matrix4 mat; |
207 | mat.setRotationDegrees(RelativeRotation); | 207 | mat.setRotationDegrees(RelativeRotation); |
208 | mat.setTranslation(RelativeTranslation); | 208 | mat.setTranslation(RelativeTranslation); |
209 | 209 | ||
210 | if (RelativeScale != core::vector3df(1.f,1.f,1.f)) | 210 | if (RelativeScale != core::vector3df(1.f,1.f,1.f)) |
211 | { | 211 | { |
212 | core::matrix4 smat; | 212 | core::matrix4 smat; |
213 | smat.setScale(RelativeScale); | 213 | smat.setScale(RelativeScale); |
214 | mat *= smat; | 214 | mat *= smat; |
215 | } | 215 | } |
216 | 216 | ||
217 | return mat; | 217 | return mat; |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | //! Returns whether the node should be visible (if all of its parents are visible). | 221 | //! Returns whether the node should be visible (if all of its parents are visible). |
222 | /** This is only an option set by the user, but has nothing to | 222 | /** This is only an option set by the user, but has nothing to |
223 | do with geometry culling | 223 | do with geometry culling |
224 | \return The requested visibility of the node, true means | 224 | \return The requested visibility of the node, true means |
225 | visible (if all parents are also visible). */ | 225 | visible (if all parents are also visible). */ |
226 | virtual bool isVisible() const | 226 | virtual bool isVisible() const |
227 | { | 227 | { |
228 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 228 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
229 | return IsVisible; | 229 | return IsVisible; |
230 | } | 230 | } |
231 | 231 | ||
232 | //! Check whether the node is truly visible, taking into accounts its parents' visibility | 232 | //! Check whether the node is truly visible, taking into accounts its parents' visibility |
233 | /** \return true if the node and all its parents are visible, | 233 | /** \return true if the node and all its parents are visible, |
234 | false if this or any parent node is invisible. */ | 234 | false if this or any parent node is invisible. */ |
235 | virtual bool isTrulyVisible() const | 235 | virtual bool isTrulyVisible() const |
236 | { | 236 | { |
237 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 237 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
238 | if(!IsVisible) | 238 | if(!IsVisible) |
239 | return false; | 239 | return false; |
240 | 240 | ||
241 | if(!Parent) | 241 | if(!Parent) |
242 | return true; | 242 | return true; |
243 | 243 | ||
244 | return Parent->isTrulyVisible(); | 244 | return Parent->isTrulyVisible(); |
245 | } | 245 | } |
246 | 246 | ||
247 | //! Sets if the node should be visible or not. | 247 | //! Sets if the node should be visible or not. |
248 | /** All children of this node won't be visible either, when set | 248 | /** All children of this node won't be visible either, when set |
249 | to false. Invisible nodes are not valid candidates for selection by | 249 | to false. Invisible nodes are not valid candidates for selection by |
250 | collision manager bounding box methods. | 250 | collision manager bounding box methods. |
251 | \param isVisible If the node shall be visible. */ | 251 | \param isVisible If the node shall be visible. */ |
252 | virtual void setVisible(bool isVisible) | 252 | virtual void setVisible(bool isVisible) |
253 | { | 253 | { |
254 | IsVisible = isVisible; | 254 | IsVisible = isVisible; |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | //! Get the id of the scene node. | 258 | //! Get the id of the scene node. |
259 | /** This id can be used to identify the node. | 259 | /** This id can be used to identify the node. |
260 | \return The id. */ | 260 | \return The id. */ |
261 | virtual s32 getID() const | 261 | virtual s32 getID() const |
262 | { | 262 | { |
263 | return ID; | 263 | return ID; |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | //! Sets the id of the scene node. | 267 | //! Sets the id of the scene node. |
268 | /** This id can be used to identify the node. | 268 | /** This id can be used to identify the node. |
269 | \param id The new id. */ | 269 | \param id The new id. */ |
270 | virtual void setID(s32 id) | 270 | virtual void setID(s32 id) |
271 | { | 271 | { |
272 | ID = id; | 272 | ID = id; |
273 | } | 273 | } |
274 | 274 | ||
275 | 275 | ||
276 | //! Adds a child to this scene node. | 276 | //! Adds a child to this scene node. |
277 | /** If the scene node already has a parent it is first removed | 277 | /** If the scene node already has a parent it is first removed |
278 | from the other parent. | 278 | from the other parent. |
279 | \param child A pointer to the new child. */ | 279 | \param child A pointer to the new child. */ |
280 | virtual void addChild(ISceneNode* child) | 280 | virtual void addChild(ISceneNode* child) |
281 | { | 281 | { |
282 | if (child && (child != this)) | 282 | if (child && (child != this)) |
283 | { | 283 | { |
284 | // Change scene manager? | 284 | // Change scene manager? |
285 | if (SceneManager != child->SceneManager) | 285 | if (SceneManager != child->SceneManager) |
286 | child->setSceneManager(SceneManager); | 286 | child->setSceneManager(SceneManager); |
287 | 287 | ||
288 | child->grab(); | 288 | child->grab(); |
289 | child->remove(); // remove from old parent | 289 | child->remove(); // remove from old parent |
290 | Children.push_back(child); | 290 | Children.push_back(child); |
291 | child->Parent = this; | 291 | child->Parent = this; |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | 295 | ||
296 | //! Removes a child from this scene node. | 296 | //! Removes a child from this scene node. |
297 | /** If found in the children list, the child pointer is also | 297 | /** If found in the children list, the child pointer is also |
298 | dropped and might be deleted if no other grab exists. | 298 | dropped and might be deleted if no other grab exists. |
299 | \param child A pointer to the child which shall be removed. | 299 | \param child A pointer to the child which shall be removed. |
300 | \return True if the child was removed, and false if not, | 300 | \return True if the child was removed, and false if not, |
301 | e.g. because it couldn't be found in the children list. */ | 301 | e.g. because it couldn't be found in the children list. */ |
302 | virtual bool removeChild(ISceneNode* child) | 302 | virtual bool removeChild(ISceneNode* child) |
303 | { | 303 | { |
304 | ISceneNodeList::Iterator it = Children.begin(); | 304 | ISceneNodeList::Iterator it = Children.begin(); |
305 | for (; it != Children.end(); ++it) | 305 | for (; it != Children.end(); ++it) |
306 | if ((*it) == child) | 306 | if ((*it) == child) |
307 | { | 307 | { |
308 | (*it)->Parent = 0; | 308 | (*it)->Parent = 0; |
309 | (*it)->drop(); | 309 | (*it)->drop(); |
310 | Children.erase(it); | 310 | Children.erase(it); |
311 | return true; | 311 | return true; |
312 | } | 312 | } |
313 | 313 | ||
314 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 314 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
315 | return false; | 315 | return false; |
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
319 | //! Removes all children of this scene node | 319 | //! Removes all children of this scene node |
320 | /** The scene nodes found in the children list are also dropped | 320 | /** The scene nodes found in the children list are also dropped |
321 | and might be deleted if no other grab exists on them. | 321 | and might be deleted if no other grab exists on them. |
322 | */ | 322 | */ |
323 | virtual void removeAll() | 323 | virtual void removeAll() |
324 | { | 324 | { |
325 | ISceneNodeList::Iterator it = Children.begin(); | 325 | ISceneNodeList::Iterator it = Children.begin(); |
326 | for (; it != Children.end(); ++it) | 326 | for (; it != Children.end(); ++it) |
327 | { | 327 | { |
328 | (*it)->Parent = 0; | 328 | (*it)->Parent = 0; |
329 | (*it)->drop(); | 329 | (*it)->drop(); |
330 | } | 330 | } |
331 | 331 | ||
332 | Children.clear(); | 332 | Children.clear(); |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | //! Removes this scene node from the scene | 336 | //! Removes this scene node from the scene |
337 | /** If no other grab exists for this node, it will be deleted. | 337 | /** If no other grab exists for this node, it will be deleted. |
338 | */ | 338 | */ |
339 | virtual void remove() | 339 | virtual void remove() |
340 | { | 340 | { |
341 | if (Parent) | 341 | if (Parent) |
342 | Parent->removeChild(this); | 342 | Parent->removeChild(this); |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | //! Adds an animator which should animate this node. | 346 | //! Adds an animator which should animate this node. |
347 | /** \param animator A pointer to the new animator. */ | 347 | /** \param animator A pointer to the new animator. */ |
348 | virtual void addAnimator(ISceneNodeAnimator* animator) | 348 | virtual void addAnimator(ISceneNodeAnimator* animator) |
349 | { | 349 | { |
350 | if (animator) | 350 | if (animator) |
351 | { | 351 | { |
352 | Animators.push_back(animator); | 352 | Animators.push_back(animator); |
353 | animator->grab(); | 353 | animator->grab(); |
354 | } | 354 | } |
355 | } | 355 | } |
356 | 356 | ||
357 | 357 | ||
358 | //! Get a list of all scene node animators. | 358 | //! Get a list of all scene node animators. |
359 | /** \return The list of animators attached to this node. */ | 359 | /** \return The list of animators attached to this node. */ |
360 | const core::list<ISceneNodeAnimator*>& getAnimators() const | 360 | const core::list<ISceneNodeAnimator*>& getAnimators() const |
361 | { | 361 | { |
362 | return Animators; | 362 | return Animators; |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | //! Removes an animator from this scene node. | 366 | //! Removes an animator from this scene node. |
367 | /** If the animator is found, it is also dropped and might be | 367 | /** If the animator is found, it is also dropped and might be |
368 | deleted if not other grab exists for it. | 368 | deleted if not other grab exists for it. |
369 | \param animator A pointer to the animator to be deleted. */ | 369 | \param animator A pointer to the animator to be deleted. */ |
370 | virtual void removeAnimator(ISceneNodeAnimator* animator) | 370 | virtual void removeAnimator(ISceneNodeAnimator* animator) |
371 | { | 371 | { |
372 | ISceneNodeAnimatorList::Iterator it = Animators.begin(); | 372 | ISceneNodeAnimatorList::Iterator it = Animators.begin(); |
373 | for (; it != Animators.end(); ++it) | 373 | for (; it != Animators.end(); ++it) |
374 | { | 374 | { |
375 | if ((*it) == animator) | 375 | if ((*it) == animator) |
376 | { | 376 | { |
377 | (*it)->drop(); | 377 | (*it)->drop(); |
378 | Animators.erase(it); | 378 | Animators.erase(it); |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | 384 | ||
385 | //! Removes all animators from this scene node. | 385 | //! Removes all animators from this scene node. |
386 | /** The animators might also be deleted if no other grab exists | 386 | /** The animators might also be deleted if no other grab exists |
387 | for them. */ | 387 | for them. */ |
388 | virtual void removeAnimators() | 388 | virtual void removeAnimators() |
389 | { | 389 | { |
390 | ISceneNodeAnimatorList::Iterator it = Animators.begin(); | 390 | ISceneNodeAnimatorList::Iterator it = Animators.begin(); |
391 | for (; it != Animators.end(); ++it) | 391 | for (; it != Animators.end(); ++it) |
392 | (*it)->drop(); | 392 | (*it)->drop(); |
393 | 393 | ||
394 | Animators.clear(); | 394 | Animators.clear(); |
395 | } | 395 | } |
396 | 396 | ||
397 | 397 | ||
398 | //! Returns the material based on the zero based index i. | 398 | //! Returns the material based on the zero based index i. |
399 | /** To get the amount of materials used by this scene node, use | 399 | /** To get the amount of materials used by this scene node, use |
400 | getMaterialCount(). This function is needed for inserting the | 400 | getMaterialCount(). This function is needed for inserting the |
401 | node into the scene hierarchy at an optimal position for | 401 | node into the scene hierarchy at an optimal position for |
402 | minimizing renderstate changes, but can also be used to | 402 | minimizing renderstate changes, but can also be used to |
403 | directly modify the material of a scene node. | 403 | directly modify the material of a scene node. |
404 | \param num Zero based index. The maximal value is getMaterialCount() - 1. | 404 | \param num Zero based index. The maximal value is getMaterialCount() - 1. |
405 | \return The material at that index. */ | 405 | \return The material at that index. */ |
406 | virtual video::SMaterial& getMaterial(u32 num) | 406 | virtual video::SMaterial& getMaterial(u32 num) |
407 | { | 407 | { |
408 | return video::IdentityMaterial; | 408 | return video::IdentityMaterial; |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | //! Get amount of materials used by this scene node. | 412 | //! Get amount of materials used by this scene node. |
413 | /** \return Current amount of materials of this scene node. */ | 413 | /** \return Current amount of materials of this scene node. */ |
414 | virtual u32 getMaterialCount() const | 414 | virtual u32 getMaterialCount() const |
415 | { | 415 | { |
416 | return 0; | 416 | return 0; |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | //! Sets all material flags at once to a new value. | 420 | //! Sets all material flags at once to a new value. |
421 | /** Useful, for example, if you want the whole mesh to be | 421 | /** Useful, for example, if you want the whole mesh to be |
422 | affected by light. | 422 | affected by light. |
423 | \param flag Which flag of all materials to be set. | 423 | \param flag Which flag of all materials to be set. |
424 | \param newvalue New value of that flag. */ | 424 | \param newvalue New value of that flag. */ |
425 | void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) | 425 | void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) |
426 | { | 426 | { |
427 | for (u32 i=0; i<getMaterialCount(); ++i) | 427 | for (u32 i=0; i<getMaterialCount(); ++i) |
428 | getMaterial(i).setFlag(flag, newvalue); | 428 | getMaterial(i).setFlag(flag, newvalue); |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | //! Sets the texture of the specified layer in all materials of this scene node to the new texture. | 432 | //! Sets the texture of the specified layer in all materials of this scene node to the new texture. |
433 | /** \param textureLayer Layer of texture to be set. Must be a | 433 | /** \param textureLayer Layer of texture to be set. Must be a |
434 | value smaller than MATERIAL_MAX_TEXTURES. | 434 | value smaller than MATERIAL_MAX_TEXTURES. |
435 | \param texture New texture to be used. */ | 435 | \param texture New texture to be used. */ |
436 | void setMaterialTexture(u32 textureLayer, video::ITexture* texture) | 436 | void setMaterialTexture(u32 textureLayer, video::ITexture* texture) |
437 | { | 437 | { |
438 | if (textureLayer >= video::MATERIAL_MAX_TEXTURES) | 438 | if (textureLayer >= video::MATERIAL_MAX_TEXTURES) |
439 | return; | 439 | return; |
440 | 440 | ||
441 | for (u32 i=0; i<getMaterialCount(); ++i) | 441 | for (u32 i=0; i<getMaterialCount(); ++i) |
442 | getMaterial(i).setTexture(textureLayer, texture); | 442 | getMaterial(i).setTexture(textureLayer, texture); |
443 | } | 443 | } |
444 | 444 | ||
445 | 445 | ||
446 | //! Sets the material type of all materials in this scene node to a new material type. | 446 | //! Sets the material type of all materials in this scene node to a new material type. |
447 | /** \param newType New type of material to be set. */ | 447 | /** \param newType New type of material to be set. */ |
448 | void setMaterialType(video::E_MATERIAL_TYPE newType) | 448 | void setMaterialType(video::E_MATERIAL_TYPE newType) |
449 | { | 449 | { |
450 | for (u32 i=0; i<getMaterialCount(); ++i) | 450 | for (u32 i=0; i<getMaterialCount(); ++i) |
451 | getMaterial(i).MaterialType = newType; | 451 | getMaterial(i).MaterialType = newType; |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | //! Gets the scale of the scene node relative to its parent. | 455 | //! Gets the scale of the scene node relative to its parent. |
456 | /** This is the scale of this node relative to its parent. | 456 | /** This is the scale of this node relative to its parent. |
457 | If you want the absolute scale, use | 457 | If you want the absolute scale, use |
458 | getAbsoluteTransformation().getScale() | 458 | getAbsoluteTransformation().getScale() |
459 | \return The scale of the scene node. */ | 459 | \return The scale of the scene node. */ |
460 | virtual const core::vector3df& getScale() const | 460 | virtual const core::vector3df& getScale() const |
461 | { | 461 | { |
462 | return RelativeScale; | 462 | return RelativeScale; |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | //! Sets the relative scale of the scene node. | 466 | //! Sets the relative scale of the scene node. |
467 | /** \param scale New scale of the node, relative to its parent. */ | 467 | /** \param scale New scale of the node, relative to its parent. */ |
468 | virtual void setScale(const core::vector3df& scale) | 468 | virtual void setScale(const core::vector3df& scale) |
469 | { | 469 | { |
470 | RelativeScale = scale; | 470 | RelativeScale = scale; |
471 | } | 471 | } |
472 | 472 | ||
473 | 473 | ||
474 | //! Gets the rotation of the node relative to its parent. | 474 | //! Gets the rotation of the node relative to its parent. |
475 | /** Note that this is the relative rotation of the node. | 475 | /** Note that this is the relative rotation of the node. |
476 | If you want the absolute rotation, use | 476 | If you want the absolute rotation, use |
477 | getAbsoluteTransformation().getRotation() | 477 | getAbsoluteTransformation().getRotation() |
478 | \return Current relative rotation of the scene node. */ | 478 | \return Current relative rotation of the scene node. */ |
479 | virtual const core::vector3df& getRotation() const | 479 | virtual const core::vector3df& getRotation() const |
480 | { | 480 | { |
481 | return RelativeRotation; | 481 | return RelativeRotation; |
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | //! Sets the rotation of the node relative to its parent. | 485 | //! Sets the rotation of the node relative to its parent. |
486 | /** This only modifies the relative rotation of the node. | 486 | /** This only modifies the relative rotation of the node. |
487 | \param rotation New rotation of the node in degrees. */ | 487 | \param rotation New rotation of the node in degrees. */ |
488 | virtual void setRotation(const core::vector3df& rotation) | 488 | virtual void setRotation(const core::vector3df& rotation) |
489 | { | 489 | { |
490 | RelativeRotation = rotation; | 490 | RelativeRotation = rotation; |
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
494 | //! Gets the position of the node relative to its parent. | 494 | //! Gets the position of the node relative to its parent. |
495 | /** Note that the position is relative to the parent. If you want | 495 | /** Note that the position is relative to the parent. If you want |
496 | the position in world coordinates, use getAbsolutePosition() instead. | 496 | the position in world coordinates, use getAbsolutePosition() instead. |
497 | \return The current position of the node relative to the parent. */ | 497 | \return The current position of the node relative to the parent. */ |
498 | virtual const core::vector3df& getPosition() const | 498 | virtual const core::vector3df& getPosition() const |
499 | { | 499 | { |
500 | return RelativeTranslation; | 500 | return RelativeTranslation; |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | //! Sets the position of the node relative to its parent. | 504 | //! Sets the position of the node relative to its parent. |
505 | /** Note that the position is relative to the parent. | 505 | /** Note that the position is relative to the parent. |
506 | \param newpos New relative position of the scene node. */ | 506 | \param newpos New relative position of the scene node. */ |
507 | virtual void setPosition(const core::vector3df& newpos) | 507 | virtual void setPosition(const core::vector3df& newpos) |
508 | { | 508 | { |
509 | RelativeTranslation = newpos; | 509 | RelativeTranslation = newpos; |
510 | } | 510 | } |
511 | 511 | ||
512 | 512 | ||
513 | //! Gets the absolute position of the node in world coordinates. | 513 | //! Gets the absolute position of the node in world coordinates. |
514 | /** If you want the position of the node relative to its parent, | 514 | /** If you want the position of the node relative to its parent, |
515 | use getPosition() instead. | 515 | use getPosition() instead. |
516 | NOTE: For speed reasons the absolute position is not | 516 | NOTE: For speed reasons the absolute position is not |
517 | automatically recalculated on each change of the relative | 517 | automatically recalculated on each change of the relative |
518 | position or by a position change of an parent. Instead the | 518 | position or by a position change of an parent. Instead the |
519 | update usually happens once per frame in OnAnimate. You can enforce | 519 | update usually happens once per frame in OnAnimate. You can enforce |
520 | an update with updateAbsolutePosition(). | 520 | an update with updateAbsolutePosition(). |
521 | \return The current absolute position of the scene node (updated on last call of updateAbsolutePosition). */ | 521 | \return The current absolute position of the scene node (updated on last call of updateAbsolutePosition). */ |
522 | virtual core::vector3df getAbsolutePosition() const | 522 | virtual core::vector3df getAbsolutePosition() const |
523 | { | 523 | { |
524 | return AbsoluteTransformation.getTranslation(); | 524 | return AbsoluteTransformation.getTranslation(); |
525 | } | 525 | } |
526 | 526 | ||
527 | 527 | ||
528 | //! Enables or disables automatic culling based on the bounding box. | 528 | //! Enables or disables automatic culling based on the bounding box. |
529 | /** Automatic culling is enabled by default. Note that not | 529 | /** Automatic culling is enabled by default. Note that not |
530 | all SceneNodes support culling and that some nodes always cull | 530 | all SceneNodes support culling and that some nodes always cull |
531 | their geometry because it is their only reason for existence, | 531 | their geometry because it is their only reason for existence, |
532 | for example the OctreeSceneNode. | 532 | for example the OctreeSceneNode. |
533 | \param state The culling state to be used. */ | 533 | \param state The culling state to be used. */ |
534 | void setAutomaticCulling( u32 state) | 534 | void setAutomaticCulling( u32 state) |
535 | { | 535 | { |
536 | AutomaticCullingState = state; | 536 | AutomaticCullingState = state; |
537 | } | 537 | } |
538 | 538 | ||
539 | 539 | ||
540 | //! Gets the automatic culling state. | 540 | //! Gets the automatic culling state. |
541 | /** \return The automatic culling state. */ | 541 | /** \return The automatic culling state. */ |
542 | u32 getAutomaticCulling() const | 542 | u32 getAutomaticCulling() const |
543 | { | 543 | { |
544 | return AutomaticCullingState; | 544 | return AutomaticCullingState; |
545 | } | 545 | } |
546 | 546 | ||
547 | 547 | ||
548 | //! Sets if debug data like bounding boxes should be drawn. | 548 | //! Sets if debug data like bounding boxes should be drawn. |
549 | /** A bitwise OR of the types from @ref irr::scene::E_DEBUG_SCENE_TYPE. | 549 | /** A bitwise OR of the types from @ref irr::scene::E_DEBUG_SCENE_TYPE. |
550 | Please note that not all scene nodes support all debug data types. | 550 | Please note that not all scene nodes support all debug data types. |
551 | \param state The debug data visibility state to be used. */ | 551 | \param state The debug data visibility state to be used. */ |
552 | virtual void setDebugDataVisible(u32 state) | 552 | virtual void setDebugDataVisible(u32 state) |
553 | { | 553 | { |
554 | DebugDataVisible = state; | 554 | DebugDataVisible = state; |
555 | } | 555 | } |
556 | 556 | ||
557 | //! Returns if debug data like bounding boxes are drawn. | 557 | //! Returns if debug data like bounding boxes are drawn. |
558 | /** \return A bitwise OR of the debug data values from | 558 | /** \return A bitwise OR of the debug data values from |
559 | @ref irr::scene::E_DEBUG_SCENE_TYPE that are currently visible. */ | 559 | @ref irr::scene::E_DEBUG_SCENE_TYPE that are currently visible. */ |
560 | u32 isDebugDataVisible() const | 560 | u32 isDebugDataVisible() const |
561 | { | 561 | { |
562 | return DebugDataVisible; | 562 | return DebugDataVisible; |
563 | } | 563 | } |
564 | 564 | ||
565 | 565 | ||
566 | //! Sets if this scene node is a debug object. | 566 | //! Sets if this scene node is a debug object. |
567 | /** Debug objects have some special properties, for example they can be easily | 567 | /** Debug objects have some special properties, for example they can be easily |
568 | excluded from collision detection or from serialization, etc. */ | 568 | excluded from collision detection or from serialization, etc. */ |
569 | void setIsDebugObject(bool debugObject) | 569 | void setIsDebugObject(bool debugObject) |
570 | { | 570 | { |
571 | IsDebugObject = debugObject; | 571 | IsDebugObject = debugObject; |
572 | } | 572 | } |
573 | 573 | ||
574 | 574 | ||
575 | //! Returns if this scene node is a debug object. | 575 | //! Returns if this scene node is a debug object. |
576 | /** Debug objects have some special properties, for example they can be easily | 576 | /** Debug objects have some special properties, for example they can be easily |
577 | excluded from collision detection or from serialization, etc. | 577 | excluded from collision detection or from serialization, etc. |
578 | \return If this node is a debug object, true is returned. */ | 578 | \return If this node is a debug object, true is returned. */ |
579 | bool isDebugObject() const | 579 | bool isDebugObject() const |
580 | { | 580 | { |
581 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 581 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
582 | return IsDebugObject; | 582 | return IsDebugObject; |
583 | } | 583 | } |
584 | 584 | ||
585 | 585 | ||
586 | //! Returns a const reference to the list of all children. | 586 | //! Returns a const reference to the list of all children. |
587 | /** \return The list of all children of this node. */ | 587 | /** \return The list of all children of this node. */ |
588 | const core::list<ISceneNode*>& getChildren() const | 588 | const core::list<ISceneNode*>& getChildren() const |
589 | { | 589 | { |
590 | return Children; | 590 | return Children; |
591 | } | 591 | } |
592 | 592 | ||
593 | 593 | ||
594 | //! Changes the parent of the scene node. | 594 | //! Changes the parent of the scene node. |
595 | /** \param newParent The new parent to be used. */ | 595 | /** \param newParent The new parent to be used. */ |
596 | virtual void setParent(ISceneNode* newParent) | 596 | virtual void setParent(ISceneNode* newParent) |
597 | { | 597 | { |
598 | grab(); | 598 | grab(); |
599 | remove(); | 599 | remove(); |
600 | 600 | ||
601 | Parent = newParent; | 601 | Parent = newParent; |
602 | 602 | ||
603 | if (Parent) | 603 | if (Parent) |
604 | Parent->addChild(this); | 604 | Parent->addChild(this); |
605 | 605 | ||
606 | drop(); | 606 | drop(); |
607 | } | 607 | } |
608 | 608 | ||
609 | 609 | ||
610 | //! Returns the triangle selector attached to this scene node. | 610 | //! Returns the triangle selector attached to this scene node. |
611 | /** The Selector can be used by the engine for doing collision | 611 | /** The Selector can be used by the engine for doing collision |
612 | detection. You can create a TriangleSelector with | 612 | detection. You can create a TriangleSelector with |
613 | ISceneManager::createTriangleSelector() or | 613 | ISceneManager::createTriangleSelector() or |
614 | ISceneManager::createOctreeTriangleSelector and set it with | 614 | ISceneManager::createOctreeTriangleSelector and set it with |
615 | ISceneNode::setTriangleSelector(). If a scene node got no triangle | 615 | ISceneNode::setTriangleSelector(). If a scene node got no triangle |
616 | selector, but collision tests should be done with it, a triangle | 616 | selector, but collision tests should be done with it, a triangle |
617 | selector is created using the bounding box of the scene node. | 617 | selector is created using the bounding box of the scene node. |
618 | \return A pointer to the TriangleSelector or 0, if there | 618 | \return A pointer to the TriangleSelector or 0, if there |
619 | is none. */ | 619 | is none. */ |
620 | virtual ITriangleSelector* getTriangleSelector() const | 620 | virtual ITriangleSelector* getTriangleSelector() const |
621 | { | 621 | { |
622 | return TriangleSelector; | 622 | return TriangleSelector; |
623 | } | 623 | } |
624 | 624 | ||
625 | 625 | ||
626 | //! Sets the triangle selector of the scene node. | 626 | //! Sets the triangle selector of the scene node. |
627 | /** The Selector can be used by the engine for doing collision | 627 | /** The Selector can be used by the engine for doing collision |
628 | detection. You can create a TriangleSelector with | 628 | detection. You can create a TriangleSelector with |
629 | ISceneManager::createTriangleSelector() or | 629 | ISceneManager::createTriangleSelector() or |
630 | ISceneManager::createOctreeTriangleSelector(). Some nodes may | 630 | ISceneManager::createOctreeTriangleSelector(). Some nodes may |
631 | create their own selector by default, so it would be good to | 631 | create their own selector by default, so it would be good to |
632 | check if there is already a selector in this node by calling | 632 | check if there is already a selector in this node by calling |
633 | ISceneNode::getTriangleSelector(). | 633 | ISceneNode::getTriangleSelector(). |
634 | \param selector New triangle selector for this scene node. */ | 634 | \param selector New triangle selector for this scene node. */ |
635 | virtual void setTriangleSelector(ITriangleSelector* selector) | 635 | virtual void setTriangleSelector(ITriangleSelector* selector) |
636 | { | 636 | { |
637 | if (TriangleSelector != selector) | 637 | if (TriangleSelector != selector) |
638 | { | 638 | { |
639 | if (TriangleSelector) | 639 | if (TriangleSelector) |
640 | TriangleSelector->drop(); | 640 | TriangleSelector->drop(); |
641 | 641 | ||
642 | TriangleSelector = selector; | 642 | TriangleSelector = selector; |
643 | if (TriangleSelector) | 643 | if (TriangleSelector) |
644 | TriangleSelector->grab(); | 644 | TriangleSelector->grab(); |
645 | } | 645 | } |
646 | } | 646 | } |
647 | 647 | ||
648 | 648 | ||
649 | //! Updates the absolute position based on the relative and the parents position | 649 | //! Updates the absolute position based on the relative and the parents position |
650 | /** Note: This does not recursively update the parents absolute positions, so if you have a deeper | 650 | /** Note: This does not recursively update the parents absolute positions, so if you have a deeper |
651 | hierarchy you might want to update the parents first.*/ | 651 | hierarchy you might want to update the parents first.*/ |
652 | virtual void updateAbsolutePosition() | 652 | virtual void updateAbsolutePosition() |
653 | { | 653 | { |
654 | if (Parent) | 654 | if (Parent) |
655 | { | 655 | { |
656 | AbsoluteTransformation = | 656 | AbsoluteTransformation = |
657 | Parent->getAbsoluteTransformation() * getRelativeTransformation(); | 657 | Parent->getAbsoluteTransformation() * getRelativeTransformation(); |
658 | } | 658 | } |
659 | else | 659 | else |
660 | AbsoluteTransformation = getRelativeTransformation(); | 660 | AbsoluteTransformation = getRelativeTransformation(); |
661 | } | 661 | } |
662 | 662 | ||
663 | 663 | ||
664 | //! Returns the parent of this scene node | 664 | //! Returns the parent of this scene node |
665 | /** \return A pointer to the parent. */ | 665 | /** \return A pointer to the parent. */ |
666 | scene::ISceneNode* getParent() const | 666 | scene::ISceneNode* getParent() const |
667 | { | 667 | { |
668 | return Parent; | 668 | return Parent; |
669 | } | 669 | } |
670 | 670 | ||
671 | 671 | ||
672 | //! Returns type of the scene node | 672 | //! Returns type of the scene node |
673 | /** \return The type of this node. */ | 673 | /** \return The type of this node. */ |
674 | virtual ESCENE_NODE_TYPE getType() const | 674 | virtual ESCENE_NODE_TYPE getType() const |
675 | { | 675 | { |
676 | return ESNT_UNKNOWN; | 676 | return ESNT_UNKNOWN; |
677 | } | 677 | } |
678 | 678 | ||
679 | 679 | ||
680 | //! Writes attributes of the scene node. | 680 | //! Writes attributes of the scene node. |
681 | /** Implement this to expose the attributes of your scene node | 681 | /** Implement this to expose the attributes of your scene node |
682 | for scripting languages, editors, debuggers or xml | 682 | for scripting languages, editors, debuggers or xml |
683 | serialization purposes. | 683 | serialization purposes. |
684 | \param out The attribute container to write into. | 684 | \param out The attribute container to write into. |
685 | \param options Additional options which might influence the | 685 | \param options Additional options which might influence the |
686 | serialization. */ | 686 | serialization. */ |
687 | virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const | 687 | virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const |
688 | { | 688 | { |
689 | if (!out) | 689 | if (!out) |
690 | return; | 690 | return; |
691 | out->addString ("Name", Name.c_str()); | 691 | out->addString ("Name", Name.c_str()); |
692 | out->addInt ("Id", ID ); | 692 | out->addInt ("Id", ID ); |
693 | 693 | ||
694 | out->addVector3d("Position", getPosition() ); | 694 | out->addVector3d("Position", getPosition() ); |
695 | out->addVector3d("Rotation", getRotation() ); | 695 | out->addVector3d("Rotation", getRotation() ); |
696 | out->addVector3d("Scale", getScale() ); | 696 | out->addVector3d("Scale", getScale() ); |
697 | 697 | ||
698 | out->addBool ("Visible", IsVisible ); | 698 | out->addBool ("Visible", IsVisible ); |
699 | out->addInt ("AutomaticCulling", AutomaticCullingState); | 699 | out->addInt ("AutomaticCulling", AutomaticCullingState); |
700 | out->addInt ("DebugDataVisible", DebugDataVisible ); | 700 | out->addInt ("DebugDataVisible", DebugDataVisible ); |
701 | out->addBool ("IsDebugObject", IsDebugObject ); | 701 | out->addBool ("IsDebugObject", IsDebugObject ); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //! Reads attributes of the scene node. | 705 | //! Reads attributes of the scene node. |
706 | /** Implement this to set the attributes of your scene node for | 706 | /** Implement this to set the attributes of your scene node for |
707 | scripting languages, editors, debuggers or xml deserialization | 707 | scripting languages, editors, debuggers or xml deserialization |
708 | purposes. | 708 | purposes. |
709 | \param in The attribute container to read from. | 709 | \param in The attribute container to read from. |
710 | \param options Additional options which might influence the | 710 | \param options Additional options which might influence the |
711 | deserialization. */ | 711 | deserialization. */ |
712 | virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) | 712 | virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) |
713 | { | 713 | { |
714 | if (!in) | 714 | if (!in) |
715 | return; | 715 | return; |
716 | Name = in->getAttributeAsString("Name"); | 716 | Name = in->getAttributeAsString("Name"); |
717 | ID = in->getAttributeAsInt("Id"); | 717 | ID = in->getAttributeAsInt("Id"); |
718 | 718 | ||
719 | setPosition(in->getAttributeAsVector3d("Position")); | 719 | setPosition(in->getAttributeAsVector3d("Position")); |
720 | setRotation(in->getAttributeAsVector3d("Rotation")); | 720 | setRotation(in->getAttributeAsVector3d("Rotation")); |
721 | setScale(in->getAttributeAsVector3d("Scale")); | 721 | setScale(in->getAttributeAsVector3d("Scale")); |
722 | 722 | ||
723 | IsVisible = in->getAttributeAsBool("Visible"); | 723 | IsVisible = in->getAttributeAsBool("Visible"); |
724 | s32 tmpState = in->getAttributeAsEnumeration("AutomaticCulling", | 724 | s32 tmpState = in->getAttributeAsEnumeration("AutomaticCulling", |
725 | scene::AutomaticCullingNames); | 725 | scene::AutomaticCullingNames); |
726 | if (tmpState != -1) | 726 | if (tmpState != -1) |
727 | AutomaticCullingState = (u32)tmpState; | 727 | AutomaticCullingState = (u32)tmpState; |
728 | else | 728 | else |
729 | AutomaticCullingState = in->getAttributeAsInt("AutomaticCulling"); | 729 | AutomaticCullingState = in->getAttributeAsInt("AutomaticCulling"); |
730 | 730 | ||
731 | DebugDataVisible = in->getAttributeAsInt("DebugDataVisible"); | 731 | DebugDataVisible = in->getAttributeAsInt("DebugDataVisible"); |
732 | IsDebugObject = in->getAttributeAsBool("IsDebugObject"); | 732 | IsDebugObject = in->getAttributeAsBool("IsDebugObject"); |
733 | 733 | ||
734 | updateAbsolutePosition(); | 734 | updateAbsolutePosition(); |
735 | } | 735 | } |
736 | 736 | ||
737 | //! Creates a clone of this scene node and its children. | 737 | //! Creates a clone of this scene node and its children. |
738 | /** \param newParent An optional new parent. | 738 | /** \param newParent An optional new parent. |
739 | \param newManager An optional new scene manager. | 739 | \param newManager An optional new scene manager. |
740 | \return The newly created clone of this node. */ | 740 | \return The newly created clone of this node. */ |
741 | virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) | 741 | virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) |
742 | { | 742 | { |
743 | return 0; // to be implemented by derived classes | 743 | return 0; // to be implemented by derived classes |
744 | } | 744 | } |
745 | 745 | ||
746 | //! Retrieve the scene manager for this node. | 746 | //! Retrieve the scene manager for this node. |
747 | /** \return The node's scene manager. */ | 747 | /** \return The node's scene manager. */ |
748 | virtual ISceneManager* getSceneManager(void) const { return SceneManager; } | 748 | virtual ISceneManager* getSceneManager(void) const { return SceneManager; } |
749 | 749 | ||
750 | protected: | 750 | protected: |
751 | 751 | ||
752 | //! A clone function for the ISceneNode members. | 752 | //! A clone function for the ISceneNode members. |
753 | /** This method can be used by clone() implementations of | 753 | /** This method can be used by clone() implementations of |
754 | derived classes | 754 | derived classes |
755 | \param toCopyFrom The node from which the values are copied | 755 | \param toCopyFrom The node from which the values are copied |
756 | \param newManager The new scene manager. */ | 756 | \param newManager The new scene manager. */ |
757 | void cloneMembers(ISceneNode* toCopyFrom, ISceneManager* newManager) | 757 | void cloneMembers(ISceneNode* toCopyFrom, ISceneManager* newManager) |
758 | { | 758 | { |
759 | Name = toCopyFrom->Name; | 759 | Name = toCopyFrom->Name; |
760 | AbsoluteTransformation = toCopyFrom->AbsoluteTransformation; | 760 | AbsoluteTransformation = toCopyFrom->AbsoluteTransformation; |
761 | RelativeTranslation = toCopyFrom->RelativeTranslation; | 761 | RelativeTranslation = toCopyFrom->RelativeTranslation; |
762 | RelativeRotation = toCopyFrom->RelativeRotation; | 762 | RelativeRotation = toCopyFrom->RelativeRotation; |
763 | RelativeScale = toCopyFrom->RelativeScale; | 763 | RelativeScale = toCopyFrom->RelativeScale; |
764 | ID = toCopyFrom->ID; | 764 | ID = toCopyFrom->ID; |
765 | setTriangleSelector(toCopyFrom->TriangleSelector); | 765 | setTriangleSelector(toCopyFrom->TriangleSelector); |
766 | AutomaticCullingState = toCopyFrom->AutomaticCullingState; | 766 | AutomaticCullingState = toCopyFrom->AutomaticCullingState; |
767 | DebugDataVisible = toCopyFrom->DebugDataVisible; | 767 | DebugDataVisible = toCopyFrom->DebugDataVisible; |
768 | IsVisible = toCopyFrom->IsVisible; | 768 | IsVisible = toCopyFrom->IsVisible; |
769 | IsDebugObject = toCopyFrom->IsDebugObject; | 769 | IsDebugObject = toCopyFrom->IsDebugObject; |
770 | 770 | ||
771 | if (newManager) | 771 | if (newManager) |
772 | SceneManager = newManager; | 772 | SceneManager = newManager; |
773 | else | 773 | else |
774 | SceneManager = toCopyFrom->SceneManager; | 774 | SceneManager = toCopyFrom->SceneManager; |
775 | 775 | ||
776 | // clone children | 776 | // clone children |
777 | 777 | ||
778 | ISceneNodeList::Iterator it = toCopyFrom->Children.begin(); | 778 | ISceneNodeList::Iterator it = toCopyFrom->Children.begin(); |
779 | for (; it != toCopyFrom->Children.end(); ++it) | 779 | for (; it != toCopyFrom->Children.end(); ++it) |
780 | (*it)->clone(this, newManager); | 780 | (*it)->clone(this, newManager); |
781 | 781 | ||
782 | // clone animators | 782 | // clone animators |
783 | 783 | ||
784 | ISceneNodeAnimatorList::Iterator ait = toCopyFrom->Animators.begin(); | 784 | ISceneNodeAnimatorList::Iterator ait = toCopyFrom->Animators.begin(); |
785 | for (; ait != toCopyFrom->Animators.end(); ++ait) | 785 | for (; ait != toCopyFrom->Animators.end(); ++ait) |
786 | { | 786 | { |
787 | ISceneNodeAnimator* anim = (*ait)->createClone(this, SceneManager); | 787 | ISceneNodeAnimator* anim = (*ait)->createClone(this, SceneManager); |
788 | if (anim) | 788 | if (anim) |
789 | { | 789 | { |
790 | addAnimator(anim); | 790 | addAnimator(anim); |
791 | anim->drop(); | 791 | anim->drop(); |
792 | } | 792 | } |
793 | } | 793 | } |
794 | } | 794 | } |
795 | 795 | ||
796 | //! Sets the new scene manager for this node and all children. | 796 | //! Sets the new scene manager for this node and all children. |
797 | //! Called by addChild when moving nodes between scene managers | 797 | //! Called by addChild when moving nodes between scene managers |
798 | void setSceneManager(ISceneManager* newManager) | 798 | void setSceneManager(ISceneManager* newManager) |
799 | { | 799 | { |
800 | SceneManager = newManager; | 800 | SceneManager = newManager; |
801 | 801 | ||
802 | ISceneNodeList::Iterator it = Children.begin(); | 802 | ISceneNodeList::Iterator it = Children.begin(); |
803 | for (; it != Children.end(); ++it) | 803 | for (; it != Children.end(); ++it) |
804 | (*it)->setSceneManager(newManager); | 804 | (*it)->setSceneManager(newManager); |
805 | } | 805 | } |
806 | 806 | ||
807 | //! Name of the scene node. | 807 | //! Name of the scene node. |
808 | core::stringc Name; | 808 | core::stringc Name; |
809 | 809 | ||
810 | //! Absolute transformation of the node. | 810 | //! Absolute transformation of the node. |
811 | core::matrix4 AbsoluteTransformation; | 811 | core::matrix4 AbsoluteTransformation; |
812 | 812 | ||
813 | //! Relative translation of the scene node. | 813 | //! Relative translation of the scene node. |
814 | core::vector3df RelativeTranslation; | 814 | core::vector3df RelativeTranslation; |
815 | 815 | ||
816 | //! Relative rotation of the scene node. | 816 | //! Relative rotation of the scene node. |
817 | core::vector3df RelativeRotation; | 817 | core::vector3df RelativeRotation; |
818 | 818 | ||
819 | //! Relative scale of the scene node. | 819 | //! Relative scale of the scene node. |
820 | core::vector3df RelativeScale; | 820 | core::vector3df RelativeScale; |
821 | 821 | ||
822 | //! Pointer to the parent | 822 | //! Pointer to the parent |
823 | ISceneNode* Parent; | 823 | ISceneNode* Parent; |
824 | 824 | ||
825 | //! List of all children of this node | 825 | //! List of all children of this node |
826 | core::list<ISceneNode*> Children; | 826 | core::list<ISceneNode*> Children; |
827 | 827 | ||
828 | //! List of all animator nodes | 828 | //! List of all animator nodes |
829 | core::list<ISceneNodeAnimator*> Animators; | 829 | core::list<ISceneNodeAnimator*> Animators; |
830 | 830 | ||
831 | //! Pointer to the scene manager | 831 | //! Pointer to the scene manager |
832 | ISceneManager* SceneManager; | 832 | ISceneManager* SceneManager; |
833 | 833 | ||
834 | //! Pointer to the triangle selector | 834 | //! Pointer to the triangle selector |
835 | ITriangleSelector* TriangleSelector; | 835 | ITriangleSelector* TriangleSelector; |
836 | 836 | ||
837 | //! ID of the node. | 837 | //! ID of the node. |
838 | s32 ID; | 838 | s32 ID; |
839 | 839 | ||
840 | //! Automatic culling state | 840 | //! Automatic culling state |
841 | u32 AutomaticCullingState; | 841 | u32 AutomaticCullingState; |
842 | 842 | ||
843 | //! Flag if debug data should be drawn, such as Bounding Boxes. | 843 | //! Flag if debug data should be drawn, such as Bounding Boxes. |
844 | u32 DebugDataVisible; | 844 | u32 DebugDataVisible; |
845 | 845 | ||
846 | //! Is the node visible? | 846 | //! Is the node visible? |
847 | bool IsVisible; | 847 | bool IsVisible; |
848 | 848 | ||
849 | //! Is debug object? | 849 | //! Is debug object? |
850 | bool IsDebugObject; | 850 | bool IsDebugObject; |
851 | }; | 851 | }; |
852 | 852 | ||
853 | 853 | ||
854 | } // end namespace scene | 854 | } // end namespace scene |
855 | } // end namespace irr | 855 | } // end namespace irr |
856 | 856 | ||
857 | #endif | 857 | #endif |
858 | 858 | ||