OgreNode.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _Node_H__
#define _Node_H__
#include "OgrePrerequisites.h"
#include "OgreCommon.h"
#include "OgreMatrix3.h"
#include "OgreMatrix4.h"
#include "OgreQuaternion.h"
#include "OgreString.h"
#include "OgreRenderable.h"
#include "OgreIteratorWrappers.h"
#include "OgreMesh.h"
#include "OgreUserObjectBindings.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class NameGenerator;
class _OgreExport Node : public NodeAlloc
{
public:
enum TransformSpace
{
TS_LOCAL,
TS_PARENT,
TS_WORLD
};
typedef HashMap<String, Node*> ChildNodeMap;
typedef MapIterator<ChildNodeMap> ChildNodeIterator;
typedef ConstMapIterator<ChildNodeMap> ConstChildNodeIterator;
class _OgreExport Listener
{
public:
Listener() {}
virtual ~Listener() {}
virtual void nodeUpdated(const Node*) {}
virtual void nodeDestroyed(const Node*) {}
virtual void nodeAttached(const Node*) {}
virtual void nodeDetached(const Node*) {}
};
class DebugRenderable : public Renderable, public NodeAlloc
{
protected:
Node* mParent;
MeshPtr mMeshPtr;
MaterialPtr mMat;
Real mScaling;
public:
DebugRenderable(Node* parent);
~DebugRenderable();
const MaterialPtr& getMaterial(void) const;
void getRenderOperation(RenderOperation& op);
void getWorldTransforms(Matrix4* xform) const;
Real getSquaredViewDepth(const Camera* cam) const;
const LightList& getLights(void) const;
void setScaling(Real s) { mScaling = s; }
};
protected:
Node* mParent;
ChildNodeMap mChildren;
typedef set<Node*>::type ChildUpdateSet;
mutable ChildUpdateSet mChildrenToUpdate;
mutable bool mNeedParentUpdate;
mutable bool mNeedChildUpdate;
mutable bool mParentNotified ;
mutable bool mQueuedForUpdate;
String mName;
static NameGenerator msNameGenerator;
Quaternion mOrientation;
Vector3 mPosition;
Vector3 mScale;
bool mInheritOrientation;
bool mInheritScale;
virtual void setParent(Node* parent);
mutable Quaternion mDerivedOrientation;
mutable Vector3 mDerivedPosition;
mutable Vector3 mDerivedScale;
virtual void _updateFromParent(void) const;
virtual void updateFromParentImpl(void) const;
virtual Node* createChildImpl(void) = 0;
virtual Node* createChildImpl(const String& name) = 0;
Vector3 mInitialPosition;
Quaternion mInitialOrientation;
Vector3 mInitialScale;
mutable Matrix4 mCachedTransform;
mutable bool mCachedTransformOutOfDate;
Listener* mListener;
typedef vector<Node*>::type QueuedUpdates;
static QueuedUpdates msQueuedUpdates;
DebugRenderable* mDebug;
UserObjectBindings mUserObjectBindings;
public:
Node();
Node(const String& name);
virtual ~Node();
const String& getName(void) const;
virtual Node* getParent(void) const;
virtual const Quaternion & getOrientation() const;
virtual void setOrientation( const Quaternion& q );
virtual void setOrientation( Real w, Real x, Real y, Real z);
virtual void resetOrientation(void);
virtual void setPosition(const Vector3& pos);
virtual void setPosition(Real x, Real y, Real z);
virtual const Vector3 & getPosition(void) const;
virtual void setScale(const Vector3& scale);
virtual void setScale(Real x, Real y, Real z);
virtual const Vector3 & getScale(void) const;
virtual void setInheritOrientation(bool inherit);
virtual bool getInheritOrientation(void) const;
virtual void setInheritScale(bool inherit);
virtual bool getInheritScale(void) const;
virtual void scale(const Vector3& scale);
virtual void scale(Real x, Real y, Real z);
virtual void translate(const Vector3& d, TransformSpace relativeTo = TS_PARENT);
virtual void translate(Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
virtual void translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo = TS_PARENT);
virtual void translate(const Matrix3& axes, Real x, Real y, Real z, TransformSpace relativeTo = TS_PARENT);
virtual void roll(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
virtual void pitch(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
virtual void yaw(const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
virtual void rotate(const Vector3& axis, const Radian& angle, TransformSpace relativeTo = TS_LOCAL);
virtual void rotate(const Quaternion& q, TransformSpace relativeTo = TS_LOCAL);
virtual Matrix3 getLocalAxes(void) const;
virtual Node* createChild(
const Vector3& translate = Vector3::ZERO,
const Quaternion& rotate = Quaternion::IDENTITY );
virtual Node* createChild(const String& name, const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY);
virtual void addChild(Node* child);
virtual unsigned short numChildren(void) const;
virtual Node* getChild(unsigned short index) const;
virtual Node* getChild(const String& name) const;
virtual ChildNodeIterator getChildIterator(void);
virtual ConstChildNodeIterator getChildIterator(void) const;
virtual Node* removeChild(unsigned short index);
virtual Node* removeChild(Node* child);
virtual Node* removeChild(const String& name);
virtual void removeAllChildren(void);
virtual void _setDerivedPosition(const Vector3& pos);
virtual void _setDerivedOrientation(const Quaternion& q);
virtual const Quaternion & _getDerivedOrientation(void) const;
virtual const Vector3 & _getDerivedPosition(void) const;
virtual const Vector3 & _getDerivedScale(void) const;
virtual const Matrix4& _getFullTransform(void) const;
virtual void _update(bool updateChildren, bool parentHasChanged);
virtual void setListener(Listener* listener) { mListener = listener; }
virtual Listener* getListener(void) const { return mListener; }
virtual void setInitialState(void);
virtual void resetToInitialState(void);
virtual const Vector3& getInitialPosition(void) const;
virtual Vector3 convertWorldToLocalPosition( const Vector3 &worldPos );
virtual Vector3 convertLocalToWorldPosition( const Vector3 &localPos );
virtual Quaternion convertWorldToLocalOrientation( const Quaternion &worldOrientation );
virtual Quaternion convertLocalToWorldOrientation( const Quaternion &localOrientation );
virtual const Quaternion& getInitialOrientation(void) const;
virtual const Vector3& getInitialScale(void) const;
virtual Real getSquaredViewDepth(const Camera* cam) const;
virtual void needUpdate(bool forceParentUpdate = false);
virtual void requestUpdate(Node* child, bool forceParentUpdate = false);
virtual void cancelUpdate(Node* child);
virtual DebugRenderable* getDebugRenderable(Real scaling);
static void queueNeedUpdate(Node* n);
static void processQueuedUpdates(void);
OGRE_DEPRECATED virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); }
OGRE_DEPRECATED virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); }
UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
};
} // namespace Ogre
#include "OgreHeaderSuffix.h"
#endif // _Node_H__
Ogre::Node::mDerivedScale
Vector3 mDerivedScale
Cached combined scale.
Definition: OgreNode.h:192
Ogre::Node::msNameGenerator
static NameGenerator msNameGenerator
Incremented count for next name extension.
Definition: OgreNode.h:147
Ogre::Node::mCachedTransformOutOfDate
bool mCachedTransformOutOfDate
Definition: OgreNode.h:226
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
Ogre::Node::getUserObjectBindings
UserObjectBindings & getUserObjectBindings()
Return an instance of user objects binding associated with this class.
Definition: OgreNode.h:766
OgreQuaternion.h
Ogre::Node::TS_LOCAL
Transform is relative to the local space.
Definition: OgreNode.h:72
Ogre::Node::mInheritScale
bool mInheritScale
Stores whether this node inherits scale from it&#39;s parent.
Definition: OgreNode.h:162
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Node::mChildrenToUpdate
ChildUpdateSet mChildrenToUpdate
List of children which need updating, used if self is not out of date but children are...
Definition: OgreNode.h:133
Ogre::Node::mQueuedForUpdate
bool mQueuedForUpdate
Flag indicating that the node has been queued for update.
Definition: OgreNode.h:141
Ogre::Node::Listener::Listener
Listener()
Definition: OgreNode.h:87
OgreRenderable.h
Ogre::Node::mListener
Listener * mListener
Node listener - only one allowed (no list) for size & performance reasons.
Definition: OgreNode.h:229
Ogre::Node::getListener
virtual Listener * getListener(void) const
Gets the current listener for this Node.
Definition: OgreNode.h:670
Ogre::Node::DebugRenderable
Inner class for displaying debug renderable for Node.
Definition: OgreNode.h:106
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:57
OgreMesh.h
Ogre::MapIterator
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:319
Ogre::Matrix3
A 3x3 matrix which can represent rotations around axes.
Definition: OgreMatrix3.h:68
Ogre::ConstMapIterator
Concrete IteratorWrapper for const access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:352
Ogre::NameGenerator
Utility class to generate a sequentially numbered series of names.
Definition: OgreNameGenerator.h:56
Ogre::Node::mNeedParentUpdate
bool mNeedParentUpdate
Flag to indicate own transform from parent is out of date.
Definition: OgreNode.h:135
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Node::Listener::~Listener
virtual ~Listener()
Definition: OgreNode.h:88
Ogre::Node::mCachedTransform
Matrix4 mCachedTransform
Cached derived transform as a 4x4 matrix.
Definition: OgreNode.h:225
OGRE_DEPRECATED
#define OGRE_DEPRECATED
Definition: OgrePlatform.h:189
OgreString.h
Ogre::Node::mDebug
DebugRenderable * mDebug
Definition: OgreNode.h:234
Ogre::Node::getUserAny
virtual OGRE_DEPRECATED const Any & getUserAny(void) const
Definition: OgreNode.h:760
Ogre::Node::msQueuedUpdates
static QueuedUpdates msQueuedUpdates
Definition: OgreNode.h:232
Ogre::Node::mUserObjectBindings
UserObjectBindings mUserObjectBindings
User objects binding.
Definition: OgreNode.h:237
Ogre::Node::mDerivedPosition
Vector3 mDerivedPosition
Cached combined position.
Definition: OgreNode.h:183
Ogre::Node::mParent
Node * mParent
Pointer to parent node.
Definition: OgreNode.h:127
Ogre::Node::getUserObjectBindings
const UserObjectBindings & getUserObjectBindings() const
Return an instance of user objects binding associated with this class.
Definition: OgreNode.h:772
Ogre::Any
Variant type that can hold Any other type.
Definition: OgreAny.h:56
Ogre::Node::setListener
virtual void setListener(Listener *listener)
Sets a listener for this Node.
Definition: OgreNode.h:666
OgreCommon.h
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
OgreUserObjectBindings.h
Ogre::Node::mInitialScale
Vector3 mInitialScale
The scale to use as a base for keyframe animation.
Definition: OgreNode.h:222
OgrePrerequisites.h
Ogre::Node::mParentNotified
bool mParentNotified
Flag indicating that parent has been notified about update request.
Definition: OgreNode.h:139
Ogre::Node::mInheritOrientation
bool mInheritOrientation
Stores whether this node inherits orientation from it&#39;s parent.
Definition: OgreNode.h:159
Ogre::Node::DebugRenderable::mParent
Node * mParent
Definition: OgreNode.h:109
Ogre::HashedVector
A hashed vector.
Definition: OgreCommon.h:332
Ogre::Node
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:64
Ogre::Node::QueuedUpdates
vector< Node * >::type QueuedUpdates
Definition: OgreNode.h:231
Ogre::Node::TS_PARENT
Transform is relative to the space of the parent node.
Definition: OgreNode.h:74
Ogre::Node::Listener::nodeDetached
virtual void nodeDetached(const Node *)
Node has been detached from a parent.
Definition: OgreNode.h:102
Ogre::Node::mChildren
ChildNodeMap mChildren
Collection of pointers to direct children; hashmap for efficiency.
Definition: OgreNode.h:129
Ogre::Node::DebugRenderable::setScaling
void setScaling(Real s)
Definition: OgreNode.h:121
OgreMatrix4.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Node::mName
String mName
Friendly name of this node, can be automatically generated if you don&#39;t care.
Definition: OgreNode.h:144
Ogre::set
Definition: OgrePrerequisites.h:519
Ogre::Node::DebugRenderable::mMeshPtr
MeshPtr mMeshPtr
Definition: OgreNode.h:110
Ogre::Node::mInitialOrientation
Quaternion mInitialOrientation
The orientation to use as a base for keyframe animation.
Definition: OgreNode.h:220
Ogre::Node::mNeedChildUpdate
bool mNeedChildUpdate
Flag indicating that all children need to be updated.
Definition: OgreNode.h:137
Ogre::Node::Listener
Listener which gets called back on Node events.
Definition: OgreNode.h:84
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
OgreHeaderSuffix.h
Ogre::Node::ChildNodeIterator
MapIterator< ChildNodeMap > ChildNodeIterator
Definition: OgreNode.h:79
Ogre::Node::ConstChildNodeIterator
ConstMapIterator< ChildNodeMap > ConstChildNodeIterator
Definition: OgreNode.h:80
OgreMatrix3.h
OgreIteratorWrappers.h
Ogre::Node::Listener::nodeAttached
virtual void nodeAttached(const Node *)
Node has been attached to a parent.
Definition: OgreNode.h:100
Ogre::Node::mScale
Vector3 mScale
Stores the scaling factor applied to this node.
Definition: OgreNode.h:156
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Node::TransformSpace
TransformSpace
Enumeration denoting the spaces which a transform can be relative to.
Definition: OgreNode.h:69
Ogre::Node::Listener::nodeDestroyed
virtual void nodeDestroyed(const Node *)
Node is being destroyed.
Definition: OgreNode.h:98
Ogre::SharedPtr< Mesh >
Ogre::Node::mPosition
Vector3 mPosition
Stores the position/translation of the node relative to its parent.
Definition: OgreNode.h:153
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::Node::mOrientation
Quaternion mOrientation
Stores the orientation of the node relative to it&#39;s parent.
Definition: OgreNode.h:150
OgreHeaderPrefix.h
Ogre::UserObjectBindings
Class that provides convenient interface to establish a linkage between custom user application objec...
Definition: OgreUserObjectBindings.h:49
Ogre::Node::DebugRenderable::mScaling
Real mScaling
Definition: OgreNode.h:112
Ogre::RenderOperation
&#39;New&#39; rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::Node::ChildNodeMap
HashMap< String, Node * > ChildNodeMap
Definition: OgreNode.h:78
Ogre::Node::Listener::nodeUpdated
virtual void nodeUpdated(const Node *)
Called when a node gets updated.
Definition: OgreNode.h:96
Ogre::Quaternion::IDENTITY
static const Quaternion IDENTITY
Definition: OgreQuaternion.h:301
Ogre::Node::DebugRenderable::mMat
MaterialPtr mMat
Definition: OgreNode.h:111
Ogre::Node::setUserAny
virtual OGRE_DEPRECATED void setUserAny(const Any &anything)
Definition: OgreNode.h:755
Ogre::Node::ChildUpdateSet
set< Node * >::type ChildUpdateSet
Definition: OgreNode.h:131
Ogre::Node::mInitialPosition
Vector3 mInitialPosition
The position to use as a base for keyframe animation.
Definition: OgreNode.h:218
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::Radian
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:47
Ogre::Vector3::ZERO
static const Vector3 ZERO
Definition: OgreVector3.h:800
Ogre::Node::mDerivedOrientation
Quaternion mDerivedOrientation
Cached combined orientation.
Definition: OgreNode.h:174

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.