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://ogre.sourceforge.net/
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 
00063         mutable std::list<Node*> mChildrenToUpdate;
00065         mutable bool mNeedUpdate;
00066 
00068         String mName;
00069 
00071         static unsigned long msNextGeneratedNameExt;
00072 
00074         Quaternion mOrientation;
00075 
00077         Vector3 mPosition;
00078 
00080         Vector3 mScale;
00081 
00083         bool mInheritScale;
00084 
00086         void setParent(Node* parent);
00087 
00095         mutable Quaternion mDerivedOrientation;
00096 
00104         mutable Vector3 mDerivedPosition;
00105 
00113         mutable Vector3 mDerivedScale;
00114 
00121         virtual void _updateFromParent(void) const;
00122 
00124         virtual Node* createChildImpl(void) = 0;
00125 
00127         virtual Node* createChildImpl(const String& name) = 0;
00128 
00135         void makeTransform(
00136             const Vector3& position, 
00137             const Vector3& scale, 
00138             const Quaternion& orientation, 
00139             Matrix4& destMatrix );
00140 
00146         void makeInverseTransform(
00147             const Vector3& position, 
00148             const Vector3& scale, 
00149             const Quaternion& orientation, 
00150             Matrix4& destMatrix );
00151 
00153         Vector3 mInitialPosition;
00155         Quaternion mInitialOrientation;
00157         Vector3 mInitialScale;
00158 
00159         // Weight of applied animations so far, used for blending
00160         Real mAccumAnimWeight;
00161         // The total weighted translation from the initial state so far
00162         Vector3 mTransFromInitial;
00163         // The total weighted rotation from the initial state so far
00164         Quaternion mRotFromInitial;
00165         // The total weighted scale from the initial state so far
00166         Vector3 mScaleFromInitial;
00167 
00168 
00169     public:
00174         Node();
00179         Node(const String& name);
00180 
00181         virtual ~Node();  
00182 
00184         const String& getName(void) const;
00185 
00188         virtual Node* getParent(void) const;
00189 
00192         virtual const Quaternion & getOrientation() const;
00193 
00196         virtual void setOrientation( const Quaternion& q );
00197 
00200         virtual void resetOrientation(void);
00201 
00204         virtual void setPosition(const Vector3& pos);
00205 
00208         virtual void setPosition(Real x, Real y, Real z);
00209 
00212         virtual const Vector3 & getPosition(void) const;
00213 
00227         virtual void setScale(const Vector3& scale);
00228 
00242         virtual void setScale(Real x, Real y, Real z);
00243 
00246         virtual const Vector3 & getScale(void) const;
00247 
00261         virtual void setInheritScale(bool inherit);
00262 
00267         virtual bool getInheritScale(void) const;
00268 
00278         virtual void scale(const Vector3& scale);
00279 
00289         virtual void scale(Real x, Real y, Real z);
00290 
00298         virtual void translate(const Vector3& d);
00310         virtual void translate(Real x, Real y, Real z);
00328         virtual void translate(const Matrix3& axes, const Vector3& move);
00346         virtual void translate(const Matrix3& axes, Real x, Real y, Real z);
00347 
00350         virtual void roll(Real degrees);
00351 
00354         virtual void pitch(Real degrees);
00355 
00358         virtual void yaw(Real degrees);
00359 
00362         virtual void rotate(const Vector3& axis, Real degrees);
00363 
00366         virtual void rotate(const Quaternion& q);
00367 
00370         virtual Matrix3 getLocalAxes(void);
00371 
00384         Node* createChild(
00385             const Vector3& translate = Vector3::ZERO, 
00386             const Quaternion& rotate = Quaternion::IDENTITY );
00387 
00397         Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
00398 
00401         virtual void addChild(Node* child);
00402 
00405         virtual unsigned short numChildren(void) const;
00406 
00417         Node* getChild(unsigned short index) const;    
00418 
00427         Node* getChild(const String& name) const;
00428 
00439         ChildNodeIterator getChildIterator(void);
00440 
00454         Node* removeChild(unsigned short index);
00455 
00467         Node* removeChild(const String& name);
00471         virtual void removeAllChildren(void);
00472 
00475         virtual const Quaternion & _getDerivedOrientation(void) const;
00476 
00479         virtual const Vector3 & _getDerivedPosition(void) const;
00480 
00483         virtual const Vector3 & _getDerivedScale(void) const;
00484 
00494         virtual Matrix4 _getFullTransform(void);
00495 
00508         virtual void _update(bool updateChildren, bool parentHasChanged);
00509 
00516         Material* getMaterial(void) const;
00523         void getRenderOperation(RenderOperation& rend);
00530         void getWorldTransforms(Matrix4* xform);
00531 
00542         virtual void setInitialState(void);
00543 
00545         virtual void resetToInitialState(void);
00546 
00551         virtual const Vector3& getInitialPosition(void) const;
00552 
00554         virtual const Quaternion& getInitialOrientation(void) const;
00555 
00557         virtual const Vector3& getInitialScale(void) const;
00558 
00567         virtual void _weightedTransform(Real weight, const Vector3& translate, 
00568             const Quaternion& rotate, const Vector3& scale);
00569 
00571         Real getSquaredViewDepth(const Camera* cam) const;
00572 
00578         virtual void needUpdate();
00580         virtual void requestUpdate(Node* child);
00582         virtual void cancelUpdate(Node* child);
00583 
00584 
00585 
00586 
00587     };
00588 
00589 } //namespace
00590 
00591 #endif

Copyright © 2002 by The OGRE Team