- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

# OgreNode.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef _Node_H__
    00030 #define _Node_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033
    00034 #include "OgreMatrix3.h"
    00035 #include "OgreMatrix4.h"
    00036 #include "OgreQuaternion.h"
    00037 #include "OgreString.h"
    00038 #include "OgreRenderable.h"
    00039 #include "OgreIteratorWrappers.h"
    00040
    00041 namespace Ogre {
    00042
    00043
    00054     class _OgreExport Node : public Renderable
    00055     {
    00056     public:
    00059         enum TransformSpace
    00060         {
    00062             TS_LOCAL,
    00064             TS_PARENT,
    00066             TS_WORLD
    00067         };
    00068         typedef HashMap<String, Node*> ChildNodeMap;
    00069         typedef MapIterator<ChildNodeMap> ChildNodeIterator;
    00070         typedef ConstMapIterator<ChildNodeMap> ConstChildNodeIterator;
    00071
    00074         class _OgreExport Listener
    00075         {
    00076         public:
    00077             Listener() {}
    00078             virtual ~Listener() {}
    00086             virtual void nodeUpdated(const Node*) {}
    00088             virtual void nodeDestroyed(const Node*) {};
    00090             virtual void nodeAttached(const Node*) {};
    00092             virtual void nodeDetached(const Node*) {};
    00093         };
    00094
    00095     protected:
    00097         Node* mParent;
    00099         ChildNodeMap mChildren;
    00100
    00101         typedef std::set<Node*> ChildUpdateSet;
    00103         mutable ChildUpdateSet mChildrenToUpdate;
    00105         mutable bool mNeedParentUpdate;
    00107         mutable bool mNeedChildUpdate;
    00109         mutable bool mParentNotified ;
    00111         mutable bool mQueuedForUpdate;
    00112
    00114         String mName;
    00115
    00117         static unsigned long msNextGeneratedNameExt;
    00118
    00120         Quaternion mOrientation;
    00121
    00123         Vector3 mPosition;
    00124
    00126         Vector3 mScale;
    00127
    00129         bool mInheritOrientation;
    00130
    00132         bool mInheritScale;
    00133
    00135         mutable MaterialPtr mpMaterial;
    00136
    00138         virtual void setParent(Node* parent);
    00139
    00147         mutable Quaternion mDerivedOrientation;
    00148
    00156         mutable Vector3 mDerivedPosition;
    00157
    00165         mutable Vector3 mDerivedScale;
    00166
    00173         virtual void _updateFromParent(void) const;
    00174
    00181         virtual void updateFromParentImpl(void) const;
    00182
    00183
    00185         virtual Node* createChildImpl(void) = 0;
    00186
    00188         virtual Node* createChildImpl(const String& name) = 0;
    00189
    00191         Vector3 mInitialPosition;
    00193         Quaternion mInitialOrientation;
    00195         Vector3 mInitialScale;
    00196
    00198         mutable Matrix4 mCachedTransform;
    00199         mutable bool mCachedTransformOutOfDate;
    00200
    00202         Listener* mListener;
    00203
    00204         typedef std::vector<Node*> QueuedUpdates;
    00205         static QueuedUpdates msQueuedUpdates;
    00206
    00207
    00208     public:
    00213         Node();
    00218         Node(const String& name);
    00219
    00220         virtual ~Node();
    00221
    00223         const String& getName(void) const;
    00224
    00227         virtual Node* getParent(void) const;
    00228
    00231         virtual const Quaternion & getOrientation() const;
    00232
    00246         virtual void setOrientation( const Quaternion& q );
    00247
    00261         virtual void setOrientation( Real w, Real x, Real y, Real z);
    00262
    00276         virtual void resetOrientation(void);
    00277
    00280         virtual void setPosition(const Vector3& pos);
    00281
    00284         virtual void setPosition(Real x, Real y, Real z);
    00285
    00288         virtual const Vector3 & getPosition(void) const;
    00289
    00302         virtual void setScale(const Vector3& scale);
    00303
    00316         virtual void setScale(Real x, Real y, Real z);
    00317
    00320         virtual const Vector3 & getScale(void) const;
    00321
    00335         virtual void setInheritOrientation(bool inherit);
    00336
    00350         virtual bool getInheritOrientation(void) const;
    00351
    00364         virtual void setInheritScale(bool inherit);
    00365
    00370         virtual bool getInheritScale(void) const;
    00371
    00381         virtual void scale(const Vector3& scale);
    00382
    00392         virtual void scale(Real x, Real y, Real z);
    00393
    00403         virtual void translate(const Vector3& d, TransformSpace relativeTo = TS_PARENT);
    00417         virtual void translate(Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
    00437         virtual void translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo = TS_PARENT);
    00457         virtual void translate(const Matrix3& axes, Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
    00458
    00461         virtual void roll(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
    00462 #ifndef OGRE_FORCE_ANGLE_TYPES
    00463         inline void roll(Real degrees, TransformSpace relativeTo = TS_LOCAL) {
    00464             roll ( Angle(degrees), relativeTo );
    00465         }
    00466 #endif//OGRE_FORCE_ANGLE_TYPES
    00467
    00470         virtual void pitch(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
    00471 #ifndef OGRE_FORCE_ANGLE_TYPES
    00472         inline void pitch(Real degrees, TransformSpace relativeTo = TS_LOCAL) {
    00473             pitch ( Angle(degrees), relativeTo );
    00474         }
    00475 #endif//OGRE_FORCE_ANGLE_TYPES
    00476
    00479         virtual void yaw(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
    00480 #ifndef OGRE_FORCE_ANGLE_TYPES
    00481         inline void yaw(Real degrees, TransformSpace relativeTo = TS_LOCAL) {
    00482             yaw ( Angle(degrees), relativeTo );
    00483         }
    00484 #endif//OGRE_FORCE_ANGLE_TYPES
    00485
    00488         virtual void rotate(const Vector3& axis, const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
    00489 #ifndef OGRE_FORCE_ANGLE_TYPES
    00490         inline void rotate(const Vector3& axis, Real degrees, TransformSpace relativeTo = TS_LOCAL) {
    00491             rotate ( axis, Angle(degrees), relativeTo );
    00492         }
    00493 #endif//OGRE_FORCE_ANGLE_TYPES
    00494
    00497         virtual void rotate(const Quaternion& q, TransformSpace relativeTo = TS_LOCAL);
    00498
    00501         virtual Matrix3 getLocalAxes(void) const;
    00502
    00509         virtual Node* createChild(
    00510             const Vector3& translate = Vector3::ZERO,
    00511             const Quaternion& rotate = Quaternion::IDENTITY );
    00512
    00522         virtual Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
    00523
    00528         virtual void addChild(Node* child);
    00529
    00532         virtual unsigned short numChildren(void) const;
    00533
    00538         virtual Node* getChild(unsigned short index) const;
    00539
    00542         virtual Node* getChild(const String& name) const;
    00543
    00554         virtual ChildNodeIterator getChildIterator(void);
    00555
    00566         virtual ConstChildNodeIterator getChildIterator(void) const;
    00567
    00575         virtual Node* removeChild(unsigned short index);
    00583         virtual Node* removeChild(Node* child);
    00584
    00590         virtual Node* removeChild(const String& name);
    00594         virtual void removeAllChildren(void);
    00595
    00598         virtual const Quaternion & _getDerivedOrientation(void) const;
    00599
    00602         virtual const Vector3 & _getDerivedPosition(void) const;
    00603
    00606         virtual const Vector3 & _getDerivedScale(void) const;
    00607
    00617         virtual const Matrix4& _getFullTransform(void) const;
    00618
    00631         virtual void _update(bool updateChildren, bool parentHasChanged);
    00632
    00638         virtual void setListener(Listener* listener) { mListener = listener; }
    00639
    00642         virtual Listener* getListener(void) const { return mListener; }
    00643
    00650         const MaterialPtr& getMaterial(void) const;
    00657         void getRenderOperation(RenderOperation& op);
    00664         void getWorldTransforms(Matrix4* xform) const;
    00666         const Quaternion& getWorldOrientation(void) const;
    00668         const Vector3& getWorldPosition(void) const;
    00669
    00680         virtual void setInitialState(void);
    00681
    00683         virtual void resetToInitialState(void);
    00684
    00689         virtual const Vector3& getInitialPosition(void) const;
    00690
    00692         virtual const Quaternion& getInitialOrientation(void) const;
    00693
    00695         virtual const Vector3& getInitialScale(void) const;
    00696
    00698         Real getSquaredViewDepth(const Camera* cam) const;
    00699
    00707         virtual void needUpdate(bool forceParentUpdate = false);
    00712         virtual void requestUpdate(Node* child, bool forceParentUpdate = false);
    00714         virtual void cancelUpdate(Node* child);
    00715
    00723         static void queueNeedUpdate(Node* n);
    00725         static void processQueuedUpdates(void);
    00726
    00728         const LightList& getLights(void) const;
    00729
    00730
    00731
    00732     };
    00733
    00734 } //namespace
    00735
    00736 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Mon Jun 16 12:48:53 2008