C# Class Axiom.Core.SceneNode

Represents a node in a scene graph.
A SceneNode is a type of Node which is used to organize 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.
Inheritance: Node
Datei anzeigen Open project: WolfgangSt/axiom Class Usage Examples

Protected Properties

Property Type Description
autoTrackLocalDirection Vector3
autoTrackOffset Vector3
autoTrackTarget SceneNode
creator SceneManager
isInSceneGraph bool
isYawFixed bool
lightList LightList
lightListDirty bool
objectList Axiom.Collections.MovableObjectCollection
showBoundingBox bool
visible bool
wireBox WireBoundingBox
worldAABB Axiom.Math.AxisAlignedBox
worldBoundingSphere Axiom.Math.Sphere
yawFixedAxis Vector3

Public Methods

Method Description
AddBoundingBoxToQueue ( RenderQueue queue ) : void

Adds this nodes bounding box (wireframe) to the RenderQueue.

AttachObject ( Axiom.Core.MovableObject obj ) : void

Attaches a MovableObject to this scene node.

A MovableObject will not show up in the scene until it is attached to a SceneNode.

CreateChildSceneNode ( ) : SceneNode

Creates a new child scene node.

CreateChildSceneNode ( Vector3 translate ) : SceneNode

Creates a new child scene node.

CreateChildSceneNode ( Vector3 translate, Quaternion rotate ) : SceneNode

Creates a new child scene node.

CreateChildSceneNode ( string name ) : SceneNode

Creates a new name child node.

CreateChildSceneNode ( string name, Vector3 translate ) : SceneNode

Creates a new named child scene node.

CreateChildSceneNode ( string name, Vector3 translate, Quaternion rotate ) : SceneNode

Creates a new named child scene node.

DetachAllObjects ( ) : void

Removes all currently attached SceneObjects from this SceneNode.

Bounds for this SceneNode are also updated.

DetachObject ( Axiom.Core.MovableObject obj ) : void

Removes the specifed object from this scene node.

Bounds for this SceneNode are also updated.

FindLights ( float radius ) : LightList

Allows retrieval of the nearest lights to the center of this SceneNode.

This method allows a list of lights, ordered by proximity to the center of this SceneNode, to be retrieved. Multiple access to this method when neither the node nor the lights have moved will result in the same list being returned without recalculation. Can be useful when implementing IRenderable.Lights.

FindVisibleObjects ( Camera camera, RenderQueue queue ) : void

Overloaded method.

FindVisibleObjects ( Camera camera, RenderQueue queue, bool includeChildren, bool displayNodes ) : void

Overloaded method.

FindVisibleObjects ( Camera camera, RenderQueue queue, bool includeChildren, bool displayNodes, bool onlyShadowCasters ) : void

Internal method which locates any visible objects attached to this node and adds them to the passed in queue.

GetDebugRenderable ( ) : Node.DebugRenderable
GetObject ( int index ) : Axiom.Core.MovableObject

Returns a movable object attached to this node by index. Node that this method is O(n), whereas the string overload of this method is O(1). Use the string version of this method if speed is important.

GetObject ( string name ) : Axiom.Core.MovableObject

Returns a movable object attached to this node by name. Node that this method is O(n), whereas the integer overload of this method is O(1). Use the integer version of this method if speed is important.

LookAt ( Vector3 target, TransformSpace relativeTo ) : void
LookAt ( Vector3 target, TransformSpace relativeTo, Vector3 localDirection ) : void

Points the local Z direction of this node at a point in space.

NotifyAttachedObjectNameChanged ( Axiom.Core.MovableObject obj ) : void

Rekeys the scene object using its new Name

RemoveAndDestroyAllChildren ( ) : void

Removes and destroys all children in the subtree of this node.

Use this to destroy all nodes found in the child subtree of this node and remove them from the scene graph. Note that all objects attached to the nodes will be detached but will not be destroyed.

RemoveAndDestroyChild ( SceneNode sceneNode ) : void

This method removes and destroys the child and all of its children.

Unlike removeChild, which removes a single named child from this node but does not destroy it, this method destroys the child and all of it's children.

Use this if you wish to recursively destroy a node as well as detaching it from it's parent. Note that any objects attached to the nodes will be detached but will not themselves be destroyed.

RemoveAndDestroyChild ( String name ) : void

This method removes and destroys the child and all of its children.

Unlike removeChild, which removes a single named child from this node but does not destroy it, this method destroys the child and all of it's children.

Use this if you wish to recursively destroy a node as well as detaching it from it's parent. Note that any objects attached to the nodes will be detached but will not themselves be destroyed.

SceneNode ( SceneManager creator ) : System

Basic constructor. Takes a scene manager reference to record the creator.

Can be created manually, but should be left the Create* Methods.

SceneNode ( SceneManager creator, string name ) : System

Overloaded constructor. Takes a scene manager reference to record the creator, and a name for the node.

SetAsRootNode ( ) : void

Only called by SceneManagers

SetAutoTracking ( bool enabled ) : void
SetAutoTracking ( bool enabled, SceneNode target ) : void
SetAutoTracking ( bool enabled, SceneNode target, Vector3 localDirection ) : void
SetAutoTracking ( bool enabled, SceneNode target, Vector3 localDirection, Vector3 offset ) : void

Enables / disables automatic tracking of another SceneNode.

If you enable auto-tracking, this SceneNode will automatically rotate to point it's -Z at the target SceneNode every frame, no matter how it or the other SceneNode move. Note that by default the -Z points at the origin of the target SceneNode, if you want to tweak this, provide a vector in the 'offset' parameter and the target point will be adjusted.

SetDirection ( Real x, Real y, Real z ) : void
SetDirection ( Real x, Real y, Real z, TransformSpace relativeTo ) : void
SetDirection ( Real x, Real y, Real z, TransformSpace relativeTo, Vector3 localDirectionVector ) : void

Sets the node's direction vector ie it's local -z.

Note that the 'up' vector for the orientation will automatically be recalculated based on the current 'up' vector (i.e. the roll will remain the same). If you need more control, use the property.

SetDirection ( Vector3 vec ) : void
SetDirection ( Vector3 vec, TransformSpace relativeTo ) : void
SetDirection ( Vector3 vec, TransformSpace relativeTo, Vector3 localDirection ) : void

Sets the node's direction vector ie it's local -z.

Note that the 'up' vector for the orientation will automatically be recalculated based on the current 'up' vector (i.e. the roll will remain the same). If you need more control, use the property.

SetFixedYawAxis ( bool useFixed ) : void

Sets a default fixed yaw axis of Y.

SetFixedYawAxis ( bool useFixed, Vector3 fixedAxis ) : void

Tells the node whether to yaw around it's own local Y axis or a fixed axis of choice.

This method allows you to change the yaw behavior of the node - by default, it yaws around it's own local Y axis when told to yaw with TransformSpace.Local, this makes it yaw around a fixed axis. You only really need this when you're using auto tracking (SetAutoTracking(bool), because when you're manually rotating a node you can specify the TransformSpace in which you wish to work anyway.

Yaw ( float degrees ) : void

Overridden to apply fixed yaw axis behavior.

Protected Methods

Method Description
CreateChildImpl ( ) : Node

CreateChildImpl ( string name ) : Node

OnRename ( string oldName ) : void
Update ( bool updateChildren, bool hasParentChanged ) : void

Internal method to update the Node.

Updates this scene node and any relevant children to incorporate transforms etc. Don't call this yourself unless you are writing a SceneManager implementation.

UpdateBounds ( ) : void

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

UpdateFromParent ( ) : void

dispose ( bool disposeManagedResources ) : void

Private Methods

Method Description
AutoTrack ( ) : void

Internal method used to update auto-tracking scene nodes.

Clear ( ) : void

Need to clear list of child objects in addition to base class functionality.

Method Details

AddBoundingBoxToQueue() public method

Adds this nodes bounding box (wireframe) to the RenderQueue.
public AddBoundingBoxToQueue ( RenderQueue queue ) : void
queue Axiom.Graphics.RenderQueue
return void

AttachObject() public method

Attaches a MovableObject to this scene node.
A MovableObject will not show up in the scene until it is attached to a SceneNode.
public AttachObject ( Axiom.Core.MovableObject obj ) : void
obj Axiom.Core.MovableObject
return void

CreateChildImpl() protected method

protected CreateChildImpl ( ) : Node
return Node

CreateChildImpl() protected method

protected CreateChildImpl ( string name ) : Node
name string
return Node

CreateChildSceneNode() public method

Creates a new child scene node.
public CreateChildSceneNode ( ) : SceneNode
return SceneNode

CreateChildSceneNode() public method

Creates a new child scene node.
public CreateChildSceneNode ( Vector3 translate ) : SceneNode
translate Vector3 A vector to specify the position relative to the parent.
return SceneNode

CreateChildSceneNode() public method

Creates a new child scene node.
public CreateChildSceneNode ( Vector3 translate, Quaternion rotate ) : SceneNode
translate Vector3 A vector to specify the position relative to the parent.
rotate Axiom.Math.Quaternion A quaternion to specify the orientation relative to the parent.
return SceneNode

CreateChildSceneNode() public method

Creates a new name child node.
public CreateChildSceneNode ( string name ) : SceneNode
name string
return SceneNode

CreateChildSceneNode() public method

Creates a new named child scene node.
public CreateChildSceneNode ( string name, Vector3 translate ) : SceneNode
name string Name of the node.
translate Vector3 A vector to specify the position relative to the parent.
return SceneNode

CreateChildSceneNode() public method

Creates a new named child scene node.
public CreateChildSceneNode ( string name, Vector3 translate, Quaternion rotate ) : SceneNode
name string Name of the node.
translate Vector3 A vector to specify the position relative to the parent.
rotate Axiom.Math.Quaternion A quaternion to specify the orientation relative to the parent.
return SceneNode

DetachAllObjects() public method

Removes all currently attached SceneObjects from this SceneNode.
Bounds for this SceneNode are also updated.
public DetachAllObjects ( ) : void
return void

DetachObject() public method

Removes the specifed object from this scene node.
Bounds for this SceneNode are also updated.
public DetachObject ( Axiom.Core.MovableObject obj ) : void
obj Axiom.Core.MovableObject Reference to the object to remove.
return void

FindLights() public method

Allows retrieval of the nearest lights to the center of this SceneNode.
This method allows a list of lights, ordered by proximity to the center of this SceneNode, to be retrieved. Multiple access to this method when neither the node nor the lights have moved will result in the same list being returned without recalculation. Can be useful when implementing IRenderable.Lights.
public FindLights ( float radius ) : LightList
radius float Parameter to specify lights intersecting a given radius of /// this SceneNode's centre
return LightList

FindVisibleObjects() public method

Overloaded method.
public FindVisibleObjects ( Camera camera, RenderQueue queue ) : void
camera Camera
queue Axiom.Graphics.RenderQueue
return void

FindVisibleObjects() public method

Overloaded method.
public FindVisibleObjects ( Camera camera, RenderQueue queue, bool includeChildren, bool displayNodes ) : void
camera Camera
queue Axiom.Graphics.RenderQueue
includeChildren bool
displayNodes bool
return void

FindVisibleObjects() public method

Internal method which locates any visible objects attached to this node and adds them to the passed in queue.
public FindVisibleObjects ( Camera camera, RenderQueue queue, bool includeChildren, bool displayNodes, bool onlyShadowCasters ) : void
camera Camera Active camera.
queue Axiom.Graphics.RenderQueue Queue to which these objects should be added.
includeChildren bool If true, cascades down to all children.
displayNodes bool Renders the local axes for the node.
onlyShadowCasters bool
return void

GetDebugRenderable() public method

public GetDebugRenderable ( ) : Node.DebugRenderable
return Node.DebugRenderable

GetObject() public method

Returns a movable object attached to this node by index. Node that this method is O(n), whereas the string overload of this method is O(1). Use the string version of this method if speed is important.
public GetObject ( int index ) : Axiom.Core.MovableObject
index int The index of the object to return.
return Axiom.Core.MovableObject

GetObject() public method

Returns a movable object attached to this node by name. Node that this method is O(n), whereas the integer overload of this method is O(1). Use the integer version of this method if speed is important.
public GetObject ( string name ) : Axiom.Core.MovableObject
name string The name of the object to return.
return Axiom.Core.MovableObject

LookAt() public method

public LookAt ( Vector3 target, TransformSpace relativeTo ) : void
target Vector3
relativeTo TransformSpace
return void

LookAt() public method

Points the local Z direction of this node at a point in space.
public LookAt ( Vector3 target, TransformSpace relativeTo, Vector3 localDirection ) : void
target Vector3 A vector specifying the look at point.
relativeTo TransformSpace The space in which the point resides.
localDirection Vector3 /// The vector which normally describes the natural direction of the node, usually -Z. ///
return void

NotifyAttachedObjectNameChanged() public method

Rekeys the scene object using its new Name
public NotifyAttachedObjectNameChanged ( Axiom.Core.MovableObject obj ) : void
obj Axiom.Core.MovableObject
return void

OnRename() protected method

protected OnRename ( string oldName ) : void
oldName string
return void

RemoveAndDestroyAllChildren() public method

Removes and destroys all children in the subtree of this node.
Use this to destroy all nodes found in the child subtree of this node and remove them from the scene graph. Note that all objects attached to the nodes will be detached but will not be destroyed.
public RemoveAndDestroyAllChildren ( ) : void
return void

RemoveAndDestroyChild() public method

This method removes and destroys the child and all of its children.
Unlike removeChild, which removes a single named child from this node but does not destroy it, this method destroys the child and all of it's children.

Use this if you wish to recursively destroy a node as well as detaching it from it's parent. Note that any objects attached to the nodes will be detached but will not themselves be destroyed.

public RemoveAndDestroyChild ( SceneNode sceneNode ) : void
sceneNode SceneNode The node to remove and destroy
return void

RemoveAndDestroyChild() public method

This method removes and destroys the child and all of its children.
Unlike removeChild, which removes a single named child from this node but does not destroy it, this method destroys the child and all of it's children.

Use this if you wish to recursively destroy a node as well as detaching it from it's parent. Note that any objects attached to the nodes will be detached but will not themselves be destroyed.

public RemoveAndDestroyChild ( String name ) : void
name String name of the node to remove and destroy
return void

SceneNode() public method

Basic constructor. Takes a scene manager reference to record the creator.
Can be created manually, but should be left the Create* Methods.
public SceneNode ( SceneManager creator ) : System
creator SceneManager
return System

SceneNode() public method

Overloaded constructor. Takes a scene manager reference to record the creator, and a name for the node.
public SceneNode ( SceneManager creator, string name ) : System
creator SceneManager
name string
return System

SetAsRootNode() public method

Only called by SceneManagers
public SetAsRootNode ( ) : void
return void

SetAutoTracking() public method

public SetAutoTracking ( bool enabled ) : void
enabled bool
return void

SetAutoTracking() public method

public SetAutoTracking ( bool enabled, SceneNode target ) : void
enabled bool
target SceneNode
return void

SetAutoTracking() public method

public SetAutoTracking ( bool enabled, SceneNode target, Vector3 localDirection ) : void
enabled bool
target SceneNode
localDirection Vector3
return void

SetAutoTracking() public method

Enables / disables automatic tracking of another SceneNode.
If you enable auto-tracking, this SceneNode will automatically rotate to point it's -Z at the target SceneNode every frame, no matter how it or the other SceneNode move. Note that by default the -Z points at the origin of the target SceneNode, if you want to tweak this, provide a vector in the 'offset' parameter and the target point will be adjusted.
public SetAutoTracking ( bool enabled, SceneNode target, Vector3 localDirection, Vector3 offset ) : void
enabled bool /// If true, tracking will be enabled and the 'target' cannot be null. /// If false tracking will be disabled and the current orientation will be maintained. ///
target SceneNode /// Reference to the SceneNode to track. Can be null if and only if the enabled param is false. ///
localDirection Vector3 /// The local vector considered to be the usual 'direction' /// of the node; normally the local -Z but can be another direction. ///
offset Vector3 /// If supplied, this is the target point in local space of the target node /// instead of the origin of the target node. Good for fine tuning the look at point. ///
return void

SetDirection() public method

public SetDirection ( Real x, Real y, Real z ) : void
x Real
y Real
z Real
return void

SetDirection() public method

public SetDirection ( Real x, Real y, Real z, TransformSpace relativeTo ) : void
x Real
y Real
z Real
relativeTo TransformSpace
return void

SetDirection() public method

Sets the node's direction vector ie it's local -z.
Note that the 'up' vector for the orientation will automatically be recalculated based on the current 'up' vector (i.e. the roll will remain the same). If you need more control, use the property.
public SetDirection ( Real x, Real y, Real z, TransformSpace relativeTo, Vector3 localDirectionVector ) : void
x Real The x component of the direction vector.
y Real The y component of the direction vector.
z Real The z component of the direction vector.
relativeTo TransformSpace The space in which this direction vector is expressed.
localDirectionVector Vector3 The vector which normally describes the natural direction /// of the node, usually -Z. ///
return void

SetDirection() public method

public SetDirection ( Vector3 vec ) : void
vec Vector3
return void

SetDirection() public method

public SetDirection ( Vector3 vec, TransformSpace relativeTo ) : void
vec Vector3
relativeTo TransformSpace
return void

SetDirection() public method

Sets the node's direction vector ie it's local -z.
Note that the 'up' vector for the orientation will automatically be recalculated based on the current 'up' vector (i.e. the roll will remain the same). If you need more control, use the property.
public SetDirection ( Vector3 vec, TransformSpace relativeTo, Vector3 localDirection ) : void
vec Vector3 The direction vector.
relativeTo TransformSpace The space in which this direction vector is expressed.
localDirection Vector3 The vector which normally describes the natural direction /// of the node, usually -Z. ///
return void

SetFixedYawAxis() public method

Sets a default fixed yaw axis of Y.
public SetFixedYawAxis ( bool useFixed ) : void
useFixed bool
return void

SetFixedYawAxis() public method

Tells the node whether to yaw around it's own local Y axis or a fixed axis of choice.
This method allows you to change the yaw behavior of the node - by default, it yaws around it's own local Y axis when told to yaw with TransformSpace.Local, this makes it yaw around a fixed axis. You only really need this when you're using auto tracking (SetAutoTracking(bool), because when you're manually rotating a node you can specify the TransformSpace in which you wish to work anyway.
public SetFixedYawAxis ( bool useFixed, Vector3 fixedAxis ) : void
useFixed bool /// If true, the axis passed in the second parameter will always be the yaw axis no /// matter what the node orientation. If false, the node returns to it's default behavior. ///
fixedAxis Vector3 The axis to use if the first parameter is true.
return void

Update() protected method

Internal method to update the Node.
Updates this scene node and any relevant children to incorporate transforms etc. Don't call this yourself unless you are writing a SceneManager implementation.
protected Update ( bool updateChildren, bool hasParentChanged ) : void
updateChildren bool
hasParentChanged bool
return void

UpdateBounds() protected method

Tell the SceneNode to update the world bound info it stores.
protected UpdateBounds ( ) : void
return void

UpdateFromParent() protected method

protected UpdateFromParent ( ) : void
return void

Yaw() public method

Overridden to apply fixed yaw axis behavior.
public Yaw ( float degrees ) : void
degrees float
return void

dispose() protected method

protected dispose ( bool disposeManagedResources ) : void
disposeManagedResources bool
return void

Property Details

autoTrackLocalDirection protected_oe property

Local 'normal' direction vector.
protected Vector3 autoTrackLocalDirection
return Vector3

autoTrackOffset protected_oe property

Tracking offset for fine tuning.
protected Vector3 autoTrackOffset
return Vector3

autoTrackTarget protected_oe property

Auto tracking target.
protected SceneNode,Axiom.Core autoTrackTarget
return SceneNode

creator protected_oe property

Reference to the scene manager who created me.
protected SceneManager,Axiom.Core creator
return SceneManager

isInSceneGraph protected_oe property

Is this node a current part of the scene graph?
protected bool isInSceneGraph
return bool

isYawFixed protected_oe property

Where to yaw around a fixed axis.
protected bool isYawFixed
return bool

lightList protected_oe property

List of lights within range of this node.
protected LightList lightList
return LightList

lightListDirty protected_oe property

Keeps track of whether the list of lights located near this node needs updating.
protected bool lightListDirty
return bool

objectList protected_oe property

A collection of all objects attached to this scene node.
protected MovableObjectCollection,Axiom.Collections objectList
return Axiom.Collections.MovableObjectCollection

showBoundingBox protected_oe property

Whether or not to display this node's bounding box.
protected bool showBoundingBox
return bool

visible protected_oe property

Determines whether node and children are visible or not.
protected bool visible
return bool

wireBox protected_oe property

Renderable bounding box for this node.
protected WireBoundingBox,Axiom.Core wireBox
return WireBoundingBox

worldAABB protected_oe property

Bounding box. Updated through Update.
protected AxisAlignedBox,Axiom.Math worldAABB
return Axiom.Math.AxisAlignedBox

worldBoundingSphere protected_oe property

Word bounding sphere surrounding this node.
protected Sphere,Axiom.Math worldBoundingSphere
return Axiom.Math.Sphere

yawFixedAxis protected_oe property

Fixed axis to yaw around.
protected Vector3 yawFixedAxis
return Vector3