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 
00040 
00051     class _OgreExport Node : public Renderable
00052     {
00053     public:
00056         enum TransformSpace
00057         {
00059             TS_LOCAL,
00061             TS_PARENT,
00063             TS_WORLD
00064         };
00065         typedef HashMap<String, Node*, _StringHash> ChildNodeMap;
00066         typedef MapIterator<ChildNodeMap> ChildNodeIterator;
00067 
00068     protected:
00070         Node* mParent;
00072         ChildNodeMap mChildren;
00073 
00074         typedef std::set<Node*> ChildUpdateSet;
00076         mutable ChildUpdateSet mChildrenToUpdate;
00078         mutable bool mNeedParentUpdate;
00080         mutable bool mNeedChildUpdate;
00082         mutable bool mParentNotified ;
00083 
00085         String mName;
00086 
00088         static unsigned long msNextGeneratedNameExt;
00089 
00091         Quaternion mOrientation;
00092 
00094         Vector3 mPosition;
00095 
00097         Vector3 mScale;
00098 
00100         bool mInheritScale;
00101 
00103         void setParent(Node* parent);
00104 
00112         mutable Quaternion mDerivedOrientation;
00113 
00121         mutable Vector3 mDerivedPosition;
00122 
00130         mutable Vector3 mDerivedScale;
00131 
00138         virtual void _updateFromParent(void) const;
00139 
00141         virtual Node* createChildImpl(void) = 0;
00142 
00144         virtual Node* createChildImpl(const String& name) = 0;
00145 
00152         void makeTransform(
00153             const Vector3& position, 
00154             const Vector3& scale, 
00155             const Quaternion& orientation, 
00156             Matrix4& destMatrix ) const;
00157 
00163         void makeInverseTransform(
00164             const Vector3& position, 
00165             const Vector3& scale, 
00166             const Quaternion& orientation, 
00167             Matrix4& destMatrix );
00168 
00170         Vector3 mInitialPosition;
00172         Quaternion mInitialOrientation;
00174         Vector3 mInitialScale;
00175 
00176         // Weight of applied animations so far, used for blending
00177         Real mAccumAnimWeight;
00178         // The total weighted translation from the initial state so far
00179         Vector3 mTransFromInitial;
00180         // The total weighted rotation from the initial state so far
00181         Quaternion mRotFromInitial;
00182         // The total weighted scale from the initial state so far
00183         Vector3 mScaleFromInitial;
00184 
00186         mutable Matrix4 mCachedTransform;
00187         mutable bool mCachedTransformOutOfDate;
00188 
00189 
00190     public:
00195         Node();
00200         Node(const String& name);
00201 
00202         virtual ~Node();  
00203 
00205         const String& getName(void) const;
00206 
00209         virtual Node* getParent(void) const;
00210 
00213         virtual const Quaternion & getOrientation() const;
00214 
00217         virtual void setOrientation( const Quaternion& q );
00218 
00221         virtual void setOrientation( Real w, Real x, Real y, Real z);
00222 
00225         virtual void resetOrientation(void);
00226 
00229         virtual void setPosition(const Vector3& pos);
00230 
00233         virtual void setPosition(Real x, Real y, Real z);
00234 
00237         virtual const Vector3 & getPosition(void) const;
00238 
00252         virtual void setScale(const Vector3& scale);
00253 
00267         virtual void setScale(Real x, Real y, Real z);
00268 
00271         virtual const Vector3 & getScale(void) const;
00272 
00286         virtual void setInheritScale(bool inherit);
00287 
00292         virtual bool getInheritScale(void) const;
00293 
00303         virtual void scale(const Vector3& scale);
00304 
00314         virtual void scale(Real x, Real y, Real z);
00315 
00325         virtual void translate(const Vector3& d, TransformSpace relativeTo = TS_PARENT);
00339         virtual void translate(Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
00359         virtual void translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo = TS_PARENT);
00379         virtual void translate(const Matrix3& axes, Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
00380 
00383         virtual void roll(Real degrees, TransformSpace relativeTo = TS_LOCAL);
00384 
00387         virtual void pitch(Real degrees, TransformSpace relativeTo = TS_LOCAL);
00388 
00391         virtual void yaw(Real degrees, TransformSpace relativeTo = TS_LOCAL);
00392 
00395         virtual void rotate(const Vector3& axis, Real degrees, TransformSpace relativeTo = TS_LOCAL);
00396 
00399         virtual void rotate(const Quaternion& q, TransformSpace relativeTo = TS_LOCAL);
00400 
00403         virtual Matrix3 getLocalAxes(void) const;
00404 
00411         virtual Node* createChild(
00412             const Vector3& translate = Vector3::ZERO, 
00413             const Quaternion& rotate = Quaternion::IDENTITY );
00414 
00424         virtual Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
00425 
00428         virtual void addChild(Node* child);
00429 
00432         virtual unsigned short numChildren(void) const;
00433 
00438         virtual Node* getChild(unsigned short index) const;    
00439 
00442         virtual Node* getChild(const String& name) const;
00443 
00454         virtual ChildNodeIterator getChildIterator(void);
00455 
00463         virtual Node* removeChild(unsigned short index);
00464 
00470         virtual Node* removeChild(const String& name);
00474         virtual void removeAllChildren(void);
00475 
00478         virtual const Quaternion & _getDerivedOrientation(void) const;
00479 
00482         virtual const Vector3 & _getDerivedPosition(void) const;
00483 
00486         virtual const Vector3 & _getDerivedScale(void) const;
00487 
00497         virtual Matrix4 _getFullTransform(void) const;
00498 
00511         virtual void _update(bool updateChildren, bool parentHasChanged);
00512 
00519         Material* getMaterial(void) const;
00526         void getRenderOperation(RenderOperation& op);
00533         void getWorldTransforms(Matrix4* xform) const;
00535         const Quaternion& getWorldOrientation(void) const;
00537         const Vector3& getWorldPosition(void) const;
00538 
00549         virtual void setInitialState(void);
00550 
00552         virtual void resetToInitialState(void);
00553 
00558         virtual const Vector3& getInitialPosition(void) const;
00559 
00561         virtual const Quaternion& getInitialOrientation(void) const;
00562 
00564         virtual const Vector3& getInitialScale(void) const;
00565 
00574         virtual void _weightedTransform(Real weight, const Vector3& translate, 
00575             const Quaternion& rotate, const Vector3& scale);
00576 
00578         Real getSquaredViewDepth(const Camera* cam) const;
00579 
00585         virtual void needUpdate();
00587         virtual void requestUpdate(Node* child);
00589         virtual void cancelUpdate(Node* child);
00590 
00592         const LightList& getLights(void) const
00593         {
00594             // Nodes should not be lit by the scene, this will not get called
00595             static LightList ll;
00596             return ll;
00597         }
00598 
00599 
00600 
00601     };
00602 
00603 } //namespace
00604 
00605 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:28 2004