source: GTP/trunk/Lib/Geom/OgreStuff/include/OgreNode.h @ 1809

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