1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef _Node_H__
|
---|
26 | #define _Node_H__
|
---|
27 |
|
---|
28 | #include "OgrePrerequisites.h"
|
---|
29 |
|
---|
30 | #include "OgreMatrix3.h"
|
---|
31 | #include "OgreMatrix4.h"
|
---|
32 | #include "OgreQuaternion.h"
|
---|
33 | #include "OgreString.h"
|
---|
34 | #include "OgreRenderable.h"
|
---|
35 | #include "OgreIteratorWrappers.h"
|
---|
36 |
|
---|
37 | namespace Ogre {
|
---|
38 |
|
---|
39 |
|
---|
40 | /** Class representing a general-purpose node an articulated scene graph.
|
---|
41 | @remarks
|
---|
42 | A node in the scene graph is a node in a structured tree. A node contains
|
---|
43 | information about the transformation which will apply to
|
---|
44 | it and all of it's children. Child nodes can have transforms of their own, which
|
---|
45 | are combined with their parent's transformations.
|
---|
46 | @par
|
---|
47 | This is an abstract class - concrete classes are based on this for specific purposes,
|
---|
48 | e.g. SceneNode, Bone
|
---|
49 | */
|
---|
50 | class _OgreExport Node : public Renderable
|
---|
51 | {
|
---|
52 | public:
|
---|
53 | /** Enumeration denoting the spaces which a transform can be relative to.
|
---|
54 | */
|
---|
55 | enum TransformSpace
|
---|
56 | {
|
---|
57 | /// Transform is relative to the local space
|
---|
58 | TS_LOCAL,
|
---|
59 | /// Transform is relative to the space of the parent node
|
---|
60 | TS_PARENT,
|
---|
61 | /// Transform is relative to world space
|
---|
62 | TS_WORLD
|
---|
63 | };
|
---|
64 | typedef HashMap<String, Node*> ChildNodeMap;
|
---|
65 | typedef MapIterator<ChildNodeMap> ChildNodeIterator;
|
---|
66 | typedef ConstMapIterator<ChildNodeMap> ConstChildNodeIterator;
|
---|
67 |
|
---|
68 | /** Listener which gets called back on Node events.
|
---|
69 | */
|
---|
70 | class _OgreExport Listener
|
---|
71 | {
|
---|
72 | public:
|
---|
73 | Listener() {}
|
---|
74 | virtual ~Listener() {}
|
---|
75 | /** Called when a node gets updated.
|
---|
76 | @remarks
|
---|
77 | Note that this happens when the node's derived update happens,
|
---|
78 | not every time a method altering it's state occurs. There may
|
---|
79 | be several state-changing calls but only one of these calls,
|
---|
80 | when the node graph is fully updated.
|
---|
81 | */
|
---|
82 | virtual void nodeUpdated(const Node* node) {}
|
---|
83 | /** Node is being destroyed */
|
---|
84 | virtual void nodeDestroyed(const Node* node) {};
|
---|
85 | /** Node has been attached to a parent */
|
---|
86 | virtual void nodeAttached(const Node* node) {};
|
---|
87 | /** Node has been detached from a parent */
|
---|
88 | virtual void nodeDetached(const Node* node) {};
|
---|
89 | };
|
---|
90 |
|
---|
91 | protected:
|
---|
92 | /// Pointer to parent node
|
---|
93 | Node* mParent;
|
---|
94 | /// Collection of pointers to direct children; hashmap for efficiency
|
---|
95 | ChildNodeMap mChildren;
|
---|
96 |
|
---|
97 | typedef std::set<Node*> ChildUpdateSet;
|
---|
98 | /// List of children which need updating, used if self is not out of date but children are
|
---|
99 | mutable ChildUpdateSet mChildrenToUpdate;
|
---|
100 | /// Flag to indicate own transform from parent is out of date
|
---|
101 | mutable bool mNeedParentUpdate;
|
---|
102 | /// Flag indicating that all children need to be updated
|
---|
103 | mutable bool mNeedChildUpdate;
|
---|
104 | /// Flag indicating that parent has been notified about update request
|
---|
105 | mutable bool mParentNotified ;
|
---|
106 |
|
---|
107 | /// Friendly name of this node, can be automatically generated if you don't care
|
---|
108 | String mName;
|
---|
109 |
|
---|
110 | /// Incremented count for next name extension
|
---|
111 | static unsigned long msNextGeneratedNameExt;
|
---|
112 |
|
---|
113 | /// Stores the orientation of the node relative to it's parent.
|
---|
114 | Quaternion mOrientation;
|
---|
115 |
|
---|
116 | /// Stores the position/translation of the node relative to its parent.
|
---|
117 | Vector3 mPosition;
|
---|
118 |
|
---|
119 | /// Stores the scaling factor applied to this node
|
---|
120 | Vector3 mScale;
|
---|
121 |
|
---|
122 | /// Stores whether this node inherits orientation from it's parent
|
---|
123 | bool mInheritOrientation;
|
---|
124 |
|
---|
125 | /// Stores whether this node inherits scale from it's parent
|
---|
126 | bool mInheritScale;
|
---|
127 |
|
---|
128 | /// Material pointer should this node be rendered
|
---|
129 | mutable MaterialPtr mpMaterial;
|
---|
130 |
|
---|
131 | /// Only available internally - notification of parent.
|
---|
132 | virtual void setParent(Node* parent);
|
---|
133 |
|
---|
134 | /** Cached combined orientation.
|
---|
135 | @par
|
---|
136 | This member is the orientation derived by combining the
|
---|
137 | local transformations and those of it's parents.
|
---|
138 | This is updated when _updateFromParent is called by the
|
---|
139 | SceneManager or the nodes parent.
|
---|
140 | */
|
---|
141 | mutable Quaternion mDerivedOrientation;
|
---|
142 |
|
---|
143 | /** Cached combined position.
|
---|
144 | @par
|
---|
145 | This member is the position derived by combining the
|
---|
146 | local transformations and those of it's parents.
|
---|
147 | This is updated when _updateFromParent is called by the
|
---|
148 | SceneManager or the nodes parent.
|
---|
149 | */
|
---|
150 | mutable Vector3 mDerivedPosition;
|
---|
151 |
|
---|
152 | /** Cached combined scale.
|
---|
153 | @par
|
---|
154 | This member is the position derived by combining the
|
---|
155 | local transformations and those of it's parents.
|
---|
156 | This is updated when _updateFromParent is called by the
|
---|
157 | SceneManager or the nodes parent.
|
---|
158 | */
|
---|
159 | mutable Vector3 mDerivedScale;
|
---|
160 |
|
---|
161 | /** Triggers the node to update it's combined transforms.
|
---|
162 | @par
|
---|
163 | This method is called internally by Ogre to ask the node
|
---|
164 | to update it's complete transformation based on it's parents
|
---|
165 | derived transform.
|
---|
166 | */
|
---|
167 | virtual void _updateFromParent(void) const;
|
---|
168 |
|
---|
169 | /** Internal method for creating a new child node - must be overridden per subclass. */
|
---|
170 | virtual Node* createChildImpl(void) = 0;
|
---|
171 |
|
---|
172 | /** Internal method for creating a new child node - must be overridden per subclass. */
|
---|
173 | virtual Node* createChildImpl(const String& name) = 0;
|
---|
174 |
|
---|
175 | /// The position to use as a base for keyframe animation
|
---|
176 | Vector3 mInitialPosition;
|
---|
177 | /// The orientation to use as a base for keyframe animation
|
---|
178 | Quaternion mInitialOrientation;
|
---|
179 | /// The scale to use as a base for keyframe animation
|
---|
180 | Vector3 mInitialScale;
|
---|
181 |
|
---|
182 | // Weight of applied animations so far, used for blending
|
---|
183 | Real mAccumAnimWeight;
|
---|
184 | // The total weighted translation from the initial state so far
|
---|
185 | Vector3 mTransFromInitial;
|
---|
186 | // The total weighted rotation from the initial state so far
|
---|
187 | Quaternion mRotFromInitial;
|
---|
188 | // The total weighted scale from the initial state so far
|
---|
189 | Vector3 mScaleFromInitial;
|
---|
190 |
|
---|
191 | /// Cached derived transform as a 4x4 matrix
|
---|
192 | mutable Matrix4 mCachedTransform;
|
---|
193 | mutable bool mCachedTransformOutOfDate;
|
---|
194 |
|
---|
195 | /** Node listener - only one allowed (no list) for size & performance reasons. */
|
---|
196 | Listener* mListener;
|
---|
197 |
|
---|
198 | typedef std::vector<Node*> QueuedUpdates;
|
---|
199 | static QueuedUpdates msQueuedUpdates;
|
---|
200 |
|
---|
201 |
|
---|
202 | public:
|
---|
203 | /** Constructor, should only be called by parent, not directly.
|
---|
204 | @remarks
|
---|
205 | Generates a name.
|
---|
206 | */
|
---|
207 | Node();
|
---|
208 | /** Constructor, should only be called by parent, not directly.
|
---|
209 | @remarks
|
---|
210 | Assigned a name.
|
---|
211 | */
|
---|
212 | Node(const String& name);
|
---|
213 |
|
---|
214 | virtual ~Node();
|
---|
215 |
|
---|
216 | /** Returns the name of the node. */
|
---|
217 | const String& getName(void) const;
|
---|
218 |
|
---|
219 | /** Gets this node's parent (NULL if this is the root).
|
---|
220 | */
|
---|
221 | virtual Node* getParent(void) const;
|
---|
222 |
|
---|
223 | /** Returns a quaternion representing the nodes orientation.
|
---|
224 | */
|
---|
225 | virtual const Quaternion & getOrientation() const;
|
---|
226 |
|
---|
227 | /** Sets the orientation of this node via a quaternion.
|
---|
228 | @remarks
|
---|
229 | Orientatings, unlike other transforms, are not always inherited by child nodes.
|
---|
230 | Whether or not orientatings affect the orientation of the child nodes depends on
|
---|
231 | the setInheritOrientation option of the child. In some cases you want a orientating
|
---|
232 | of a parent node to apply to a child node (e.g. where the child node is a part of
|
---|
233 | the same object, so you want it to be the same relative orientation based on the
|
---|
234 | parent's orientation), but not in other cases (e.g. where the child node is just
|
---|
235 | for positioning another object, you want it to maintain it's own orientation).
|
---|
236 | The default is to inherit as with other transforms.
|
---|
237 | @par
|
---|
238 | Note that rotations are oriented around the node's origin.
|
---|
239 | */
|
---|
240 | virtual void setOrientation( const Quaternion& q );
|
---|
241 |
|
---|
242 | /** Sets the orientation of this node via quaternion parameters.
|
---|
243 | @remarks
|
---|
244 | Orientatings, unlike other transforms, are not always inherited by child nodes.
|
---|
245 | Whether or not orientatings affect the orientation of the child nodes depends on
|
---|
246 | the setInheritOrientation option of the child. In some cases you want a orientating
|
---|
247 | of a parent node to apply to a child node (e.g. where the child node is a part of
|
---|
248 | the same object, so you want it to be the same relative orientation based on the
|
---|
249 | parent's orientation), but not in other cases (e.g. where the child node is just
|
---|
250 | for positioning another object, you want it to maintain it's own orientation).
|
---|
251 | The default is to inherit as with other transforms.
|
---|
252 | @par
|
---|
253 | Note that rotations are oriented around the node's origin.
|
---|
254 | */
|
---|
255 | virtual void setOrientation( Real w, Real x, Real y, Real z);
|
---|
256 |
|
---|
257 | /** Resets the nodes orientation (local axes as world axes, no rotation).
|
---|
258 | @remarks
|
---|
259 | Orientatings, unlike other transforms, are not always inherited by child nodes.
|
---|
260 | Whether or not orientatings affect the orientation of the child nodes depends on
|
---|
261 | the setInheritOrientation option of the child. In some cases you want a orientating
|
---|
262 | of a parent node to apply to a child node (e.g. where the child node is a part of
|
---|
263 | the same object, so you want it to be the same relative orientation based on the
|
---|
264 | parent's orientation), but not in other cases (e.g. where the child node is just
|
---|
265 | for positioning another object, you want it to maintain it's own orientation).
|
---|
266 | The default is to inherit as with other transforms.
|
---|
267 | @par
|
---|
268 | Note that rotations are oriented around the node's origin.
|
---|
269 | */
|
---|
270 | virtual void resetOrientation(void);
|
---|
271 |
|
---|
272 | /** Sets the position of the node relative to it's parent.
|
---|
273 | */
|
---|
274 | virtual void setPosition(const Vector3& pos);
|
---|
275 |
|
---|
276 | /** Sets the position of the node relative to it's parent.
|
---|
277 | */
|
---|
278 | virtual void setPosition(Real x, Real y, Real z);
|
---|
279 |
|
---|
280 | /** Gets the position of the node relative to it's parent.
|
---|
281 | */
|
---|
282 | virtual const Vector3 & getPosition(void) const;
|
---|
283 |
|
---|
284 | /** Sets the scaling factor applied to this node.
|
---|
285 | @remarks
|
---|
286 | Scaling factors, unlike other transforms, are not always inherited by child nodes.
|
---|
287 | Whether or not scalings affect the size of the child nodes depends on the setInheritScale
|
---|
288 | option of the child. In some cases you want a scaling factor of a parent node to apply to
|
---|
289 | a child node (e.g. where the child node is a part of the same object, so you want it to be
|
---|
290 | the same relative size based on the parent's size), but not in other cases (e.g. where the
|
---|
291 | child node is just for positioning another object, you want it to maintain it's own size).
|
---|
292 | The default is to inherit as with other transforms.
|
---|
293 | @par
|
---|
294 | Note that like rotations, scalings are oriented around the node's origin.
|
---|
295 | */
|
---|
296 | virtual void setScale(const Vector3& scale);
|
---|
297 |
|
---|
298 | /** Sets the scaling factor applied to this node.
|
---|
299 | @remarks
|
---|
300 | Scaling factors, unlike other transforms, are not always inherited by child nodes.
|
---|
301 | Whether or not scalings affect the size of the child nodes depends on the setInheritScale
|
---|
302 | option of the child. In some cases you want a scaling factor of a parent node to apply to
|
---|
303 | a child node (e.g. where the child node is a part of the same object, so you want it to be
|
---|
304 | the same relative size based on the parent's size), but not in other cases (e.g. where the
|
---|
305 | child node is just for positioning another object, you want it to maintain it's own size).
|
---|
306 | The default is to inherit as with other transforms.
|
---|
307 | @par
|
---|
308 | Note that like rotations, scalings are oriented around the node's origin.
|
---|
309 | */
|
---|
310 | virtual void setScale(Real x, Real y, Real z);
|
---|
311 |
|
---|
312 | /** Gets the scaling factor of this node.
|
---|
313 | */
|
---|
314 | virtual const Vector3 & getScale(void) const;
|
---|
315 |
|
---|
316 | /** Tells the node whether it should inherit orientation from it's parent node.
|
---|
317 | @remarks
|
---|
318 | Orientatings, unlike other transforms, are not always inherited by child nodes.
|
---|
319 | Whether or not orientatings affect the orientation of the child nodes depends on
|
---|
320 | the setInheritOrientation option of the child. In some cases you want a orientating
|
---|
321 | of a parent node to apply to a child node (e.g. where the child node is a part of
|
---|
322 | the same object, so you want it to be the same relative orientation based on the
|
---|
323 | parent's orientation), but not in other cases (e.g. where the child node is just
|
---|
324 | for positioning another object, you want it to maintain it's own orientation).
|
---|
325 | The default is to inherit as with other transforms.
|
---|
326 | @param inherit If true, this node's orientation will be affected by its parent's orientation.
|
---|
327 | If false, it will not be affected.
|
---|
328 | */
|
---|
329 | virtual void setInheritOrientation(bool inherit);
|
---|
330 |
|
---|
331 | /** Returns true if this node is affected by orientation applied to the parent node.
|
---|
332 | @remarks
|
---|
333 | Orientatings, unlike other transforms, are not always inherited by child nodes.
|
---|
334 | Whether or not orientatings affect the orientation of the child nodes depends on
|
---|
335 | the setInheritOrientation option of the child. In some cases you want a orientating
|
---|
336 | of a parent node to apply to a child node (e.g. where the child node is a part of
|
---|
337 | the same object, so you want it to be the same relative orientation based on the
|
---|
338 | parent's orientation), but not in other cases (e.g. where the child node is just
|
---|
339 | for positioning another object, you want it to maintain it's own orientation).
|
---|
340 | The default is to inherit as with other transforms.
|
---|
341 | @remarks
|
---|
342 | See setInheritOrientation for more info.
|
---|
343 | */
|
---|
344 | virtual bool getInheritOrientation(void) const;
|
---|
345 |
|
---|
346 | /** Tells the node whether it should inherit scaling factors from it's parent node.
|
---|
347 | @remarks
|
---|
348 | Scaling factors, unlike other transforms, are not always inherited by child nodes.
|
---|
349 | Whether or not scalings affect the size of the child nodes depends on the setInheritScale
|
---|
350 | option of the child. In some cases you want a scaling factor of a parent node to apply to
|
---|
351 | a child node (e.g. where the child node is a part of the same object, so you want it to be
|
---|
352 | the same relative size based on the parent's size), but not in other cases (e.g. where the
|
---|
353 | child node is just for positioning another object, you want it to maintain it's own size).
|
---|
354 | The default is to inherit as with other transforms.
|
---|
355 | @param inherit If true, this node's scale will be affected by its parent's scale. If false,
|
---|
356 | it will not be affected.
|
---|
357 | */
|
---|
358 | virtual void setInheritScale(bool inherit);
|
---|
359 |
|
---|
360 | /** Returns true if this node is affected by scaling factors applied to the parent node.
|
---|
361 | @remarks
|
---|
362 | See setInheritScale for more info.
|
---|
363 | */
|
---|
364 | virtual bool getInheritScale(void) const;
|
---|
365 |
|
---|
366 | /** Scales the node, combining it's current scale with the passed in scaling factor.
|
---|
367 | @remarks
|
---|
368 | This method applies an extra scaling factor to the node's existing scale, (unlike setScale
|
---|
369 | which overwrites it) combining it's current scale with the new one. E.g. calling this
|
---|
370 | method twice with Vector3(2,2,2) would have the same effect as setScale(Vector3(4,4,4)) if
|
---|
371 | the existing scale was 1.
|
---|
372 | @par
|
---|
373 | Note that like rotations, scalings are oriented around the node's origin.
|
---|
374 | */
|
---|
375 | virtual void scale(const Vector3& scale);
|
---|
376 |
|
---|
377 | /** Scales the node, combining it's current scale with the passed in scaling factor.
|
---|
378 | @remarks
|
---|
379 | This method applies an extra scaling factor to the node's existing scale, (unlike setScale
|
---|
380 | which overwrites it) combining it's current scale with the new one. E.g. calling this
|
---|
381 | method twice with Vector3(2,2,2) would have the same effect as setScale(Vector3(4,4,4)) if
|
---|
382 | the existing scale was 1.
|
---|
383 | @par
|
---|
384 | Note that like rotations, scalings are oriented around the node's origin.
|
---|
385 | */
|
---|
386 | virtual void scale(Real x, Real y, Real z);
|
---|
387 |
|
---|
388 | /** Moves the node along the cartesian axes.
|
---|
389 | @par
|
---|
390 | This method moves the node by the supplied vector along the
|
---|
391 | world cartesian axes, i.e. along world x,y,z
|
---|
392 | @param
|
---|
393 | d Vector with x,y,z values representing the translation.
|
---|
394 | @param
|
---|
395 | relativeTo The space which this transform is relative to.
|
---|
396 | */
|
---|
397 | virtual void translate(const Vector3& d, TransformSpace relativeTo = TS_PARENT);
|
---|
398 | /** Moves the node along the cartesian axes.
|
---|
399 | @par
|
---|
400 | This method moves the node by the supplied vector along the
|
---|
401 | world cartesian axes, i.e. along world x,y,z
|
---|
402 | @param
|
---|
403 | x
|
---|
404 | @param
|
---|
405 | y
|
---|
406 | @param
|
---|
407 | z Real x, y and z values representing the translation.
|
---|
408 | @param
|
---|
409 | relativeTo The space which this transform is relative to.
|
---|
410 | */
|
---|
411 | virtual void translate(Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
|
---|
412 | /** Moves the node along arbitrary axes.
|
---|
413 | @remarks
|
---|
414 | This method translates the node by a vector which is relative to
|
---|
415 | a custom set of axes.
|
---|
416 | @param
|
---|
417 | axes A 3x3 Matrix containg 3 column vectors each representing the
|
---|
418 | axes X, Y and Z respectively. In this format the standard cartesian
|
---|
419 | axes would be expressed as:
|
---|
420 | <pre>
|
---|
421 | 1 0 0
|
---|
422 | 0 1 0
|
---|
423 | 0 0 1
|
---|
424 | </pre>
|
---|
425 | i.e. the identity matrix.
|
---|
426 | @param
|
---|
427 | move Vector relative to the axes above.
|
---|
428 | @param
|
---|
429 | relativeTo The space which this transform is relative to.
|
---|
430 | */
|
---|
431 | virtual void translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo = TS_PARENT);
|
---|
432 | /** Moves the node along arbitrary axes.
|
---|
433 | @remarks
|
---|
434 | This method translates the node by a vector which is relative to
|
---|
435 | a custom set of axes.
|
---|
436 | @param
|
---|
437 | axes A 3x3 Matrix containg 3 column vectors each representing the
|
---|
438 | axes X, Y and Z respectively. In this format the standard cartesian
|
---|
439 | axes would be expressed as
|
---|
440 | <pre>
|
---|
441 | 1 0 0
|
---|
442 | 0 1 0
|
---|
443 | 0 0 1
|
---|
444 | </pre>
|
---|
445 | i.e. the identity matrix.
|
---|
446 | @param
|
---|
447 | x,y,z Translation components relative to the axes above.
|
---|
448 | @param
|
---|
449 | relativeTo The space which this transform is relative to.
|
---|
450 | */
|
---|
451 | virtual void translate(const Matrix3& axes, Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
|
---|
452 |
|
---|
453 | /** Rotate the node around the Z-axis.
|
---|
454 | */
|
---|
455 | virtual void roll(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
|
---|
456 | #ifndef OGRE_FORCE_ANGLE_TYPES
|
---|
457 | inline void roll(Real degrees, TransformSpace relativeTo = TS_LOCAL) {
|
---|
458 | roll ( Angle(degrees), relativeTo );
|
---|
459 | }
|
---|
460 | #endif//OGRE_FORCE_ANGLE_TYPES
|
---|
461 |
|
---|
462 | /** Rotate the node around the X-axis.
|
---|
463 | */
|
---|
464 | virtual void pitch(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
|
---|
465 | #ifndef OGRE_FORCE_ANGLE_TYPES
|
---|
466 | inline void pitch(Real degrees, TransformSpace relativeTo = TS_LOCAL) {
|
---|
467 | pitch ( Angle(degrees), relativeTo );
|
---|
468 | }
|
---|
469 | #endif//OGRE_FORCE_ANGLE_TYPES
|
---|
470 |
|
---|
471 | /** Rotate the node around the Y-axis.
|
---|
472 | */
|
---|
473 | virtual void yaw(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
|
---|
474 | #ifndef OGRE_FORCE_ANGLE_TYPES
|
---|
475 | inline void yaw(Real degrees, TransformSpace relativeTo = TS_LOCAL) {
|
---|
476 | yaw ( Angle(degrees), relativeTo );
|
---|
477 | }
|
---|
478 | #endif//OGRE_FORCE_ANGLE_TYPES
|
---|
479 |
|
---|
480 | /** Rotate the node around an arbitrary axis.
|
---|
481 | */
|
---|
482 | virtual void rotate(const Vector3& axis, const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
|
---|
483 | #ifndef OGRE_FORCE_ANGLE_TYPES
|
---|
484 | inline void rotate(const Vector3& axis, Real degrees, TransformSpace relativeTo = TS_LOCAL) {
|
---|
485 | rotate ( axis, Angle(degrees), relativeTo );
|
---|
486 | }
|
---|
487 | #endif//OGRE_FORCE_ANGLE_TYPES
|
---|
488 |
|
---|
489 | /** Rotate the node around an aritrary axis using a Quarternion.
|
---|
490 | */
|
---|
491 | virtual void rotate(const Quaternion& q, TransformSpace relativeTo = TS_LOCAL);
|
---|
492 |
|
---|
493 | /** Gets a matrix whose columns are the local axes based on
|
---|
494 | the nodes orientation relative to it's parent. */
|
---|
495 | virtual Matrix3 getLocalAxes(void) const;
|
---|
496 |
|
---|
497 | /** Creates an unnamed new Node as a child of this node.
|
---|
498 | @param
|
---|
499 | translate Initial translation offset of child relative to parent
|
---|
500 | @param
|
---|
501 | rotate Initial rotation relative to parent
|
---|
502 | */
|
---|
503 | virtual Node* createChild(
|
---|
504 | const Vector3& translate = Vector3::ZERO,
|
---|
505 | const Quaternion& rotate = Quaternion::IDENTITY );
|
---|
506 |
|
---|
507 | /** Creates a new named Node as a child of this node.
|
---|
508 | @remarks
|
---|
509 | This creates a child node with a given name, which allows you to look the node up from
|
---|
510 | the parent which holds this collection of nodes.
|
---|
511 | @param
|
---|
512 | translate Initial translation offset of child relative to parent
|
---|
513 | @param
|
---|
514 | rotate Initial rotation relative to parent
|
---|
515 | */
|
---|
516 | virtual Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
|
---|
517 |
|
---|
518 | /** Adds a (precreated) child scene node to this node. If it is attached to another node,
|
---|
519 | it must be detached first.
|
---|
520 | @param child The Node which is to become a child node of this one
|
---|
521 | */
|
---|
522 | virtual void addChild(Node* child);
|
---|
523 |
|
---|
524 | /** Reports the number of child nodes under this one.
|
---|
525 | */
|
---|
526 | virtual unsigned short numChildren(void) const;
|
---|
527 |
|
---|
528 | /** Gets a pointer to a child node.
|
---|
529 | @remarks
|
---|
530 | There is an alternate getChild method which returns a named child.
|
---|
531 | */
|
---|
532 | virtual Node* getChild(unsigned short index) const;
|
---|
533 |
|
---|
534 | /** Gets a pointer to a named child node.
|
---|
535 | */
|
---|
536 | virtual Node* getChild(const String& name) const;
|
---|
537 |
|
---|
538 | /** Retrieves an iterator for efficiently looping through all children of this node.
|
---|
539 | @remarks
|
---|
540 | Using this is faster than repeatedly calling getChild if you want to go through
|
---|
541 | all (or most of) the children of this node.
|
---|
542 | Note that the returned iterator is only valid whilst no children are added or
|
---|
543 | removed from this node. Thus you should not store this returned iterator for
|
---|
544 | later use, nor should you add / remove children whilst iterating through it;
|
---|
545 | store up changes for later. Note that calling methods on returned items in
|
---|
546 | the iterator IS allowed and does not invalidate the iterator.
|
---|
547 | */
|
---|
548 | virtual ChildNodeIterator getChildIterator(void);
|
---|
549 |
|
---|
550 | /** Retrieves an iterator for efficiently looping through all children of this node.
|
---|
551 | @remarks
|
---|
552 | Using this is faster than repeatedly calling getChild if you want to go through
|
---|
553 | all (or most of) the children of this node.
|
---|
554 | Note that the returned iterator is only valid whilst no children are added or
|
---|
555 | removed from this node. Thus you should not store this returned iterator for
|
---|
556 | later use, nor should you add / remove children whilst iterating through it;
|
---|
557 | store up changes for later. Note that calling methods on returned items in
|
---|
558 | the iterator IS allowed and does not invalidate the iterator.
|
---|
559 | */
|
---|
560 | virtual ConstChildNodeIterator getChildIterator(void) const;
|
---|
561 |
|
---|
562 | /** Drops the specified child from this node.
|
---|
563 | @remarks
|
---|
564 | Does not delete the node, just detaches it from
|
---|
565 | this parent, potentially to be reattached elsewhere.
|
---|
566 | There is also an alternate version which drops a named
|
---|
567 | child from this node.
|
---|
568 | */
|
---|
569 | virtual Node* removeChild(unsigned short index);
|
---|
570 | /** Drops the specified child from this node.
|
---|
571 | @remarks
|
---|
572 | Does not delete the node, just detaches it from
|
---|
573 | this parent, potentially to be reattached elsewhere.
|
---|
574 | There is also an alternate version which drops a named
|
---|
575 | child from this node.
|
---|
576 | */
|
---|
577 | virtual Node* removeChild(Node* child);
|
---|
578 |
|
---|
579 | /** Drops the named child from this node.
|
---|
580 | @remarks
|
---|
581 | Does not delete the node, just detaches it from
|
---|
582 | this parent, potentially to be reattached elsewhere.
|
---|
583 | */
|
---|
584 | virtual Node* removeChild(const String& name);
|
---|
585 | /** Removes all child Nodes attached to this node. Does not delete the nodes, just detaches them from
|
---|
586 | this parent, potentially to be reattached elsewhere.
|
---|
587 | */
|
---|
588 | virtual void removeAllChildren(void);
|
---|
589 |
|
---|
590 | /** Gets the orientation of the node as derived from all parents.
|
---|
591 | */
|
---|
592 | virtual const Quaternion & _getDerivedOrientation(void) const;
|
---|
593 |
|
---|
594 | /** Gets the position of the node as derived from all parents.
|
---|
595 | */
|
---|
596 | virtual const Vector3 & _getDerivedPosition(void) const;
|
---|
597 |
|
---|
598 | /** Gets the scaling factor of the node as derived from all parents.
|
---|
599 | */
|
---|
600 | virtual const Vector3 & _getDerivedScale(void) const;
|
---|
601 |
|
---|
602 | /** Gets the full transformation matrix for this node.
|
---|
603 | @remarks
|
---|
604 | This method returns the full transformation matrix
|
---|
605 | for this node, including the effect of any parent node
|
---|
606 | transformations, provided they have been updated using the Node::_update method.
|
---|
607 | This should only be called by a SceneManager which knows the
|
---|
608 | derived transforms have been updated before calling this method.
|
---|
609 | Applications using Ogre should just use the relative transforms.
|
---|
610 | */
|
---|
611 | virtual Matrix4 _getFullTransform(void) const;
|
---|
612 |
|
---|
613 | /** Internal method to update the Node.
|
---|
614 | @note
|
---|
615 | Updates this node and any relevant children to incorporate transforms etc.
|
---|
616 | Don't call this yourself unless you are writing a SceneManager implementation.
|
---|
617 | @param
|
---|
618 | updateChildren If true, the update cascades down to all children. Specify false if you wish to
|
---|
619 | update children separately, e.g. because of a more selective SceneManager implementation.
|
---|
620 | @param
|
---|
621 | parentHasChanged This flag indicates that the parent xform has changed,
|
---|
622 | so the child should retrieve the parent's xform and combine it with its own
|
---|
623 | even if it hasn't changed itself.
|
---|
624 | */
|
---|
625 | virtual void _update(bool updateChildren, bool parentHasChanged);
|
---|
626 |
|
---|
627 | /** Sets a listener for this Node.
|
---|
628 | @remarks
|
---|
629 | Note for size and performance reasons only one listener per node is
|
---|
630 | allowed.
|
---|
631 | */
|
---|
632 | virtual void setListener(Listener* listener) { mListener = listener; }
|
---|
633 |
|
---|
634 | /** Gets the current listener for this Node.
|
---|
635 | */
|
---|
636 | virtual Listener* getListener(void) const { return mListener; }
|
---|
637 |
|
---|
638 | /** Overridden from Renderable.
|
---|
639 | @remarks
|
---|
640 | This is only used if the SceneManager chooses to render the node. This option can be set
|
---|
641 | for SceneNodes at SceneManager::setDisplaySceneNodes, and for entities based on skeletal
|
---|
642 | models using Entity::setDisplayBones()
|
---|
643 | */
|
---|
644 | const MaterialPtr& getMaterial(void) const;
|
---|
645 | /** Overridden from Renderable.
|
---|
646 | @remarks
|
---|
647 | This is only used if the SceneManager chooses to render the node. This option can be set
|
---|
648 | for SceneNodes at SceneManager::setDisplaySceneNodes, and for entities based on skeletal
|
---|
649 | models using Entity::setDisplaySkeleton()
|
---|
650 | */
|
---|
651 | void getRenderOperation(RenderOperation& op);
|
---|
652 | /** Overridden from Renderable.
|
---|
653 | @remarks
|
---|
654 | This is only used if the SceneManager chooses to render the node. This option can be set
|
---|
655 | for SceneNodes at SceneManager::setDisplaySceneNodes, and for entities based on skeletal
|
---|
656 | models using Entity::setDisplaySkeleton()
|
---|
657 | */
|
---|
658 | void getWorldTransforms(Matrix4* xform) const;
|
---|
659 | /** @copydoc Renderable::getWorldOrientation */
|
---|
660 | const Quaternion& getWorldOrientation(void) const;
|
---|
661 | /** @copydoc Renderable::getWorldPosition */
|
---|
662 | const Vector3& getWorldPosition(void) const;
|
---|
663 |
|
---|
664 | /** Sets the current transform of this node to be the 'initial state' ie that
|
---|
665 | position / orientation / scale to be used as a basis for delta values used
|
---|
666 | in keyframe animation.
|
---|
667 | @remarks
|
---|
668 | You never need to call this method unless you plan to animate this node. If you do
|
---|
669 | plan to animate it, call this method once you've loaded the node with it's base state,
|
---|
670 | ie the state on which all keyframes are based.
|
---|
671 | @par
|
---|
672 | If you never call this method, the initial state is the identity transform, ie do nothing.
|
---|
673 | */
|
---|
674 | virtual void setInitialState(void);
|
---|
675 |
|
---|
676 | /** Resets the position / orientation / scale of this node to it's initial state, see setInitialState for more info. */
|
---|
677 | virtual void resetToInitialState(void);
|
---|
678 |
|
---|
679 | /** Gets the initial position of this node, see setInitialState for more info.
|
---|
680 | @remarks
|
---|
681 | Also resets the cumulative animation weight used for blending.
|
---|
682 | */
|
---|
683 | virtual const Vector3& getInitialPosition(void) const;
|
---|
684 |
|
---|
685 | /** Gets the initial orientation of this node, see setInitialState for more info. */
|
---|
686 | virtual const Quaternion& getInitialOrientation(void) const;
|
---|
687 |
|
---|
688 | /** Gets the initial position of this node, see setInitialState for more info. */
|
---|
689 | virtual const Vector3& getInitialScale(void) const;
|
---|
690 |
|
---|
691 | /** Internal weighted transform method.
|
---|
692 | @remarks
|
---|
693 | This method transforms a Node by a weighted amount from it's
|
---|
694 | initial state. If weighted transforms have already been applied,
|
---|
695 | the previous transforms and this one are blended together based
|
---|
696 | on their relative weight. This method should not be used in
|
---|
697 | combination with the unweighted rotate, translate etc methods.
|
---|
698 | */
|
---|
699 | virtual void _weightedTransform(Real weight, const Vector3& translate,
|
---|
700 | const Quaternion& rotate, const Vector3& scale);
|
---|
701 |
|
---|
702 | /** Overridden, see Renderable */
|
---|
703 | Real getSquaredViewDepth(const Camera* cam) const;
|
---|
704 |
|
---|
705 | /** To be called in the event of transform changes to this node that require it's recalculation.
|
---|
706 | @remarks
|
---|
707 | This not only tags the node state as being 'dirty', it also requests it's parent to
|
---|
708 | know about it's dirtiness so it will get an update next time.
|
---|
709 | @param forceParentUpdate Even if the node thinks it has already told it's
|
---|
710 | parent, tell it anyway
|
---|
711 | */
|
---|
712 | virtual void needUpdate(bool forceParentUpdate = false);
|
---|
713 | /** Called by children to notify their parent that they need an update.
|
---|
714 | @param forceParentUpdate Even if the node thinks it has already told it's
|
---|
715 | parent, tell it anyway
|
---|
716 | */
|
---|
717 | virtual void requestUpdate(Node* child, bool forceParentUpdate = false);
|
---|
718 | /** Called by children to notify their parent that they no longer need an update. */
|
---|
719 | virtual void cancelUpdate(Node* child);
|
---|
720 |
|
---|
721 | /** Queue a 'needUpdate' call to a node safely.
|
---|
722 | @ramarks
|
---|
723 | You can't call needUpdate() during the scene graph update, e.g. in
|
---|
724 | response to a Node::Listener hook, because the graph is already being
|
---|
725 | updated, and update flag changes cannot be made reliably in that context.
|
---|
726 | Call this method if you need to queue a needUpdate call in this case.
|
---|
727 | */
|
---|
728 | static void queueNeedUpdate(Node* n);
|
---|
729 | /** Process queued 'needUpdate' calls. */
|
---|
730 | static void processQueuedUpdates(void);
|
---|
731 |
|
---|
732 | /** @copydoc Renderable::getLights */
|
---|
733 | const LightList& getLights(void) const;
|
---|
734 |
|
---|
735 |
|
---|
736 |
|
---|
737 | };
|
---|
738 |
|
---|
739 | } //namespace
|
---|
740 |
|
---|
741 | #endif
|
---|