OgreNode.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _Node_H__
29 #define _Node_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreCommon.h"
34 #include "OgreMatrix3.h"
35 #include "OgreMatrix4.h"
36 #include "OgreQuaternion.h"
37 #include "OgreString.h"
38 #include "OgreRenderable.h"
39 #include "OgreIteratorWrappers.h"
40 #include "OgreMesh.h"
41 #include "OgreUserObjectBindings.h"
42 #include "OgreHeaderPrefix.h"
43 
44 namespace Ogre {
45 
46  class NameGenerator;
47 
64  class _OgreExport Node : public NodeAlloc
65  {
66  public:
70  {
76  TS_WORLD
77  };
78  typedef HashMap<String, Node*> ChildNodeMap;
81 
85  {
86  public:
87  Listener() {}
88  virtual ~Listener() {}
96  virtual void nodeUpdated(const Node*) {}
98  virtual void nodeDestroyed(const Node*) {}
100  virtual void nodeAttached(const Node*) {}
102  virtual void nodeDetached(const Node*) {}
103  };
104 
106  class DebugRenderable : public Renderable, public NodeAlloc
107  {
108  protected:
113  public:
114  DebugRenderable(Node* parent);
115  ~DebugRenderable();
116  const MaterialPtr& getMaterial(void) const;
117  void getRenderOperation(RenderOperation& op);
118  void getWorldTransforms(Matrix4* xform) const;
119  Real getSquaredViewDepth(const Camera* cam) const;
120  const LightList& getLights(void) const;
121  void setScaling(Real s) { mScaling = s; }
122 
123  };
124 
125  protected:
130 
135  mutable bool mNeedParentUpdate;
137  mutable bool mNeedChildUpdate;
139  mutable bool mParentNotified ;
141  mutable bool mQueuedForUpdate;
142 
145 
148 
151 
154 
157 
160 
163 
165  virtual void setParent(Node* parent);
166 
175 
184 
193 
200  virtual void _updateFromParent(void) const;
201 
208  virtual void updateFromParentImpl(void) const;
209 
210 
212  virtual Node* createChildImpl(void) = 0;
213 
215  virtual Node* createChildImpl(const String& name) = 0;
216 
223 
227 
230 
233 
235 
238 
239  public:
244  Node();
249  Node(const String& name);
250 
251  virtual ~Node();
252 
254  const String& getName(void) const;
255 
258  virtual Node* getParent(void) const;
259 
262  virtual const Quaternion & getOrientation() const;
263 
277  virtual void setOrientation( const Quaternion& q );
278 
292  virtual void setOrientation( Real w, Real x, Real y, Real z);
293 
307  virtual void resetOrientation(void);
308 
311  virtual void setPosition(const Vector3& pos);
312 
315  virtual void setPosition(Real x, Real y, Real z);
316 
319  virtual const Vector3 & getPosition(void) const;
320 
333  virtual void setScale(const Vector3& scale);
334 
347  virtual void setScale(Real x, Real y, Real z);
348 
351  virtual const Vector3 & getScale(void) const;
352 
366  virtual void setInheritOrientation(bool inherit);
367 
381  virtual bool getInheritOrientation(void) const;
382 
395  virtual void setInheritScale(bool inherit);
396 
401  virtual bool getInheritScale(void) const;
402 
412  virtual void scale(const Vector3& scale);
413 
423  virtual void scale(Real x, Real y, Real z);
424 
434  virtual void translate(const Vector3& d, TransformSpace relativeTo = TS_PARENT);
448  virtual void translate(Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
468  virtual void translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo = TS_PARENT);
492  virtual void translate(const Matrix3& axes, Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
493 
496  virtual void roll(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
497 
500  virtual void pitch(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
501 
504  virtual void yaw(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
505 
508  virtual void rotate(const Vector3& axis, const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
509 
512  virtual void rotate(const Quaternion& q, TransformSpace relativeTo = TS_LOCAL);
513 
516  virtual Matrix3 getLocalAxes(void) const;
517 
524  virtual Node* createChild(
525  const Vector3& translate = Vector3::ZERO,
526  const Quaternion& rotate = Quaternion::IDENTITY );
527 
537  virtual Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
538 
543  virtual void addChild(Node* child);
544 
547  virtual unsigned short numChildren(void) const;
548 
553  virtual Node* getChild(unsigned short index) const;
554 
557  virtual Node* getChild(const String& name) const;
558 
569  virtual ChildNodeIterator getChildIterator(void);
570 
581  virtual ConstChildNodeIterator getChildIterator(void) const;
582 
590  virtual Node* removeChild(unsigned short index);
598  virtual Node* removeChild(Node* child);
599 
605  virtual Node* removeChild(const String& name);
609  virtual void removeAllChildren(void);
610 
615  virtual void _setDerivedPosition(const Vector3& pos);
616 
622  virtual void _setDerivedOrientation(const Quaternion& q);
623 
626  virtual const Quaternion & _getDerivedOrientation(void) const;
627 
630  virtual const Vector3 & _getDerivedPosition(void) const;
631 
634  virtual const Vector3 & _getDerivedScale(void) const;
635 
645  virtual const Matrix4& _getFullTransform(void) const;
646 
659  virtual void _update(bool updateChildren, bool parentHasChanged);
660 
666  virtual void setListener(Listener* listener) { mListener = listener; }
667 
670  virtual Listener* getListener(void) const { return mListener; }
671 
672 
683  virtual void setInitialState(void);
684 
686  virtual void resetToInitialState(void);
687 
692  virtual const Vector3& getInitialPosition(void) const;
693 
695  virtual Vector3 convertWorldToLocalPosition( const Vector3 &worldPos );
696 
699  virtual Vector3 convertLocalToWorldPosition( const Vector3 &localPos );
700 
702  virtual Quaternion convertWorldToLocalOrientation( const Quaternion &worldOrientation );
703 
706  virtual Quaternion convertLocalToWorldOrientation( const Quaternion &localOrientation );
707 
709  virtual const Quaternion& getInitialOrientation(void) const;
710 
712  virtual const Vector3& getInitialScale(void) const;
713 
715  virtual Real getSquaredViewDepth(const Camera* cam) const;
716 
724  virtual void needUpdate(bool forceParentUpdate = false);
729  virtual void requestUpdate(Node* child, bool forceParentUpdate = false);
731  virtual void cancelUpdate(Node* child);
732 
734  virtual DebugRenderable* getDebugRenderable(Real scaling);
735 
743  static void queueNeedUpdate(Node* n);
745  static void processQueuedUpdates(void);
746 
747 
755  virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); }
756 
760  virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); }
761 
766  UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
767 
772  const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
773 
774  };
778 } // namespace Ogre
779 
780 #include "OgreHeaderSuffix.h"
781 
782 #endif // _Node_H__

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 16 2013 14:35:43