Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   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 © 2000-2002 The OGRE Team
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 */
00025 #ifndef _Node_H__
00026 #define _Node_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 
00030 #include "OgreMatrix3.h"
00031 #include "OgreMatrix4.h"
00032 #include "OgreQuaternion.h"
00033 #include "OgreAxisAlignedBox.h"
00034 #include "OgreString.h"
00035 #include "OgreRenderable.h"
00036 #include "OgreIteratorWrappers.h"
00037 
00038 namespace Ogre {
00039 
00050     class _OgreExport Node : public Renderable
00051     {
00052     public:
00053         typedef HashMap<String, Node*, _StringHash> ChildNodeMap;
00054         typedef MapIterator<ChildNodeMap> ChildNodeIterator;
00055 
00056     protected:
00058         Node* mParent;
00060         ChildNodeMap mChildren;
00061 
00062         typedef std::set<Node*> ChildUpdateSet;
00064         mutable ChildUpdateSet mChildrenToUpdate;
00066         mutable bool mNeedParentUpdate;
00068         mutable bool mNeedChildUpdate;
00070         mutable bool mParentNotified ;
00071 
00073         String mName;
00074 
00076         static unsigned long msNextGeneratedNameExt;
00077 
00079         Quaternion mOrientation;
00080 
00082         Vector3 mPosition;
00083 
00085         Vector3 mScale;
00086 
00088         bool mInheritScale;
00089 
00091         void setParent(Node* parent);
00092 
00100         mutable Quaternion mDerivedOrientation;
00101 
00109         mutable Vector3 mDerivedPosition;
00110 
00118         mutable Vector3 mDerivedScale;
00119 
00126         virtual void _updateFromParent(void) const;
00127 
00129         virtual Node* createChildImpl(void) = 0;
00130 
00132         virtual Node* createChildImpl(const String& name) = 0;
00133 
00140         void makeTransform(
00141             const Vector3& position, 
00142             const Vector3& scale, 
00143             const Quaternion& orientation, 
00144             Matrix4& destMatrix ) const;
00145 
00151         void makeInverseTransform(
00152             const Vector3& position, 
00153             const Vector3& scale, 
00154             const Quaternion& orientation, 
00155             Matrix4& destMatrix );
00156 
00158         Vector3 mInitialPosition;
00160         Quaternion mInitialOrientation;
00162         Vector3 mInitialScale;
00163 
00164         // Weight of applied animations so far, used for blending
00165         Real mAccumAnimWeight;
00166         // The total weighted translation from the initial state so far
00167         Vector3 mTransFromInitial;
00168         // The total weighted rotation from the initial state so far
00169         Quaternion mRotFromInitial;
00170         // The total weighted scale from the initial state so far
00171         Vector3 mScaleFromInitial;
00172 
00174         mutable Matrix4 mCachedTransform;
00175         mutable bool mCachedTransformOutOfDate;
00176 
00177 
00178     public:
00183         Node();
00188         Node(const String& name);
00189 
00190         virtual ~Node();  
00191 
00193         const String& getName(void) const;
00194 
00197         virtual Node* getParent(void) const;
00198 
00201         virtual const Quaternion & getOrientation() const;
00202 
00205         virtual void setOrientation( const Quaternion& q );
00206 
00209         virtual void setOrientation( Real w, Real x, Real y, Real z);
00210 
00213         virtual void resetOrientation(void);
00214 
00217         virtual void setPosition(const Vector3& pos);
00218 
00221         virtual void setPosition(Real x, Real y, Real z);
00222 
00225         virtual const Vector3 & getPosition(void) const;
00226 
00240         virtual void setScale(const Vector3& scale);
00241 
00255         virtual void setScale(Real x, Real y, Real z);
00256 
00259         virtual const Vector3 & getScale(void) const;
00260 
00274         virtual void setInheritScale(bool inherit);
00275 
00280         virtual bool getInheritScale(void) const;
00281 
00291         virtual void scale(const Vector3& scale);
00292 
00302         virtual void scale(Real x, Real y, Real z);
00303 
00311         virtual void translate(const Vector3& d);
00323         virtual void translate(Real x, Real y, Real z);
00341         virtual void translate(const Matrix3& axes, const Vector3& move);
00359         virtual void translate(const Matrix3& axes, Real x, Real y, Real z);
00360 
00363         virtual void roll(Real degrees);
00364 
00367         virtual void pitch(Real degrees);
00368 
00371         virtual void yaw(Real degrees);
00372 
00375         virtual void rotate(const Vector3& axis, Real degrees);
00376 
00379         virtual void rotate(const Quaternion& q);
00380 
00383         virtual Matrix3 getLocalAxes(void) const;
00384 
00391         virtual Node* createChild(
00392             const Vector3& translate = Vector3::ZERO, 
00393             const Quaternion& rotate = Quaternion::IDENTITY );
00394 
00404         virtual Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
00405 
00408         virtual void addChild(Node* child);
00409 
00412         virtual unsigned short numChildren(void) const;
00413 
00418         virtual Node* getChild(unsigned short index) const;    
00419 
00422         virtual Node* getChild(const String& name) const;
00423 
00434         virtual ChildNodeIterator getChildIterator(void);
00435 
00443         virtual Node* removeChild(unsigned short index);
00444 
00450         virtual Node* removeChild(const String& name);
00454         virtual void removeAllChildren(void);
00455 
00458         virtual const Quaternion & _getDerivedOrientation(void) const;
00459 
00462         virtual const Vector3 & _getDerivedPosition(void) const;
00463 
00466         virtual const Vector3 & _getDerivedScale(void) const;
00467 
00477         virtual Matrix4 _getFullTransform(void) const;
00478 
00491         virtual void _update(bool updateChildren, bool parentHasChanged);
00492 
00499         Material* getMaterial(void) const;
00506         void getRenderOperation(RenderOperation& op);
00513         void getWorldTransforms(Matrix4* xform) const;
00515         const Quaternion& getWorldOrientation(void) const;
00517         const Vector3& getWorldPosition(void) const;
00518 
00529         virtual void setInitialState(void);
00530 
00532         virtual void resetToInitialState(void);
00533 
00538         virtual const Vector3& getInitialPosition(void) const;
00539 
00541         virtual const Quaternion& getInitialOrientation(void) const;
00542 
00544         virtual const Vector3& getInitialScale(void) const;
00545 
00554         virtual void _weightedTransform(Real weight, const Vector3& translate, 
00555             const Quaternion& rotate, const Vector3& scale);
00556 
00558         Real getSquaredViewDepth(const Camera* cam) const;
00559 
00565         virtual void needUpdate();
00567         virtual void requestUpdate(Node* child);
00569         virtual void cancelUpdate(Node* child);
00570 
00572         const LightList& getLights(void) const
00573         {
00574             // Nodes should not be lit by the scene, this will not get called
00575             static LightList ll;
00576             return ll;
00577         }
00578 
00579 
00580 
00581     };
00582 
00583 } //namespace
00584 
00585 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:19 2004