Ogre::SceneNode Class Reference

Class representing a node in the scene graph. More...

#include <OgreSceneNode.h>

Inheritance diagram for Ogre::SceneNode:

Inheritance graph
[legend]

List of all members.

Public Types

typedef HashMap
< String,
MovableObject * > 
ObjectMap
typedef MapIterator
< ObjectMap
ObjectIterator
typedef
ConstMapIterator
< ObjectMap
ConstObjectIterator
enum  TransformSpace { TS_LOCAL, TS_PARENT, TS_WORLD }
 Enumeration denoting the spaces which a transform can be relative to. More...
typedef HashMap
< String, Node * > 
ChildNodeMap
typedef MapIterator
< ChildNodeMap
ChildNodeIterator
typedef
ConstMapIterator
< ChildNodeMap
ConstChildNodeIterator

Public Member Functions

 SceneNode (SceneManager *creator)
 Constructor, only to be called by the creator SceneManager.
 SceneNode (SceneManager *creator, const String &name)
 Constructor, only to be called by the creator SceneManager.
 ~SceneNode ()
virtual void attachObject (MovableObject *obj)
 Adds an instance of a scene object to this node.
virtual unsigned short numAttachedObjects (void) const
 Reports the number of objects attached to this node.
virtual MovableObjectgetAttachedObject (unsigned short index)
 Retrieves a pointer to an attached object.
virtual MovableObjectgetAttachedObject (const String &name)
 Retrieves a pointer to an attached object.
virtual MovableObjectdetachObject (unsigned short index)
 Detaches the indexed object from this scene node.
virtual void detachObject (MovableObject *obj)
 Detaches an object by pointer.
virtual MovableObjectdetachObject (const String &name)
 Detaches the named object from this node and returns a pointer to it.
virtual void detachAllObjects (void)
 Detaches all objects attached to this node.
virtual bool isInSceneGraph (void) const
 Determines whether this node is in the scene graph, i.e.
virtual void _notifyRootNode (void)
 Notifies this SceneNode that it is the root scene node.
virtual void _update (bool updateChildren, bool parentHasChanged)
 Internal method to update the Node.
virtual void _updateBounds (void)
 Tells the SceneNode to update the world bound info it stores.
virtual void _findVisibleObjects (Camera *cam, RenderQueue *queue, VisibleObjectsBoundsInfo *visibleBounds, bool includeChildren=true, bool displayNodes=false, bool onlyShadowCasters=false)
 Internal method which locates any visible objects attached to this node and adds them to the passed in queue.
virtual const
AxisAlignedBox
_getWorldAABB (void) const
 Gets the axis-aligned bounding box of this node (and hence all subnodes).
virtual ObjectIterator getAttachedObjectIterator (void)
 Retrieves an iterator which can be used to efficiently step through the objects attached to this node.
virtual
ConstObjectIterator 
getAttachedObjectIterator (void) const
 Retrieves an iterator which can be used to efficiently step through the objects attached to this node.
SceneManagergetCreator (void) const
 Gets the creator of this scene node.
virtual void removeAndDestroyChild (const String &name)
 This method removes and destroys the named child and all of its children.
virtual void removeAndDestroyChild (unsigned short index)
 This method removes and destroys the child and all of its children.
virtual void removeAndDestroyAllChildren (void)
 Removes and destroys all children of this node.
virtual void showBoundingBox (bool bShow)
 Allows the showing of the node's bounding box.
virtual void _addBoundingBoxToQueue (RenderQueue *queue)
 Add the bounding box to the rendering queue.
virtual bool getShowBoundingBox () const
 This allows scene managers to determine if the node's bounding box should be added to the rendering queue.
virtual SceneNodecreateChildSceneNode (const Vector3 &translate=Vector3::ZERO, const Quaternion &rotate=Quaternion::IDENTITY)
 Creates an unnamed new SceneNode as a child of this node.
virtual SceneNodecreateChildSceneNode (const String &name, const Vector3 &translate=Vector3::ZERO, const Quaternion &rotate=Quaternion::IDENTITY)
 Creates a new named SceneNode as a child of this node.
virtual void findLights (LightList &destList, Real radius) const
 Allows retrieval of the nearest lights to the centre of this SceneNode.
virtual void setFixedYawAxis (bool useFixed, const Vector3 &fixedAxis=Vector3::UNIT_Y)
 Tells the node whether to yaw around it's own local Y axis or a fixed axis of choice.
virtual void yaw (const Radian &angle, TransformSpace relativeTo=TS_LOCAL)
 Rotate the node around the Y-axis.
virtual void setDirection (Real x, Real y, Real z, TransformSpace relativeTo=TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
 Sets the node's direction vector ie it's local -z.
virtual void setDirection (const Vector3 &vec, TransformSpace relativeTo=TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
 Sets the node's direction vector ie it's local -z.
virtual void lookAt (const Vector3 &targetPoint, TransformSpace relativeTo, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
 Points the local -Z direction of this node at a point in space.
virtual void setAutoTracking (bool enabled, SceneNode *target=0, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z, const Vector3 &offset=Vector3::ZERO)
 Enables / disables automatic tracking of another SceneNode.
virtual SceneNodegetAutoTrackTarget (void)
 Get the auto tracking target for this node, if any.
virtual const Vector3getAutoTrackOffset (void)
 Get the auto tracking offset for this node, if the node is auto tracking.
virtual const Vector3getAutoTrackLocalDirection (void)
 Get the auto tracking local direction for this node, if it is auto tracking.
void _autoTrack (void)
 Internal method used by OGRE to update auto-tracking cameras.
SceneNodegetParentSceneNode (void) const
 Gets the parent of this SceneNode.
virtual void setVisible (bool visible, bool cascade=true)
 Makes all objects attached to this node become visible / invisible.
virtual void flipVisibility (bool cascade=true)
 Inverts the visibility of all objects attached to this node.
virtual void setDebugDisplayEnabled (bool enabled, bool cascade=true)
 Tells all objects attached to this node whether to display their debug information or not.
const StringgetName (void) const
 Returns the name of the node.
virtual NodegetParent (void) const
 Gets this node's parent (NULL if this is the root).
virtual const
Quaternion
getOrientation () const
 Returns a quaternion representing the nodes orientation.
virtual void setOrientation (const Quaternion &q)
 Sets the orientation of this node via a quaternion.
virtual void setOrientation (Real w, Real x, Real y, Real z)
 Sets the orientation of this node via quaternion parameters.
virtual void resetOrientation (void)
 Resets the nodes orientation (local axes as world axes, no rotation).
virtual void setPosition (const Vector3 &pos)
 Sets the position of the node relative to it's parent.
virtual void setPosition (Real x, Real y, Real z)
 Sets the position of the node relative to it's parent.
virtual const Vector3getPosition (void) const
 Gets the position of the node relative to it's parent.
virtual void setScale (const Vector3 &scale)
 Sets the scaling factor applied to this node.
virtual void setScale (Real x, Real y, Real z)
 Sets the scaling factor applied to this node.
virtual const Vector3getScale (void) const
 Gets the scaling factor of this node.
virtual void setInheritOrientation (bool inherit)
 Tells the node whether it should inherit orientation from it's parent node.
virtual bool getInheritOrientation (void) const
 Returns true if this node is affected by orientation applied to the parent node.
virtual void setInheritScale (bool inherit)
 Tells the node whether it should inherit scaling factors from it's parent node.
virtual bool getInheritScale (void) const
 Returns true if this node is affected by scaling factors applied to the parent node.
virtual void scale (const Vector3 &scale)
 Scales the node, combining it's current scale with the passed in scaling factor.
virtual void scale (Real x, Real y, Real z)
 Scales the node, combining it's current scale with the passed in scaling factor.
virtual void translate (const Vector3 &d, TransformSpace relativeTo=TS_PARENT)
 Moves the node along the Cartesian axes.
virtual void translate (Real x, Real y, Real z, TransformSpace relativeTo=TS_PARENT)
 Moves the node along the Cartesian axes.
virtual void translate (const Matrix3 &axes, const Vector3 &move, TransformSpace relativeTo=TS_PARENT)
 Moves the node along arbitrary axes.
virtual void translate (const Matrix3 &axes, Real x, Real y, Real z, TransformSpace relativeTo=TS_PARENT)
 Moves the node along arbitrary axes.
virtual void roll (const Radian &angle, TransformSpace relativeTo=TS_LOCAL)
 Rotate the node around the Z-axis.
virtual void pitch (const Radian &angle, TransformSpace relativeTo=TS_LOCAL)
 Rotate the node around the X-axis.
virtual void rotate (const Vector3 &axis, const Radian &angle, TransformSpace relativeTo=TS_LOCAL)
 Rotate the node around an arbitrary axis.
virtual void rotate (const Quaternion &q, TransformSpace relativeTo=TS_LOCAL)
 Rotate the node around an aritrary axis using a Quarternion.
virtual Matrix3 getLocalAxes (void) const
 Gets a matrix whose columns are the local axes based on the nodes orientation relative to it's parent.
virtual NodecreateChild (const Vector3 &translate=Vector3::ZERO, const Quaternion &rotate=Quaternion::IDENTITY)
 Creates an unnamed new Node as a child of this node.
virtual NodecreateChild (const String &name, const Vector3 &translate=Vector3::ZERO, const Quaternion &rotate=Quaternion::IDENTITY)
 Creates a new named Node as a child of this node.
virtual void addChild (Node *child)
 Adds a (precreated) child scene node to this node.
virtual unsigned short numChildren (void) const
 Reports the number of child nodes under this one.
virtual NodegetChild (unsigned short index) const
 Gets a pointer to a child node.
virtual NodegetChild (const String &name) const
 Gets a pointer to a named child node.
virtual ChildNodeIterator getChildIterator (void)
 Retrieves an iterator for efficiently looping through all children of this node.
virtual
ConstChildNodeIterator 
getChildIterator (void) const
 Retrieves an iterator for efficiently looping through all children of this node.
virtual NoderemoveChild (unsigned short index)
 Drops the specified child from this node.
virtual NoderemoveChild (Node *child)
 Drops the specified child from this node.
virtual NoderemoveChild (const String &name)
 Drops the named child from this node.
virtual void removeAllChildren (void)
 Removes all child Nodes attached to this node.
virtual const
Quaternion
_getDerivedOrientation (void) const
 Gets the orientation of the node as derived from all parents.
virtual const Vector3_getDerivedPosition (void) const
 Gets the position of the node as derived from all parents.
virtual const Vector3_getDerivedScale (void) const
 Gets the scaling factor of the node as derived from all parents.
virtual const Matrix4_getFullTransform (void) const
 Gets the full transformation matrix for this node.
virtual void setListener (Listener *listener)
 Sets a listener for this Node.
virtual Listener * getListener (void) const
 Gets the current listener for this Node.
const MaterialPtrgetMaterial (void) const
 Overridden from Renderable.
void getRenderOperation (RenderOperation &op)
 Overridden from Renderable.
void getWorldTransforms (Matrix4 *xform) const
 Overridden from Renderable.
virtual void setInitialState (void)
 Sets the current transform of this node to be the 'initial state' ie that position / orientation / scale to be used as a basis for delta values used in keyframe animation.
virtual void resetToInitialState (void)
 Resets the position / orientation / scale of this node to it's initial state, see setInitialState for more info.
virtual const Vector3getInitialPosition (void) const
 Gets the initial position of this node, see setInitialState for more info.
virtual const
Quaternion
getInitialOrientation (void) const
 Gets the initial orientation of this node, see setInitialState for more info.
virtual const Vector3getInitialScale (void) const
 Gets the initial position of this node, see setInitialState for more info.
Real getSquaredViewDepth (const Camera *cam) const
 Overridden, see Renderable.
virtual void needUpdate (bool forceParentUpdate=false)
 To be called in the event of transform changes to this node that require it's recalculation.
virtual void requestUpdate (Node *child, bool forceParentUpdate=false)
 Called by children to notify their parent that they need an update.
virtual void cancelUpdate (Node *child)
 Called by children to notify their parent that they no longer need an update.
const LightListgetLights (void) const
 Gets a list of lights, ordered relative to how close they are to this renderable.

Remarks:
Directional lights, which have no position, will always be first on this list.

virtual TechniquegetTechnique (void) const
 Retrieves a pointer to the Material Technique this renderable object uses.
virtual bool preRender (SceneManager *sm, RenderSystem *rsys)
 Called just prior to the Renderable being rendered.
virtual void postRender (SceneManager *sm, RenderSystem *rsys)
 Called immediately after the Renderable has been rendered.
virtual unsigned short getNumWorldTransforms (void) const
 Returns the number of world transform matrices this renderable requires.
void setUseIdentityProjection (bool useIdentityProjection)
 Sets whether or not to use an 'identity' projection.
bool getUseIdentityProjection (void) const
 Returns whether or not to use an 'identity' projection.
void setUseIdentityView (bool useIdentityView)
 Sets whether or not to use an 'identity' view.
bool getUseIdentityView (void) const
 Returns whether or not to use an 'identity' view.
virtual bool getCastsShadows (void) const
 Method which reports whether this renderable would normally cast a shadow.
void setCustomParameter (size_t index, const Vector4 &value)
 Sets a custom parameter for this Renderable, which may be used to drive calculations for this specific Renderable, like GPU program parameters.
const Vector4getCustomParameter (size_t index) const
 Gets the custom value associated with this Renderable at the given index.
virtual void _updateCustomGpuParameter (const GpuProgramParameters::AutoConstantEntry &constantEntry, GpuProgramParameters *params) const
 Update a custom GpuProgramParameters constant which is derived from information only this Renderable knows.
virtual void setPolygonModeOverrideable (bool override)
 Sets whether this renderable's chosen detail level can be overridden (downgraded) by the camera setting.
virtual bool getPolygonModeOverrideable (void) const
 Gets whether this renderable's chosen detail level can be overridden (downgraded) by the camera setting.
virtual void setUserAny (const Any &anything)
 Sets any kind of user value on this object.
virtual const AnygetUserAny (void) const
 Retrieves the custom user value associated with this object.
virtual
RenderSystemData * 
getRenderSystemData () const
 Sets render system private data.
virtual void setRenderSystemData (RenderSystemData *val) const
 gets render system private data
void * operator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info
void * operator new (size_t sz)
void * operator new (size_t sz, void *ptr)
 placement operator new
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info
void * operator new[] (size_t sz)
void operator delete (void *ptr)
void operator delete (void *ptr, const char *, int, const char *)
void operator delete[] (void *ptr)
void operator delete[] (void *ptr, const char *, int, const char *)

Static Public Member Functions

static void queueNeedUpdate (Node *n)
 Queue a 'needUpdate' call to a node safely.
static void processQueuedUpdates (void)
 Process queued 'needUpdate' calls.

Protected Types

typedef std::set
< Node * > 
ChildUpdateSet
typedef std::vector
< Node * > 
QueuedUpdates
typedef std::map
< size_t, Vector4
CustomParameterMap

Protected Member Functions

void updateFromParentImpl (void) const
 Class-specific implementation of _updateFromParent.

Remarks:
Splitting the implementation of the update away from the update call itself allows the detail to be overridden without disrupting the general sequence of updateFromParent (e.g. raising events)
.
NodecreateChildImpl (void)
 See Node.
NodecreateChildImpl (const String &name)
 See Node.
void setParent (Node *parent)
 See Node.
virtual void setInSceneGraph (bool inGraph)
 Internal method for setting whether the node is in the scene graph.
virtual void _updateFromParent (void) const
 Triggers the node to update it's combined transforms.

Protected Attributes

ObjectMap mObjectsByName
WireBoundingBoxmWireBoundingBox
 Pointer to a Wire Bounding Box for this Node.
bool mShowBoundingBox
 Flag that determines if the bounding box of the node should be displayed.
SceneManagermCreator
 SceneManager which created this node.
AxisAlignedBox mWorldAABB
 World-Axis aligned bounding box, updated only through _update.
bool mYawFixed
 Whether to yaw around a fixed axis.
Vector3 mYawFixedAxis
 Fixed axis to yaw around.
SceneNodemAutoTrackTarget
 Auto tracking target.
Vector3 mAutoTrackOffset
 Tracking offset for fine tuning.
Vector3 mAutoTrackLocalDirection
 Local 'normal' direction vector.
bool mIsInSceneGraph
 Is this node a current part of the scene graph?
NodemParent
 Pointer to parent node.
ChildNodeMap mChildren
 Collection of pointers to direct children; hashmap for efficiency.
ChildUpdateSet mChildrenToUpdate
 List of children which need updating, used if self is not out of date but children are.
bool mNeedParentUpdate
 Flag to indicate own transform from parent is out of date.
bool mNeedChildUpdate
 Flag indicating that all children need to be updated.
bool mParentNotified
 Flag indicating that parent has been notified about update request.
bool mQueuedForUpdate
 Flag indicating that the node has been queued for update.
String mName
 Friendly name of this node, can be automatically generated if you don't care.
Quaternion mOrientation
 Stores the orientation of the node relative to it's parent.
Vector3 mPosition
 Stores the position/translation of the node relative to its parent.
Vector3 mScale
 Stores the scaling factor applied to this node.
bool mInheritOrientation
 Stores whether this node inherits orientation from it's parent.
bool mInheritScale
 Stores whether this node inherits scale from it's parent.
MaterialPtr mpMaterial
 Material pointer should this node be rendered.
Quaternion mDerivedOrientation
 Cached combined orientation.
Vector3 mDerivedPosition
 Cached combined position.
Vector3 mDerivedScale
 Cached combined scale.
Vector3 mInitialPosition
 The position to use as a base for keyframe animation.
Quaternion mInitialOrientation
 The orientation to use as a base for keyframe animation.
Vector3 mInitialScale
 The scale to use as a base for keyframe animation.
Matrix4 mCachedTransform
 Cached derived transform as a 4x4 matrix.
bool mCachedTransformOutOfDate
Listener * mListener
 Node listener - only one allowed (no list) for size & performance reasons.
CustomParameterMap mCustomParameters
bool mPolygonModeOverrideable
bool mUseIdentityProjection
bool mUseIdentityView
Any mUserAny
RenderSystemData * mRenderSystemData

Static Protected Attributes

static unsigned long msNextGeneratedNameExt
 Incremented count for next name extension.
static QueuedUpdates msQueuedUpdates


Detailed Description

Class representing a node in the scene graph.

Remarks:
A SceneNode is a type of Node which is used to organise objects in a scene. It has the same hierarchical transformation properties of the generic Node class, but also adds the ability to attach world objects to the node, and stores hierarchical bounding volumes of the nodes in the tree. Child nodes are contained within the bounds of the parent, and so on down the tree, allowing for fast culling.

Definition at line 52 of file OgreSceneNode.h.


Member Typedef Documentation

typedef HashMap<String, MovableObject*> Ogre::SceneNode::ObjectMap

Definition at line 55 of file OgreSceneNode.h.

typedef MapIterator<ObjectMap> Ogre::SceneNode::ObjectIterator

Definition at line 56 of file OgreSceneNode.h.

typedef ConstMapIterator<ObjectMap> Ogre::SceneNode::ConstObjectIterator

Definition at line 57 of file OgreSceneNode.h.

typedef HashMap<String, Node*> Ogre::Node::ChildNodeMap [inherited]

Definition at line 68 of file OgreNode.h.

typedef MapIterator<ChildNodeMap> Ogre::Node::ChildNodeIterator [inherited]

Definition at line 69 of file OgreNode.h.

typedef ConstMapIterator<ChildNodeMap> Ogre::Node::ConstChildNodeIterator [inherited]

Definition at line 70 of file OgreNode.h.

typedef std::set<Node*> Ogre::Node::ChildUpdateSet [protected, inherited]

Definition at line 101 of file OgreNode.h.

typedef std::vector<Node*> Ogre::Node::QueuedUpdates [protected, inherited]

Definition at line 204 of file OgreNode.h.

typedef std::map<size_t, Vector4> Ogre::Renderable::CustomParameterMap [protected, inherited]

Definition at line 371 of file OgreRenderable.h.


Member Enumeration Documentation

enum Ogre::Node::TransformSpace [inherited]

Enumeration denoting the spaces which a transform can be relative to.

Enumerator:
TS_LOCAL  Transform is relative to the local space.
TS_PARENT  Transform is relative to the space of the parent node.
TS_WORLD  Transform is relative to world space.

Definition at line 59 of file OgreNode.h.


Constructor & Destructor Documentation

Ogre::SceneNode::SceneNode ( SceneManager creator  ) 

Constructor, only to be called by the creator SceneManager.

Remarks:
Creates a node with a generated name.

Ogre::SceneNode::SceneNode ( SceneManager creator,
const String name 
)

Constructor, only to be called by the creator SceneManager.

Remarks:
Creates a node with a specified name.

Ogre::SceneNode::~SceneNode (  ) 


Member Function Documentation

void Ogre::SceneNode::updateFromParentImpl ( void   )  const [protected, virtual]

Class-specific implementation of _updateFromParent.

Remarks:
Splitting the implementation of the update away from the update call itself allows the detail to be overridden without disrupting the general sequence of updateFromParent (e.g. raising events)
.

Reimplemented from Ogre::Node.

Node* Ogre::SceneNode::createChildImpl ( void   )  [protected, virtual]

See Node.

Implements Ogre::Node.

Node* Ogre::SceneNode::createChildImpl ( const String name  )  [protected, virtual]

See Node.

Implements Ogre::Node.

void Ogre::SceneNode::setParent ( Node parent  )  [protected, virtual]

See Node.

Reimplemented from Ogre::Node.

virtual void Ogre::SceneNode::setInSceneGraph ( bool  inGraph  )  [protected, virtual]

Internal method for setting whether the node is in the scene graph.

virtual void Ogre::SceneNode::attachObject ( MovableObject obj  )  [virtual]

Adds an instance of a scene object to this node.

Remarks:
Scene objects can include Entity objects, Camera objects, Light objects, ParticleSystem objects etc. Anything that subclasses from MovableObject.

virtual unsigned short Ogre::SceneNode::numAttachedObjects ( void   )  const [virtual]

Reports the number of objects attached to this node.

virtual MovableObject* Ogre::SceneNode::getAttachedObject ( unsigned short  index  )  [virtual]

Retrieves a pointer to an attached object.

Remarks:
Retrieves by index, see alternate version to retrieve by name. The index of an object may change as other objects are added / removed.

virtual MovableObject* Ogre::SceneNode::getAttachedObject ( const String name  )  [virtual]

Retrieves a pointer to an attached object.

Remarks:
Retrieves by object name, see alternate version to retrieve by index.

virtual MovableObject* Ogre::SceneNode::detachObject ( unsigned short  index  )  [virtual]

Detaches the indexed object from this scene node.

Remarks:
Detaches by index, see the alternate version to detach by name. Object indexes may change as other objects are added / removed.

virtual void Ogre::SceneNode::detachObject ( MovableObject obj  )  [virtual]

Detaches an object by pointer.

virtual MovableObject* Ogre::SceneNode::detachObject ( const String name  )  [virtual]

Detaches the named object from this node and returns a pointer to it.

virtual void Ogre::SceneNode::detachAllObjects ( void   )  [virtual]

Detaches all objects attached to this node.

virtual bool Ogre::SceneNode::isInSceneGraph ( void   )  const [virtual]

Determines whether this node is in the scene graph, i.e.

whether it's ultimate ancestor is the root scene node.

Definition at line 157 of file OgreSceneNode.h.

virtual void Ogre::SceneNode::_notifyRootNode ( void   )  [virtual]

Notifies this SceneNode that it is the root scene node.

Remarks:
Only SceneManager should call this!

Definition at line 163 of file OgreSceneNode.h.

virtual void Ogre::SceneNode::_update ( bool  updateChildren,
bool  parentHasChanged 
) [virtual]

Internal method to update the Node.

Note:
Updates this scene node and any relevant children to incorporate transforms etc. Don't call this yourself unless you are writing a SceneManager implementation.
Parameters:
updateChildren If true, the update cascades down to all children. Specify false if you wish to update children separately, e.g. because of a more selective SceneManager implementation.
parentHasChanged This flag indicates that the parent xform has changed, so the child should retrieve the parent's xform and combine it with its own even if it hasn't changed itself.

Reimplemented from Ogre::Node.

virtual void Ogre::SceneNode::_updateBounds ( void   )  [virtual]

Tells the SceneNode to update the world bound info it stores.