SceneNode Class |
Namespace: DigitalRune.Graphics.SceneGraph
The SceneNode type exposes the following members.
Name | Description | |
---|---|---|
Clone |
Creates a new SceneNode that is a clone of the current instance (incl. all
children).
| |
CloneCore |
Makes the instance a clone (deep copy) of the specified SceneNode.
| |
CreateInstanceCore |
When implemented in a derived class, creates a new instance of the
SceneNode derived class.
| |
Dispose(Boolean) |
Releases all resources used by the scene node and all descendant nodes.
| |
Dispose(Boolean, Boolean) |
Releases the unmanaged resources used by an instance of the SceneNode class
and optionally releases the managed resources.
| |
Equals | (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Invalidate |
Invalidates this scene node and all children.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnParentChanged |
Called when Parent was changed.
| |
OnPoseChanged |
Raises the PoseChanged event.
| |
OnSceneChanged |
Raises the SceneChanged event.
| |
OnShapeChanged |
Raises the ShapeChanged event.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
ClearLastPose |
Clears the LastPoseWorld property of the current scene node (and its
descendants).
(Defined by SceneHelper.) | |
ClearLastScale |
Clears the LastScaleWorld property of the current scene node (and
its descendants).
(Defined by SceneHelper.) | |
Contains |
Determines whether whether a scene node contains another scene node in its subtree.
(Defined by SceneHelper.) | |
GetAncestors |
Gets the ancestors of the given scene node.
(Defined by SceneHelper.) | |
GetChildren |
Gets the children of the given scene node.
(Defined by SceneHelper.) | |
GetDescendants | Overloaded.
Gets the descendants of the given scene node using a depth-first search.
(Defined by SceneHelper.) | |
GetDescendants(Boolean) | Overloaded.
Gets the descendants of the given scene node using a depth-first or a breadth-first search.
(Defined by SceneHelper.) | |
GetLeaves |
Gets the leaves of the scene node.
(Defined by SceneHelper.) | |
GetRoot |
Gets the root node.
(Defined by SceneHelper.) | |
GetSceneNode |
Gets a scene node by name from the subtree of the specified scene node.
(Defined by SceneHelper.) | |
GetSelfAndAncestors |
Gets the scene node and its ancestors scene.
(Defined by SceneHelper.) | |
GetSubtree | Overloaded.
Gets the subtree (the given scene node and all of its descendants) using a depth-first
search.
(Defined by SceneHelper.) | |
GetSubtree(Boolean) | Overloaded.
Gets the subtree (the given scene node and all of its descendants) using a depth-first or a
breadth-first search.
(Defined by SceneHelper.) | |
GetSubtreeAabb |
Gets the AABB of the current subtree.
(Defined by SceneHelper.) | |
LookAt(Vector3F, Vector3F) | Overloaded.
Rotates the scene node so that it faces a certain direction (in world space).
(Defined by SceneHelper.) | |
LookAt(Vector3F, Vector3F, Vector3F) | Overloaded.
Moves and rotates the scene node so that it faces a certain direction (in world space).
(Defined by SceneHelper.) | |
SetInstanceAlpha |
Sets the opacity (alpha) of a scene node - see remarks.
(Defined by SceneHelper.) | |
SetLastPose |
Sets LastPoseWorld to the current
PoseWorld.
(Defined by SceneHelper.) | |
SetLastScale |
Sets LastScaleWorld to the current
ScaleWorld.
(Defined by SceneHelper.) | |
SupportsInstanceAlpha |
Determines whether the opacity of the scene node can be changed using
SetInstanceAlpha(SceneNode, Single).
(Defined by SceneHelper.) |
Name | Description | |
---|---|---|
Aabb |
Gets the axis-aligned bounding box (AABB) in world space.
| |
ActualIsEnabled |
Gets a value indicating whether this scene node is actually enabled. (The method checks the
current scene node and its ancestors.)
| |
CastsShadows |
Gets or sets a value indicating whether this scene node blocks the light and casts shadows.
| |
Children |
Gets or sets the children of this scene node.
| |
IsDisposed |
Gets a value indicating whether this scene node has been disposed of.
| |
IsEnabled |
Gets or sets a value indicating whether this scene node is enabled. (May override children -
see remarks.)
| |
IsRenderable |
Gets or sets a value indicating whether this scene node can be rendered with a
SceneNodeRenderer.
| |
IsShadowCasterCulled |
Gets or sets a value indicating whether the occlusion culling determined that this scene
node does not need to be rendered into the shadow map of the directional light.
| |
IsStatic |
Gets or sets a value indicating whether this scene node is static (immobile).
| |
LastFrame |
Gets or sets the number of the last frame in which the scene node was rendered.
| |
LastPoseWorld |
Gets or sets the PoseWorld of the last frame.
| |
LastScaleWorld |
Gets or sets the ScaleWorld of the last frame.
| |
MaxDistance |
Gets or sets the maximum distance up to which the scene node is rendered. (Needs to be
normalized - see remarks.)
| |
Name |
Gets or sets the name of this scene node.
| |
Parent |
Gets the parent scene node.
| |
PoseLocal |
Gets or sets the pose (position and orientation) relative to the parent scene node.
| |
PoseWorld |
Gets or sets the pose (position and orientation) in world space.
| |
Proxy |
Gets or sets the proxy node.
| |
RenderData |
Gets or sets the cached renderer data.
| |
ScaleLocal |
Gets or sets the scale relative to the parent scene node.
| |
ScaleWorld |
Gets the total effective scale (which incorporates the scale factors of parent scene nodes).
| |
SceneData |
Gets or sets scene data.
| |
Shape |
Gets (or sets) the bounding shape of this scene node.
| |
SortTag |
Gets or sets the sort tag.
| |
UserData |
Gets or sets user-defined data.
| |
UserFlags |
Gets or sets a 16-bit value which can be used to store user-defined information or flags.
|
Name | Description | |
---|---|---|
SceneChanged |
Occurs when the local subtree changed.
| |
ShapeChanged |
Occurs when the Shape or ScaleWorld was changed.
|
Name | Description | |
---|---|---|
IDisposableDispose |
Releases all resources used by the scene node and all descendant nodes.
| |
IGeometricObjectClone |
Creates a new IGeometricObject that is a clone (deep copy) of the current
instance.
| |
IGeometricObjectPose |
Gets the pose (position and orientation) in world space.
| |
IGeometricObjectPoseChanged |
Occurs when the pose was changed.
| |
IGeometricObjectScale |
Gets the total effective scale (which incorporates the scale factors of parent scene nodes).
|
A SceneNode usually represents an instance of a graphics object in a 3D scene. See derived classes such as MeshNode, CameraNode, LightNode, etc.
A scene node can have a transformation (see ScaleLocal/PoseLocal, ScaleWorld/PoseWorld), a bounding shape (see Shape), a parent and children (see Parent, Children).
Scene Graph:
The scene node hierarchy, defined by the properties Parent and
Children, is a tree (a graph without cycles). A scene node can only have zero or
one parent - it cannot be the child of multiple other nodes. Scene nodes are attached to their
parent: When the parent node is transformed (rotated or translated) in a scene, all descendant
nodes move together with the parent node.
Local Transformation vs. World Transformation:
ScaleLocal and PoseLocal describe the local transformation of a
node relative to its parent node. ScaleWorld and PoseWorld
describe the absolute transformation of a node in world space.
The transformation can be set either in local space (using ScaleLocal and PoseLocal) or in world space (using PoseWorld). The other properties will be updated automatically. (Note: ScaleWorld cannot be set directly - the property is read-only.)
The local transformation is the dominant transformation: When a scene node is detached from its parent and attached to another scene node, it will be placed relative to the new parent. The local transformation will remain the same, but the world transformation will change - except when the parent's transformation is the identity transform.
Non-uniform Scaling:
Non-uniform scaling of scene nodes or subtrees is supported, but it should be used with care.
Non-uniform scalings can be expensive because they require special treatment. (Imagine a scene
node which has a bounding sphere. When the node is scaled non-uniformly, the sphere becomes an
ellipsoid. An ellipsoid requires a different collision algorithm than a simple sphere...)
No Shearing:
Certain combinations of non-uniform scalings and rotations can create shear transformations.
Shearing complicates the scene management and prevents certain optimizations. Shearing is
therefore not supported! The scene graph automatically eliminates any shearing.
Transformation of Previous Frame:
A scene node additionally has two optional properties: LastScaleWorld and
LastPoseWorld. These properties define the scene node's transformation of the
last frame that was rendered. This information is required by certain effects, such as object
motion blur or camera motion blur. Important: These properties are not set
automatically! LastScaleWorld and LastPoseWorld need to be updated
by the application logic whenever the transformation of the scene node is changed.
The Shape can be set to Infinite. In this case the scene node is never culled during frustum culling and is always visible.
Some scene nodes have an Empty bounding shape. These scene nodes are ignored in scene queries. I.e. they do not show up in the query results! Newly created scene nodes have an Empty bounding shape. The Scene and ModelNode also have an Empty shape. (These types of nodes are just used to group other nodes in the scene graph. They can be ignored during rendering.)
The root of a scene hierarchy is usually the Scene. However, SceneNode objects can also be used independently from a Scene object. For example, when a ModelNode is loaded the model hierarchy is also defined as a tree of scene nodes. ModelNodes can be placed inside a Scene, but they can also be used and rendered independently from a Scene object.
Tree Traversal:
SceneHelper provides various helper methods to traverse the scene tree using
LINQ: See
GetRoot(SceneNode),
GetAncestors(SceneNode),
GetSelfAndAncestors(SceneNode),
GetChildren(SceneNode),
GetDescendants(SceneNode),
GetSubtree(SceneNode),
GetLeaves(SceneNode)
Cloning:
Scene nodes are cloneable. Clone makes a copy of the current scene node and
recursively clones all children. The purpose of Clone is to replicate a single
scene node or an entire tree of scene nodes in a scene. For example, by repeatedly calling
Clone on a MeshNode multiple copies ("instances") of a
Mesh object can be placed within a scene.
A scene node contains instance data, which is specific to a certain scene node object and shared data, which can be shared by multiple scene nodes. For example, a MeshNode contains MaterialInstances, which are unique for each mesh node, and a Mesh, which can be shared by multiple mesh nodes. By cloning a scene node all instance data is duplicated (deep copy), but the shared data is only copied by reference (shallow copy). So, when a MeshNode is cloned, the original and the cloned mesh node will have a unique set of material instances (MaterialInstances), but both will share the same Mesh.
Any object stored in UserData is copied per reference (shallow copy). SceneData and RenderData are never copied when the scene node is cloned.
Scene Node Sorting:
In many cases scene nodes need to be sorted. For example:
Scene Node Disposal (Potential Memory Leaks!)
Scene nodes implement IDisposable. The Dispose(Boolean) method should
be called when the scene node is no longer needed. This is necessary in order to prevent
potential memory leaks. Once the method has been called, the scene node is no longer usable.
Reusing a previously disposed scene node may result in undefined behavior!
When calling Dispose(Boolean), the parameter determines whether data objects (such as vertex buffers, index buffers, etc.) are disposed or preserved. Disposing scene nodes including data objects can be dangerous because resources might be shared and still used by other scene nodes. It is therefore recommended to pass as parameter - unless it is certain that the resources are no longer needed.
Any data stored in RenderData, SceneData, or UserData is disposed together with the scene node.