OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreOldNode.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-2014 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 _OldNode_H__
29 #define _OldNode_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 
63  class _OgreExport OldNode : public NodeAlloc
64  {
65  public:
69  {
75  TS_WORLD
76  };
77  typedef HashMap<String, OldNode*> ChildOldNodeMap;
80 
84  {
85  public:
86  Listener() {}
87  virtual ~Listener() {}
95  virtual void OldNodeUpdated(const OldNode*) {}
97  virtual void OldNodeDestroyed(const OldNode*) {}
99  virtual void OldNodeAttached(const OldNode*) {}
101  virtual void OldNodeDetached(const OldNode*) {}
102  };
103 
105  class DebugRenderable : public Renderable, public NodeAlloc
106  {
107  protected:
112  public:
113  DebugRenderable(OldNode* parent);
114  ~DebugRenderable();
115  const MaterialPtr& getMaterial(void) const;
116  void getRenderOperation(RenderOperation& op);
117  void getWorldTransforms(Matrix4* xform) const;
118  Real getSquaredViewDepth(const Camera* cam) const;
119  const LightList& getLights(void) const;
120  void setScaling(Real s) { mScaling = s; }
121 
122  };
123 
124  protected:
129 
134  mutable bool mNeedParentUpdate;
136  mutable bool mNeedChildUpdate;
138  mutable bool mParentNotified ;
140  mutable bool mQueuedForUpdate;
141 
144 
147 
150 
153 
156 
159 
161  virtual void setParent(OldNode* parent);
162 
171 
180 
189 
196  virtual void _updateFromParent(void) const;
197 
204  virtual void updateFromParentImpl(void) const;
205 
206 
208  virtual OldNode* createChildImpl(void) = 0;
209 
211  virtual OldNode* createChildImpl(const String& name) = 0;
212 
219 
223 
226 
229 
231 
234 
235  public:
240  OldNode();
245  OldNode(const String& name);
246 
247  virtual ~OldNode();
248 
250  const String& getName(void) const;
251 
254  virtual OldNode* getParent(void) const;
255 
258  virtual const Quaternion & getOrientation() const;
259 
273  virtual void setOrientation( const Quaternion& q );
274 
288  virtual void setOrientation( Real w, Real x, Real y, Real z);
289 
303  virtual void resetOrientation(void);
304 
307  virtual void setPosition(const Vector3& pos);
308 
311  virtual void setPosition(Real x, Real y, Real z);
312 
315  virtual const Vector3 & getPosition(void) const;
316 
329  virtual void setScale(const Vector3& scale);
330 
343  virtual void setScale(Real x, Real y, Real z);
344 
347  virtual const Vector3 & getScale(void) const;
348 
362  virtual void setInheritOrientation(bool inherit);
363 
377  virtual bool getInheritOrientation(void) const;
378 
391  virtual void setInheritScale(bool inherit);
392 
397  virtual bool getInheritScale(void) const;
398 
408  virtual void scale(const Vector3& scale);
409 
419  virtual void scale(Real x, Real y, Real z);
420 
430  virtual void translate(const Vector3& d, TransformSpace relativeTo = TS_PARENT);
444  virtual void translate(Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
464  virtual void translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo = TS_PARENT);
488  virtual void translate(const Matrix3& axes, Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
489 
492  virtual void roll(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
493 
496  virtual void pitch(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
497 
500  virtual void yaw(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
501 
504  virtual void rotate(const Vector3& axis, const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
505 
508  virtual void rotate(const Quaternion& q, TransformSpace relativeTo = TS_LOCAL);
509 
512  virtual Matrix3 getLocalAxes(void) const;
513 
520  virtual OldNode* createChild(
521  const Vector3& translate = Vector3::ZERO,
522  const Quaternion& rotate = Quaternion::IDENTITY );
523 
533  virtual OldNode* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
534 
539  virtual void addChild(OldNode* child);
540 
543  virtual unsigned short numChildren(void) const;
544 
549  virtual OldNode* getChild(unsigned short index) const;
550 
553  virtual OldNode* getChild(const String& name) const;
554 
565  virtual ChildOldNodeIterator getChildIterator(void);
566 
577  virtual ConstChildOldNodeIterator getChildIterator(void) const;
578 
586  virtual OldNode* removeChild(unsigned short index);
594  virtual OldNode* removeChild(OldNode* child);
595 
601  virtual OldNode* removeChild(const String& name);
605  virtual void removeAllChildren(void);
606 
611  virtual void _setDerivedPosition(const Vector3& pos);
612 
618  virtual void _setDerivedOrientation(const Quaternion& q);
619 
622  virtual const Quaternion & _getDerivedOrientation(void) const;
623 
626  virtual const Vector3 & _getDerivedPosition(void) const;
627 
630  virtual const Vector3 & _getDerivedScale(void) const;
631 
641  virtual const Matrix4& _getFullTransform(void) const;
642 
655  virtual void _update(bool updateChildren, bool parentHasChanged);
656 
662  virtual void setListener(Listener* listener) { mListener = listener; }
663 
666  virtual Listener* getListener(void) const { return mListener; }
667 
668 
679  virtual void setInitialState(void);
680 
682  virtual void resetToInitialState(void);
683 
688  virtual const Vector3& getInitialPosition(void) const;
689 
691  virtual Vector3 convertWorldToLocalPosition( const Vector3 &worldPos );
692 
695  virtual Vector3 convertLocalToWorldPosition( const Vector3 &localPos );
696 
698  virtual Quaternion convertWorldToLocalOrientation( const Quaternion &worldOrientation );
699 
702  virtual Quaternion convertLocalToWorldOrientation( const Quaternion &localOrientation );
703 
705  virtual const Quaternion& getInitialOrientation(void) const;
706 
708  virtual const Vector3& getInitialScale(void) const;
709 
711  virtual Real getSquaredViewDepth(const Camera* cam) const;
712 
720  virtual void needUpdate(bool forceParentUpdate = false);
725  virtual void requestUpdate(OldNode* child, bool forceParentUpdate = false);
727  virtual void cancelUpdate(OldNode* child);
728 
730  virtual DebugRenderable* getDebugRenderable(Real scaling);
731 
739  static void queueNeedUpdate(OldNode* n);
741  static void processQueuedUpdates(void);
742 
743 
751  virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); }
752 
756  virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); }
757 
762  UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
763 
768  const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
769 
770  };
774 } // namespace Ogre
775 
776 #include "OgreHeaderSuffix.h"
777 
778 #endif // _OldNode_H__
Vector3 mDerivedScale
Cached combined scale.
Definition: OgreOldNode.h:188
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
TransformSpace
Enumeration denoting the spaces which a transform can be relative to.
Definition: OgreOldNode.h:68
UserObjectBindings & getUserObjectBindings()
Return an instance of user objects binding associated with this class.
Definition: OgreOldNode.h:762
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
Variant type that can hold Any other type.
Definition: OgreAny.h:54
std::vector< T, A > type
ConstMapIterator< ChildOldNodeMap > ConstChildOldNodeIterator
Definition: OgreOldNode.h:79
virtual Listener * getListener(void) const
Gets the current listener for this OldNode.
Definition: OgreOldNode.h:666
OldNode * mParent
Pointer to parent OldNode.
Definition: OgreOldNode.h:126
static const Vector3 ZERO
Definition: OgreVector3.h:807
A 3x3 matrix which can represent rotations around axes.
Definition: OgreMatrix3.h:68
virtual void setUserAny(const Any &anything)
Definition: OgreOldNode.h:751
bool mQueuedForUpdate
Flag indicating that the OldNode has been queued for update.
Definition: OgreOldNode.h:140
Vector3 mScale
Stores the scaling factor applied to this OldNode.
Definition: OgreOldNode.h:152
Vector3 mInitialPosition
The position to use as a base for keyframe animation.
Definition: OgreOldNode.h:214
bool mInheritOrientation
Stores whether this OldNode inherits orientation from it's parent.
Definition: OgreOldNode.h:155
Quaternion mInitialOrientation
The orientation to use as a base for keyframe animation.
Definition: OgreOldNode.h:216
Abstract class defining the interface all renderable objects must implement.
Class representing a general-purpose OldNode an articulated scene graph.
Definition: OgreOldNode.h:63
Implementation of a Quaternion, i.e.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
bool mInheritScale
Stores whether this OldNode inherits scale from it's parent.
Definition: OgreOldNode.h:158
DebugRenderable * mDebug
Definition: OgreOldNode.h:230
ChildUpdateSet mChildrenToUpdate
List of children which need updating, used if self is not out of date but children are...
Definition: OgreOldNode.h:132
static const Quaternion IDENTITY
static QueuedUpdates msQueuedUpdates
Definition: OgreOldNode.h:228
MapIterator< ChildOldNodeMap > ChildOldNodeIterator
Definition: OgreOldNode.h:78
String mName
Friendly name of this OldNode, can be automatically generated if you don't care.
Definition: OgreOldNode.h:143
const UserObjectBindings & getUserObjectBindings() const
Return an instance of user objects binding associated with this class.
Definition: OgreOldNode.h:768
virtual void OldNodeDestroyed(const OldNode *)
OldNode is being destroyed.
Definition: OgreOldNode.h:97
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Quaternion mDerivedOrientation
Cached combined orientation.
Definition: OgreOldNode.h:170
virtual void OldNodeUpdated(const OldNode *)
Called when a OldNode gets updated.
Definition: OgreOldNode.h:95
Matrix4 mCachedTransform
Cached derived transform as a 4x4 matrix.
Definition: OgreOldNode.h:221
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
ChildOldNodeMap mChildren
Collection of pointers to direct children; hashmap for efficiency.
Definition: OgreOldNode.h:128
'New' rendering operation using vertex buffers.
Vector3 mInitialScale
The scale to use as a base for keyframe animation.
Definition: OgreOldNode.h:218
virtual const Any & getUserAny(void) const
Definition: OgreOldNode.h:756
bool mCachedTransformOutOfDate
Definition: OgreOldNode.h:222
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:49
Vector3 mDerivedPosition
Cached combined position.
Definition: OgreOldNode.h:179
Vector3 mPosition
Stores the position/translation of the OldNode relative to its parent.
Definition: OgreOldNode.h:149
Concrete IteratorWrapper for const access to the underlying key-value container.
HashMap< String, OldNode * > ChildOldNodeMap
Definition: OgreOldNode.h:77
virtual void setListener(Listener *listener)
Sets a listener for this OldNode.
Definition: OgreOldNode.h:662
Listener * mListener
OldNode listener - only one allowed (no list) for size & performance reasons.
Definition: OgreOldNode.h:225
_StringBase String
Definition: OgreCommon.h:53
Inner class for displaying debug renderable for OldNode.
Definition: OgreOldNode.h:105
bool mNeedChildUpdate
Flag indicating that all children need to be updated.
Definition: OgreOldNode.h:136
Transform is relative to the local space.
Definition: OgreOldNode.h:71
bool mParentNotified
Flag indicating that parent has been notified about update request.
Definition: OgreOldNode.h:138
virtual void OldNodeAttached(const OldNode *)
OldNode has been attached to a parent.
Definition: OgreOldNode.h:99
Listener which gets called back on OldNode events.
Definition: OgreOldNode.h:83
Quaternion mOrientation
Stores the orientation of the OldNode relative to it's parent.
Definition: OgreOldNode.h:146
virtual void OldNodeDetached(const OldNode *)
OldNode has been detached from a parent.
Definition: OgreOldNode.h:101
UserObjectBindings mUserObjectBindings
User objects binding.
Definition: OgreOldNode.h:233
bool mNeedParentUpdate
Flag to indicate own transform from parent is out of date.
Definition: OgreOldNode.h:134
Transform is relative to the space of the parent OldNode.
Definition: OgreOldNode.h:73
vector< OldNode * >::type QueuedUpdates
Definition: OgreOldNode.h:227
Class that provides convenient interface to establish a linkage between custom user application objec...
set< OldNode * >::type ChildUpdateSet
Definition: OgreOldNode.h:130