omegalib  13.1
omega::SceneNode Class Reference

Represents a node in the omegalib scene graph. More...

#include <SceneNode.h>

Public Types

enum  HitType { HitBoundingSphere, HitBest }
 
- Public Types inherited from omega::Node
enum  TransformSpace { TransformLocal, TransformParent, TransformWorld }
 Enumeration denoting the spaces which a transform can be relative to. More...
 
typedef Dictionary< String, Ref< Node > > ChildNodeMap
 

Public Member Functions

 SceneNode (Engine *server)
 
 SceneNode (Engine *server, const String &name)
 
EnginegetEngine ()
 
bool hit (const Ray &ray, Vector3f *hitPoint, HitType type)
 Hit test. More...
 
void update (const UpdateContext &context)
 Invoked the update function for all node components on this node and down in the hierarchy. More...
 
virtual void update (bool updateChildren, bool parentHasChanged)
 
virtual void needUpdate (bool forceParentUpdate=true)
 To be called in the event of transform changes to this node that require it's recalculation. More...
 
void setTag (const String &value)
 
const StringgetTag ()
 
void addComponent (NodeComponent *o)
 
int getNumComponents ()
 
void removeComponent (NodeComponent *o)
 
bool isSelectable ()
 
void setSelectable (bool value)
 
void setVisible (bool value)
 Sets this node visibility. More...
 
bool isVisible ()
 
void setChildrenVisible (bool value)
 
void setSelected (bool value)
 
bool isSelected ()
 
bool isAttachedToScene ()
 
const AlignedBox3getBoundingBox ()
 
const SpheregetBoundingSphere ()
 
const Vector3fgetBoundMinimum ()
 
const Vector3fgetBoundMaximum ()
 
const Vector3fgetBoundCenter ()
 
float getBoundRadius ()
 
void requestBoundingBoxUpdate ()
 Force an update of the bounding box for this node. More...
 
void addListener (SceneNodeListener *listener)
 
void removeListener (SceneNodeListener *listener)
 
void setFacingCamera (Camera *cam)
 Billboard mode. More...
 
CameragetFacingCamera ()
 
void setFacingCameraFixedY (bool value)
 When set to true, Y axis for nodes facing camera will be fixed to the world Y axis. More...
 
bool isFacingCameraFixedY ()
 
void followTrackable (int trackableId)
 Trackable object. More...
 
void setFollowOffset (const Vector3f &offset, const Quaternion &ooffset)
 
TrackedObjectgetTracker ()
 
void unfollow ()
 
void setFlag (uint bit)
 Node flags. More...
 
void unsetFlag (uint bit)
 
bool isFlagSet (uint bit)
 
- Public Member Functions inherited from omega::Node
 Node ()
 Constructor, should only be called by parent, not directly. More...
 
 Node (const String &name)
 Constructor, should only be called by parent, not directly. More...
 
virtual ~Node ()
 
const StringgetName (void) const
 Returns the name of the node. More...
 
virtual NodegetParent (void) const
 Gets this node's parent (NULL if this is the root). More...
 
virtual const QuaterniongetOrientation () const
 Returns a quaternion representing the nodes orientation. More...
 
virtual void setOrientation (const Quaternion &q)
 Sets the orientation of this node via a quaternion. More...
 
virtual void setOrientation (float w, float x, float y, float z)
 Sets the orientation of this node via quaternion parameters. More...
 
virtual void resetOrientation (void)
 Resets the nodes orientation (local axes as world axes, no rotation). More...
 
virtual void setPosition (const Vector3f &pos)
 Sets the position of the node relative to it's parent. More...
 
virtual void setPosition (float x, float y, float z)
 Sets the position of the node relative to it's parent. More...
 
virtual const Vector3fgetPosition (void) const
 Gets the position of the node relative to it's parent. More...
 
virtual void setScale (const Vector3f &scale)
 Sets the scaling factor applied to this node. More...
 
virtual void setScale (float x, float y, float z)
 Sets the scaling factor applied to this node. More...
 
virtual const Vector3fgetScale (void) const
 Gets the scaling factor of this node. More...
 
virtual void setInheritOrientation (bool inherit)
 Tells the node whether it should inherit orientation from it's parent node. More...
 
virtual bool getInheritOrientation (void) const
 Returns true if this node is affected by orientation applied to the parent node. More...
 
virtual void setInheritScale (bool inherit)
 Tells the node whether it should inherit scaling factors from it's parent node. More...
 
virtual bool getInheritScale (void) const
 Returns true if this node is affected by scaling factors applied to the parent node. More...
 
virtual void scale (const Vector3f &scale)
 Scales the node, combining it's current scale with the passed in scaling factor. More...
 
virtual void scale (float x, float y, float z)
 Scales the node, combining it's current scale with the passed in scaling factor. More...
 
virtual void translate (const Vector3f &d, TransformSpace relativeTo=TransformParent)
 Moves the node along the Cartesian axes. More...
 
virtual void translate (float x, float y, float z, TransformSpace relativeTo=TransformParent)
 Moves the node along the Cartesian axes. More...
 
virtual void translate (const Matrix3f &axes, const Vector3f &move, TransformSpace relativeTo=TransformParent)
 Moves the node along arbitrary axes. More...
 
virtual void translate (const Matrix3f &axes, float x, float y, float z, TransformSpace relativeTo=TransformParent)
 Moves the node along arbitrary axes. More...
 
virtual void roll (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the Z-axis. More...
 
void rollDeg (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the Z-axis, The angle is specified in degrees. More...
 
virtual void pitch (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the X-axis. More...
 
virtual void pitchDeg (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the X-axis, The angle is specified in degrees. More...
 
virtual void yaw (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the Y-axis. More...
 
virtual void yawDeg (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the Y-axis, The angle is specified in degrees. More...
 
virtual void rotate (const Vector3f &axis, const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around an arbitrary axis. More...
 
virtual void rotate (const Quaternion &q, TransformSpace relativeTo=TransformLocal)
 Rotate the node around an aritrary axis using a Quarternion. More...
 
virtual void lookAt (const Vector3f &position, const Vector3f &upVector)
 Rotate the node to make its positive Z axis point toward the specified position. More...
 
virtual Matrix3f getLocalAxes (void) const
 Gets a matrix whose columns are the local axes based on the nodes orientation relative to it's parent. More...
 
virtual void addChild (Node *child)
 Adds a (precreated) child scene node to this node. More...
 
virtual unsigned short numChildren (void) const
 Reports the number of child nodes under this one. More...
 
virtual NodegetChild (unsigned short index) const
 Gets a pointer to a child node. More...
 
virtual NodegetChild (const String &name) const
 Gets a pointer to a named child node. More...
 
virtual void removeChild (unsigned short index)
 Drops the specified child from this node. More...
 
virtual void removeChild (Node *child)
 Drops the specified child from this node. More...
 
virtual void removeChild (const String &name)
 Drops the named child from this node. More...
 
virtual void removeAllChildren (void)
 Removes all child Nodes attached to this node. More...
 
const List< Node * > & getChildren () const
 #PYPI Returns the list of children of this node More...
 
virtual void _setDerivedPosition (const Vector3f &pos)
 Sets the final world position of the node directly. More...
 
virtual void _setDerivedOrientation (const Quaternion &q)
 Sets the final world orientation of the node directly. More...
 
virtual const QuaterniongetDerivedOrientation (void) const
 Gets the orientation of the node as derived from all parents. More...
 
virtual const Vector3fgetDerivedPosition (void) const
 Gets the position of the node as derived from all parents. More...
 
virtual const Vector3fgetDerivedScale (void) const
 Gets the scaling factor of the node as derived from all parents. More...
 
virtual const AffineTransform3getFullTransform (void) const
 Gets the full transformation matrix for this node. More...
 
virtual Vector3f convertWorldToLocalPosition (const Vector3f &worldPos)
 Gets the local position, relative to this node, of the given world-space position. More...
 
virtual Vector3f convertLocalToWorldPosition (const Vector3f &localPos)
 Gets the world position of a point in the node local space useful for simple transforms that don't require a child node. More...
 
virtual Quaternion convertWorldToLocalOrientation (const Quaternion &worldOrientation)
 Gets the local orientation, relative to this node, of the given world-space orientation. More...
 
virtual Quaternion convertLocalToWorldOrientation (const Quaternion &localOrientation)
 Gets the world orientation of an orientation in the node local space useful for simple transforms that don't require a child node. More...
 
virtual void requestUpdate (Node *child, bool forceParentUpdate=false)
 Called by children to notify their parent that they need an update. More...
 
virtual void cancelUpdate (Node *child)
 Called by children to notify their parent that they no longer need an update. More...
 
void * getUserData ()
 
void setUserData (void *data)
 
void setName (const String &name)
 
bool isUpdateNeeded ()
 
- Public Member Functions inherited from omicron::ReferenceType
 ReferenceType ()
 
virtual ~ReferenceType ()
 
void ref ()
 
void unref ()
 
long refCount ()
 

Static Public Member Functions

static SceneNodecreate (const String &name)
 
- Static Public Member Functions inherited from omicron::ReferenceType
static void printObjCounts ()
 

Protected Member Functions

virtual void updateTraversal (const UpdateContext &context)
 
virtual void setParent (Node *parent)
 Only available internally - notification of parent. More...
 
void onAttachedToScene ()
 
void onDetachedFromScene ()
 
- Protected Member Functions inherited from omega::Node
virtual void updateFromParent (void) const
 Class-specific implementation of updateFromParent. More...
 

Additional Inherited Members

- Protected Types inherited from omega::Node
typedef std::set< Node * > ChildUpdateSet
 
- Protected Attributes inherited from omega::Node
NodemParent
 Pointer to parent node. More...
 
ChildNodeMap mChildren
 Collection of pointers to direct children; hashmap for efficiency. More...
 
List< Node * > mChildrenList
 
ChildUpdateSet mChildrenToUpdate
 List of children which need updating, used if self is not out of date but children are. More...
 
bool mNeedParentUpdate
 Flag to indicate own transform from parent is out of date. More...
 
bool mNeedChildUpdate
 Flag indicating that all children need to be updated. More...
 
bool mParentNotified
 Flag indicating that parent has been notified about update request. More...
 
bool mQueuedForUpdate
 Flag indicating that the node has been queued for update. More...
 
String mName
 Friendly name of this node, can be automatically generated if you don't care. More...
 
Quaternion mOrientation
 Stores the orientation of the node relative to it's parent. More...
 
Vector3f mPosition
 Stores the position/translation of the node relative to its parent. More...
 
Vector3f mScale
 Stores the scaling factor applied to this node. More...
 
bool mInheritOrientation
 Stores whether this node inherits orientation from it's parent. More...
 
bool mInheritScale
 Stores whether this node inherits scale from it's parent. More...
 
void * myUserData
 
Quaternion mDerivedOrientation
 Cached combined orientation. More...
 
Vector3f mDerivedPosition
 Cached combined position. More...
 
Vector3f mDerivedScale
 Cached combined scale. More...
 
AffineTransform3 mCachedTransform
 Cached derived transform as a 4x4 matrix. More...
 
bool mCachedTransformOutOfDate
 
- Static Protected Attributes inherited from omega::Node
static NameGenerator msNameGenerator
 Incremented count for next name extension. More...
 
- Static Protected Attributes inherited from omicron::ReferenceType
static List< ReferenceType * > mysObjList
 

Detailed Description

Represents a node in the omegalib scene graph.

Remarks
SceneNode instances add some functionality over the Node base class:
  • renderable objects can be attached to a scene node;
  • a scene node has a bounding box;
  • scene nodes have selection and visibility flags
  • it is possible to attach listeners to scene nodes, to handle visibility change, selection change and other events.
+ Inheritance diagram for omega::SceneNode:

Member Enumeration Documentation

Enumerator
HitBoundingSphere 

Perform hit tests on object bounding sphere.

HitBest 

Perform hit tests using best available intersector for the node.

Constructor & Destructor Documentation

omega::SceneNode::SceneNode ( Engine server)
inline
omega::SceneNode::SceneNode ( Engine server,
const String name 
)
inline

Member Function Documentation

void omega::SceneNode::addComponent ( NodeComponent o)
void omega::SceneNode::addListener ( SceneNodeListener listener)
static SceneNode* omega::SceneNode::create ( const String name)
static
void omega::SceneNode::followTrackable ( int  trackableId)

Trackable object.

const Vector3f& omega::SceneNode::getBoundCenter ( )
const AlignedBox3& omega::SceneNode::getBoundingBox ( )
const Sphere& omega::SceneNode::getBoundingSphere ( )
const Vector3f& omega::SceneNode::getBoundMaximum ( )
const Vector3f& omega::SceneNode::getBoundMinimum ( )
float omega::SceneNode::getBoundRadius ( )
Engine * omega::SceneNode::getEngine ( )
inline
Camera * omega::SceneNode::getFacingCamera ( )
inline
int omega::SceneNode::getNumComponents ( )
const String& omega::SceneNode::getTag ( )
inline
TrackedObject * omega::SceneNode::getTracker ( )
inline
bool omega::SceneNode::hit ( const Ray ray,
Vector3f hitPoint,
HitType  type 
)

Hit test.

bool omega::SceneNode::isAttachedToScene ( )
bool omega::SceneNode::isFacingCameraFixedY ( )
inline
bool omega::SceneNode::isFlagSet ( uint  bit)
inline
bool omega::SceneNode::isSelectable ( )
inline
bool omega::SceneNode::isSelected ( )
bool omega::SceneNode::isVisible ( )
virtual void omega::SceneNode::needUpdate ( bool  forceParentUpdate = true)
virtual

To be called in the event of transform changes to this node that require it's recalculation.

Remarks
This not only tags the node state as being 'dirty', it also requests it's parent to know about it's dirtiness so it will get an update next time.
Parameters
forceParentUpdateEven if the node thinks it has already told it's parent, tell it anyway

Reimplemented from omega::Node.

void omega::SceneNode::onAttachedToScene ( )
protected
void omega::SceneNode::onDetachedFromScene ( )
protected
void omega::SceneNode::removeComponent ( NodeComponent o)
void omega::SceneNode::removeListener ( SceneNodeListener listener)
void omega::SceneNode::requestBoundingBoxUpdate ( )
inline

Force an update of the bounding box for this node.

Usually called by NodeComponent objects attached to this node.

void omega::SceneNode::setChildrenVisible ( bool  value)
void omega::SceneNode::setFacingCamera ( Camera cam)
inline

Billboard mode.

void omega::SceneNode::setFacingCameraFixedY ( bool  value)
inline

When set to true, Y axis for nodes facing camera will be fixed to the world Y axis.

When set to false, the Y axis will follow the camera Y axis.

void omega::SceneNode::setFlag ( uint  bit)
inline

Node flags.

void omega::SceneNode::setFollowOffset ( const Vector3f offset,
const Quaternion ooffset 
)
virtual void omega::SceneNode::setParent ( Node parent)
protectedvirtual

Only available internally - notification of parent.

Reimplemented from omega::Node.

void omega::SceneNode::setSelectable ( bool  value)
inline
void omega::SceneNode::setSelected ( bool  value)
void omega::SceneNode::setTag ( const String value)
inline
void omega::SceneNode::setVisible ( bool  value)

Sets this node visibility.

A node visibility does not influence children of the node, but only scene objects attached to the node itself. To change children visibility use setChildrenVisible instead.

void omega::SceneNode::unfollow ( )
void omega::SceneNode::unsetFlag ( uint  bit)
inline
void omega::SceneNode::update ( const UpdateContext context)
virtual

Invoked the update function for all node components on this node and down in the hierarchy.

Reimplemented from omega::Node.

virtual void omega::SceneNode::update ( bool  updateChildren,
bool  parentHasChanged 
)
virtual

Updates all transforms from this node down in the hierarchy.

Reimplemented from omega::Node.

virtual void omega::SceneNode::updateTraversal ( const UpdateContext context)
protectedvirtual

Reimplemented from omega::Node.

Reimplemented in omega::Camera.


The documentation for this class was generated from the following file: