Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class 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 (c) 2000-2005 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 "OgreString.h"
00034 #include "OgreRenderable.h"
00035 #include "OgreIteratorWrappers.h"
00036 
00037 namespace Ogre {
00038 
00039 
00050     class _OgreExport Node : public Renderable
00051     {
00052     public:
00055         enum TransformSpace
00056         {
00058             TS_LOCAL,
00060             TS_PARENT,
00062             TS_WORLD
00063         };
00064         typedef HashMap<String, Node*> ChildNodeMap;
00065         typedef MapIterator<ChildNodeMap> ChildNodeIterator;
00066         typedef ConstMapIterator<ChildNodeMap> ConstChildNodeIterator;
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         mutable MaterialPtr mpMaterial;
00104 
00106         virtual void setParent(Node* parent);
00107 
00115         mutable Quaternion mDerivedOrientation;
00116 
00124         mutable Vector3 mDerivedPosition;
00125 
00133         mutable Vector3 mDerivedScale;
00134 
00141         virtual void _updateFromParent(void) const;
00142 
00144         virtual Node* createChildImpl(void) = 0;
00145 
00147         virtual Node* createChildImpl(const String& name) = 0;
00148 
00155         void makeTransform(
00156             const Vector3& position, 
00157             const Vector3& scale, 
00158             const Quaternion& orientation, 
00159             Matrix4& destMatrix ) const;
00160 
00166         void makeInverseTransform(
00167             const Vector3& position, 
00168             const Vector3& scale, 
00169             const Quaternion& orientation, 
00170             Matrix4& destMatrix );
00171 
00173         Vector3 mInitialPosition;
00175         Quaternion mInitialOrientation;
00177         Vector3 mInitialScale;
00178 
00179         // Weight of applied animations so far, used for blending
00180         Real mAccumAnimWeight;
00181         // The total weighted translation from the initial state so far
00182         Vector3 mTransFromInitial;
00183         // The total weighted rotation from the initial state so far
00184         Quaternion mRotFromInitial;
00185         // The total weighted scale from the initial state so far
00186         Vector3 mScaleFromInitial;
00187 
00189         mutable Matrix4 mCachedTransform;
00190         mutable bool mCachedTransformOutOfDate;
00191 
00192 
00193     public:
00198         Node();
00203         Node(const String& name);
00204 
00205         virtual ~Node();  
00206 
00208         const String& getName(void) const;
00209 
00212         virtual Node* getParent(void) const;
00213 
00216         virtual const Quaternion & getOrientation() const;
00217 
00220         virtual void setOrientation( const Quaternion& q );
00221 
00224         virtual void setOrientation( Real w, Real x, Real y, Real z);
00225 
00228         virtual void resetOrientation(void);
00229 
00232         virtual void setPosition(const Vector3& pos);
00233 
00236         virtual void setPosition(Real x, Real y, Real z);
00237 
00240         virtual const Vector3 & getPosition(void) const;
00241 
00255         virtual void setScale(const Vector3& scale);
00256 
00270         virtual void setScale(Real x, Real y, Real z);
00271 
00274         virtual const Vector3 & getScale(void) const;
00275 
00289         virtual void setInheritScale(bool inherit);
00290 
00295         virtual bool getInheritScale(void) const;
00296 
00306         virtual void scale(const Vector3& scale);
00307 
00317         virtual void scale(Real x, Real y, Real z);
00318 
00328         virtual void translate(const Vector3& d, TransformSpace relativeTo = TS_PARENT);
00342         virtual void translate(Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
00362         virtual void translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo = TS_PARENT);
00382         virtual void translate(const Matrix3& axes, Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
00383 
00386         virtual void roll(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
00387 #ifndef OGRE_FORCE_ANGLE_TYPES
00388         inline void roll(Real degrees, TransformSpace relativeTo = TS_LOCAL) {
00389             roll ( Angle(degrees), relativeTo );
00390         }
00391 #endif//OGRE_FORCE_ANGLE_TYPES
00392 
00395         virtual void pitch(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
00396 #ifndef OGRE_FORCE_ANGLE_TYPES
00397         inline void pitch(Real degrees, TransformSpace relativeTo = TS_LOCAL) {
00398             pitch ( Angle(degrees), relativeTo );
00399         }
00400 #endif//OGRE_FORCE_ANGLE_TYPES
00401 
00404         virtual void yaw(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
00405 #ifndef OGRE_FORCE_ANGLE_TYPES
00406         inline void yaw(Real degrees, TransformSpace relativeTo = TS_LOCAL) {
00407             yaw ( Angle(degrees), relativeTo );
00408         }
00409 #endif//OGRE_FORCE_ANGLE_TYPES
00410 
00413         virtual void rotate(const Vector3& axis, const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
00414 #ifndef OGRE_FORCE_ANGLE_TYPES
00415         inline void rotate(const Vector3& axis, Real degrees, TransformSpace relativeTo = TS_LOCAL) {
00416             rotate ( axis, Angle(degrees), relativeTo );
00417         }
00418 #endif//OGRE_FORCE_ANGLE_TYPES
00419 
00422         virtual void rotate(const Quaternion& q, TransformSpace relativeTo = TS_LOCAL);
00423 
00426         virtual Matrix3 getLocalAxes(void) const;
00427 
00434         virtual Node* createChild(
00435             const Vector3& translate = Vector3::ZERO, 
00436             const Quaternion& rotate = Quaternion::IDENTITY );
00437 
00447         virtual Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
00448 
00453         virtual void addChild(Node* child);
00454 
00457         virtual unsigned short numChildren(void) const;
00458 
00463         virtual Node* getChild(unsigned short index) const;    
00464 
00467         virtual Node* getChild(const String& name) const;
00468 
00479         virtual ChildNodeIterator getChildIterator(void);
00480 
00491         virtual ConstChildNodeIterator getChildIterator(void) const;
00492 
00500         virtual Node* removeChild(unsigned short index);
00508         virtual Node* removeChild(Node* child);
00509 
00515         virtual Node* removeChild(const String& name);
00519         virtual void removeAllChildren(void);
00520 
00523         virtual const Quaternion & _getDerivedOrientation(void) const;
00524 
00527         virtual const Vector3 & _getDerivedPosition(void) const;
00528 
00531         virtual const Vector3 & _getDerivedScale(void) const;
00532 
00542         virtual Matrix4 _getFullTransform(void) const;
00543 
00556         virtual void _update(bool updateChildren, bool parentHasChanged);
00557 
00564         const MaterialPtr& getMaterial(void) const;
00571         void getRenderOperation(RenderOperation& op);
00578         void getWorldTransforms(Matrix4* xform) const;
00580         const Quaternion& getWorldOrientation(void) const;
00582         const Vector3& getWorldPosition(void) const;
00583 
00594         virtual void setInitialState(void);
00595 
00597         virtual void resetToInitialState(void);
00598 
00603         virtual const Vector3& getInitialPosition(void) const;
00604 
00606         virtual const Quaternion& getInitialOrientation(void) const;
00607 
00609         virtual const Vector3& getInitialScale(void) const;
00610 
00619         virtual void _weightedTransform(Real weight, const Vector3& translate, 
00620             const Quaternion& rotate, const Vector3& scale);
00621 
00623         Real getSquaredViewDepth(const Camera* cam) const;
00624 
00630         virtual void needUpdate();
00632         virtual void requestUpdate(Node* child);
00634         virtual void cancelUpdate(Node* child);
00635 
00637         const LightList& getLights(void) const;
00638 
00639 
00640 
00641     };
00642 
00643 } //namespace
00644 
00645 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:48 2006