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 00067 protected: 00069 Node* mParent; 00071 ChildNodeMap mChildren; 00072 00073 typedef std::set<Node*> ChildUpdateSet; 00075 mutable ChildUpdateSet mChildrenToUpdate; 00077 mutable bool mNeedParentUpdate; 00079 mutable bool mNeedChildUpdate; 00081 mutable bool mParentNotified ; 00082 00084 String mName; 00085 00087 static unsigned long msNextGeneratedNameExt; 00088 00090 Quaternion mOrientation; 00091 00093 Vector3 mPosition; 00094 00096 Vector3 mScale; 00097 00099 bool mInheritScale; 00100 00102 mutable MaterialPtr mpMaterial; 00103 00105 virtual void setParent(Node* parent); 00106 00114 mutable Quaternion mDerivedOrientation; 00115 00123 mutable Vector3 mDerivedPosition; 00124 00132 mutable Vector3 mDerivedScale; 00133 00140 virtual void _updateFromParent(void) const; 00141 00143 virtual Node* createChildImpl(void) = 0; 00144 00146 virtual Node* createChildImpl(const String& name) = 0; 00147 00154 void makeTransform( 00155 const Vector3& position, 00156 const Vector3& scale, 00157 const Quaternion& orientation, 00158 Matrix4& destMatrix ) const; 00159 00165 void makeInverseTransform( 00166 const Vector3& position, 00167 const Vector3& scale, 00168 const Quaternion& orientation, 00169 Matrix4& destMatrix ); 00170 00172 Vector3 mInitialPosition; 00174 Quaternion mInitialOrientation; 00176 Vector3 mInitialScale; 00177 00178 // Weight of applied animations so far, used for blending 00179 Real mAccumAnimWeight; 00180 // The total weighted translation from the initial state so far 00181 Vector3 mTransFromInitial; 00182 // The total weighted rotation from the initial state so far 00183 Quaternion mRotFromInitial; 00184 // The total weighted scale from the initial state so far 00185 Vector3 mScaleFromInitial; 00186 00188 mutable Matrix4 mCachedTransform; 00189 mutable bool mCachedTransformOutOfDate; 00190 00191 00192 public: 00197 Node(); 00202 Node(const String& name); 00203 00204 virtual ~Node(); 00205 00207 const String& getName(void) const; 00208 00211 virtual Node* getParent(void) const; 00212 00215 virtual const Quaternion & getOrientation() const; 00216 00219 virtual void setOrientation( const Quaternion& q ); 00220 00223 virtual void setOrientation( Real w, Real x, Real y, Real z); 00224 00227 virtual void resetOrientation(void); 00228 00231 virtual void setPosition(const Vector3& pos); 00232 00235 virtual void setPosition(Real x, Real y, Real z); 00236 00239 virtual const Vector3 & getPosition(void) const; 00240 00254 virtual void setScale(const Vector3& scale); 00255 00269 virtual void setScale(Real x, Real y, Real z); 00270 00273 virtual const Vector3 & getScale(void) const; 00274 00288 virtual void setInheritScale(bool inherit); 00289 00294 virtual bool getInheritScale(void) const; 00295 00305 virtual void scale(const Vector3& scale); 00306 00316 virtual void scale(Real x, Real y, Real z); 00317 00327 virtual void translate(const Vector3& d, TransformSpace relativeTo = TS_PARENT); 00341 virtual void translate(Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT); 00361 virtual void translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo = TS_PARENT); 00381 virtual void translate(const Matrix3& axes, Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT); 00382 00385 virtual void roll(const Radian& angle, TransformSpace relativeTo = TS_LOCAL); 00386 #ifndef OGRE_FORCE_ANGLE_TYPES 00387 inline void roll(Real degrees, TransformSpace relativeTo = TS_LOCAL) { 00388 roll ( Angle(degrees), relativeTo ); 00389 } 00390 #endif//OGRE_FORCE_ANGLE_TYPES 00391 00394 virtual void pitch(const Radian& angle, TransformSpace relativeTo = TS_LOCAL); 00395 #ifndef OGRE_FORCE_ANGLE_TYPES 00396 inline void pitch(Real degrees, TransformSpace relativeTo = TS_LOCAL) { 00397 pitch ( Angle(degrees), relativeTo ); 00398 } 00399 #endif//OGRE_FORCE_ANGLE_TYPES 00400 00403 virtual void yaw(const Radian& angle, TransformSpace relativeTo = TS_LOCAL); 00404 #ifndef OGRE_FORCE_ANGLE_TYPES 00405 inline void yaw(Real degrees, TransformSpace relativeTo = TS_LOCAL) { 00406 yaw ( Angle(degrees), relativeTo ); 00407 } 00408 #endif//OGRE_FORCE_ANGLE_TYPES 00409 00412 virtual void rotate(const Vector3& axis, const Radian& angle, TransformSpace relativeTo = TS_LOCAL); 00413 #ifndef OGRE_FORCE_ANGLE_TYPES 00414 inline void rotate(const Vector3& axis, Real degrees, TransformSpace relativeTo = TS_LOCAL) { 00415 rotate ( axis, Angle(degrees), relativeTo ); 00416 } 00417 #endif//OGRE_FORCE_ANGLE_TYPES 00418 00421 virtual void rotate(const Quaternion& q, TransformSpace relativeTo = TS_LOCAL); 00422 00425 virtual Matrix3 getLocalAxes(void) const; 00426 00433 virtual Node* createChild( 00434 const Vector3& translate = Vector3::ZERO, 00435 const Quaternion& rotate = Quaternion::IDENTITY ); 00436 00446 virtual Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY); 00447 00451 virtual void addChild(Node* child); 00452 00455 virtual unsigned short numChildren(void) const; 00456 00461 virtual Node* getChild(unsigned short index) const; 00462 00465 virtual Node* getChild(const String& name) const; 00466 00477 virtual ChildNodeIterator getChildIterator(void); 00478 00486 virtual Node* removeChild(unsigned short index); 00494 virtual Node* removeChild(Node* child); 00495 00501 virtual Node* removeChild(const String& name); 00505 virtual void removeAllChildren(void); 00506 00509 virtual const Quaternion & _getDerivedOrientation(void) const; 00510 00513 virtual const Vector3 & _getDerivedPosition(void) const; 00514 00517 virtual const Vector3 & _getDerivedScale(void) const; 00518 00528 virtual Matrix4 _getFullTransform(void) const; 00529 00542 virtual void _update(bool updateChildren, bool parentHasChanged); 00543 00550 const MaterialPtr& getMaterial(void) const; 00557 void getRenderOperation(RenderOperation& op); 00564 void getWorldTransforms(Matrix4* xform) const; 00566 const Quaternion& getWorldOrientation(void) const; 00568 const Vector3& getWorldPosition(void) const; 00569 00580 virtual void setInitialState(void); 00581 00583 virtual void resetToInitialState(void); 00584 00589 virtual const Vector3& getInitialPosition(void) const; 00590 00592 virtual const Quaternion& getInitialOrientation(void) const; 00593 00595 virtual const Vector3& getInitialScale(void) const; 00596 00605 virtual void _weightedTransform(Real weight, const Vector3& translate, 00606 const Quaternion& rotate, const Vector3& scale); 00607 00609 Real getSquaredViewDepth(const Camera* cam) const; 00610 00616 virtual void needUpdate(); 00618 virtual void requestUpdate(Node* child); 00620 virtual void cancelUpdate(Node* child); 00621 00623 const LightList& getLights(void) const; 00624 00625 00626 00627 }; 00628 00629 } //namespace 00630 00631 #endif
Copyright © 2000-2005 by The OGRE Team
Last modified Sun Apr 10 23:21:18 2005