Table of Contents

Class SceneNode

Namespace
HelixToolkit.SharpDX.Model.Scene
Assembly
HelixToolkit.SharpDX.dll
public abstract class SceneNode : DisposeObject, IDisposable, IComparable<SceneNode>, IAnimationNode
Inheritance
SceneNode
Implements
Derived
Inherited Members
Extension Methods

Constructors

SceneNode()

Initializes a new instance of the SceneNode class.

public SceneNode()

SceneNode(string)

Initializes a new instance of the SceneNode class.

public SceneNode(string name)

Parameters

name string

The name.

Fields

MaxBound

The maximum bound

public static readonly BoundingBox MaxBound

Field Value

BoundingBox

MaxBoundSphere

The maximum bound sphere

public static readonly BoundingSphere MaxBoundSphere

Field Value

BoundingSphere

NeedMatrixUpdate

Gets or sets a value indicating whether [need matrix update].

protected bool NeedMatrixUpdate

Field Value

bool

true if [need matrix update]; otherwise, false.

OnSetRenderTechnique

A delegate function to change render technique.

There are two ways to set render technique, one is use this OnSetRenderTechnique delegate. The other one is to override the OnCreateRenderTechnique(IEffectsManager) function.

If OnSetRenderTechnique is set, then OnSetRenderTechnique instead of OnCreateRenderTechnique(IEffectsManager) function will be called.

public SceneNode.SetRenderTechniqueFunc? OnSetRenderTechnique

Field Value

SceneNode.SetRenderTechniqueFunc

Properties

AffectsGlobalVariable

Set this to true if this node updates global variable.

Currently only used by screenspaced node and topmost node

public bool AffectsGlobalVariable { get; protected set; }

Property Value

bool

AlwaysHittable

Gets or sets a value indicating whether [always hittable] even it is not rendered.

public bool AlwaysHittable { get; set; }

Property Value

bool

true if [always hittable]; otherwise, false.

Bounds

public virtual BoundingBox Bounds { get; }

Property Value

BoundingBox

The bounds.

BoundsSphere

public virtual BoundingSphere BoundsSphere { get; }

Property Value

BoundingSphere

The bounds sphere.

BoundsSphereWithTransform

public virtual BoundingSphere BoundsSphereWithTransform { get; }

Property Value

BoundingSphere

The bounds sphere with transform.

BoundsWithTransform

public virtual BoundingBox BoundsWithTransform { get; }

Property Value

BoundingBox

The bounds with transform.

EffectTechnique

Gets the effects technique.

public IRenderTechnique? EffectTechnique { get; }

Property Value

IRenderTechnique

The effects technique.

EffectsManager

Gets the effects manager.

public IEffectsManager? EffectsManager { get; }

Property Value

IEffectsManager

The effects manager.

GUID

public Guid GUID { get; }

Property Value

Guid

HasAnyPostEffect

Gets a value indicating whether this instance has any post effect.

public bool HasAnyPostEffect { get; }

Property Value

bool

true if this instance has any post effect; otherwise, false.

HasBound

Gets or sets a value indicating whether this instance has bound.

public bool HasBound { get; protected set; }

Property Value

bool

true if this instance has bound; otherwise, false.

IsAnimationNode

Gets or sets a value indicating whether this node is animation node.

public bool IsAnimationNode { get; set; }

Property Value

bool

true if this instance is animation node; otherwise, false.

IsAnimationNodeRoot

Gets a value indicating whether this node is animation node root.

public bool IsAnimationNodeRoot { get; }

Property Value

bool

true if this node is animation node root; otherwise, false.

IsAttached

If this has been attached onto renderhost.

public bool IsAttached { get; }

Property Value

bool

IsHitTestVisible

Gets or sets a value indicating whether this instance is hit test visible.

public bool IsHitTestVisible { get; set; }

Property Value

bool

true if this instance is hit test visible; otherwise, false.

IsInFrustum

Gets or sets a value indicating whether this instance is in frustum in current frame.

public bool IsInFrustum { get; }

Property Value

bool

true if this instance is in frustum; otherwise, false.

IsRenderable

Gets or sets a value indicating whether this instance is renderable.

public bool IsRenderable { get; }

Property Value

bool

true if this instance is renderable; otherwise, false.

Items

Gets the readonly child items from outside UI component access.

public ReadOnlyObservableFastList<SceneNode> Items { get; }

Property Value

ReadOnlyObservableFastList<SceneNode>

The children.

ItemsCount

Gets the items count.

public int ItemsCount { get; }

Property Value

int

The items count.

ModelMatrix

Gets or sets the model matrix.

public Matrix4x4 ModelMatrix { get; set; }

Property Value

Matrix4x4

The model matrix.

Name

Gets or sets the name.

public string Name { get; set; }

Property Value

string

The name.

OriginalBounds

public virtual BoundingBox OriginalBounds { get; }

Property Value

BoundingBox

The original bounds.

OriginalBoundsSphere

public virtual BoundingSphere OriginalBoundsSphere { get; }

Property Value

BoundingSphere

The original bounds sphere.

Parent

Gets or sets the parent.

public SceneNode? Parent { get; }

Property Value

SceneNode

The parent.

PostEffectNames

Gets the post effect names.

public IEnumerable<string> PostEffectNames { get; }

Property Value

IEnumerable<string>

The post effect names.

RenderCore

public RenderCore RenderCore { get; }

Property Value

RenderCore

RenderOrder

Gets or sets the render order. Manually specify the render order

public ushort RenderOrder { get; set; }

Property Value

ushort

The render order.

RenderOrderKey

Gets or sets the order key.

public OrderKey RenderOrderKey { get; }

Property Value

OrderKey

The render order key.

RenderType

Gets or sets the type of the render.

public RenderType RenderType { get; set; }

Property Value

RenderType

The type of the render.

Tag

Gets or sets the tag. This can be used to attach an external view model or property class object

public object? Tag { get; set; }

Property Value

object

The tag.

TotalModelMatrix

Gets the total model matrix.

public Matrix4x4 TotalModelMatrix { get; }

Property Value

Matrix4x4

The total model matrix.

Visible

Gets or sets a value indicating whether this SceneNode is visible.

public bool Visible { get; set; }

Property Value

bool

true if visible; otherwise, false.

WrapperSource

Gets or sets the wrapper source used for such as hit test model, etc. The wrapper must set this so the ModelHit is the wrapper.

public object? WrapperSource { get; set; }

Property Value

object

The hit test source.

Methods

AddPostEffect(IEffectAttributes)

Adds the post effect.

public void AddPostEffect(IEffectAttributes effect)

Parameters

effect IEffectAttributes

The effect.

AssignDefaultValuesToCore(RenderCore)

Assigns the default values to core.

protected virtual void AssignDefaultValuesToCore(RenderCore core)

Parameters

core RenderCore

The core.

Attach(IEffectsManager?)

Attaches the element to the specified effectsManager and initialize all necessary graphics resources.

To overide Attach, please override OnAttach(IEffectsManager) function.

To set different render technique instead of using technique from host, override OnCreateRenderTechnique(IEffectsManager)

Attach Flow: OnCreateRenderTechnique(IEffectsManager) -> Set RenderHost -> Get Effect -> OnAttach(IEffectsManager) -> InvalidateSceneGraph()

public void Attach(IEffectsManager? effectsManager)

Parameters

effectsManager IEffectsManager

The effectsManager.

CanHitTest(HitTestContext?)

Determines whether this instance [can hit test] the specified context.

protected virtual bool CanHitTest(HitTestContext? context)

Parameters

context HitTestContext

The context.

Returns

bool

true if this instance [can hit test] the specified context; otherwise, false.

CanRender(RenderContext)

protected virtual bool CanRender(RenderContext context)

Parameters

context RenderContext

Returns

bool

ClearPostEffect()

Clears the post effect.

public void ClearPostEffect()

CompareTo(SceneNode?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(SceneNode? other)

Parameters

other SceneNode

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

ComputeTransformMatrix()

public void ComputeTransformMatrix()

Detach()

Detaches the element from the effectsManager and release all graphics resources. Override OnDetach()

public void Detach()

HasPostEffect(string)

Determines whether [has post effect] [the specified effect name].

public bool HasPostEffect(string effectName)

Parameters

effectName string

Name of the effect.

Returns

bool

true if [has post effect] [the specified effect name]; otherwise, false.

HitTest(HitTestContext?, ref List<HitTestResult>)

Hits the test.

public virtual bool HitTest(HitTestContext? context, ref List<HitTestResult> hits)

Parameters

context HitTestContext

The context.

hits List<HitTestResult>

The hits.

Returns

bool

Invalidate(InvalidateTypes)

Invalidate by type

protected void Invalidate(InvalidateTypes type)

Parameters

type InvalidateTypes

InvalidatePerFrameRenderables()

Invalidates the per frame renderables.

protected void InvalidatePerFrameRenderables()

InvalidateRender()

Tries to invalidate the current render, causes re-render

public void InvalidateRender()

InvalidateRenderEvent(object?, EventArgs)

protected void InvalidateRenderEvent(object? sender, EventArgs arg)

Parameters

sender object
arg EventArgs

InvalidateSceneGraph()

Invalidates the scene graph. Use this if scene graph has been changed.

protected void InvalidateSceneGraph()

OnAttach(IEffectsManager)

To override Attach routine, please override this.

protected virtual bool OnAttach(IEffectsManager effectsManager)

Parameters

effectsManager IEffectsManager

Returns

bool

Return true if attached

OnAttached()

Called when [attached] and IsAttached = true.

protected virtual void OnAttached()

OnCreateRenderCore()

Called when [create render core].

protected virtual RenderCore OnCreateRenderCore()

Returns

RenderCore

OnCreateRenderTechnique(IEffectsManager)

Override this function to set render technique during Attach Host.

If OnSetRenderTechnique is set, then OnSetRenderTechnique instead of OnCreateRenderTechnique(IEffectsManager) function will be called.

protected virtual IRenderTechnique? OnCreateRenderTechnique(IEffectsManager effectsManager)

Parameters

effectsManager IEffectsManager

Returns

IRenderTechnique

Return RenderTechnique

OnDetach()

Used to override Detach

protected virtual void OnDetach()

OnDispose(bool)

Disposes of object resources.

protected override void OnDispose(bool disposeManagedResources)

Parameters

disposeManagedResources bool

If true, managed resources should be disposed of in addition to unmanaged resources.

OnHitTest(HitTestContext?, Matrix4x4, ref List<HitTestResult>)

Called when [hit test].

protected abstract bool OnHitTest(HitTestContext? context, Matrix4x4 totalModelMatrix, ref List<HitTestResult> hits)

Parameters

context HitTestContext

The context.

totalModelMatrix Matrix4x4

The total model matrix.

hits List<HitTestResult>

The hits.

Returns

bool

OnTransformChanged(ref Matrix4x4)

Transforms the changed.

protected virtual void OnTransformChanged(ref Matrix4x4 totalTransform)

Parameters

totalTransform Matrix4x4

The total transform.

OnUpdateRenderOrderKey()

protected virtual OrderKey OnUpdateRenderOrderKey()

Returns

OrderKey

RaiseMouseDownEvent(IViewport3DX, Vector2, HitTestResult, object?)

public void RaiseMouseDownEvent(IViewport3DX viewport, Vector2 pos, HitTestResult hit, object? originalInputEventArgs = null)

Parameters

viewport IViewport3DX
pos Vector2
hit HitTestResult
originalInputEventArgs object

RaiseMouseMoveEvent(IViewport3DX, Vector2, HitTestResult, object?)

public void RaiseMouseMoveEvent(IViewport3DX viewport, Vector2 pos, HitTestResult hit, object? originalInputEventArgs = null)

Parameters

viewport IViewport3DX
pos Vector2
hit HitTestResult
originalInputEventArgs object

RaiseMouseUpEvent(IViewport3DX, Vector2, HitTestResult, object?)

public void RaiseMouseUpEvent(IViewport3DX viewport, Vector2 pos, HitTestResult hit, object? originalInputEventArgs = null)

Parameters

viewport IViewport3DX
pos Vector2
hit HitTestResult
originalInputEventArgs object

RaiseOnBoundChanged(BoundChangeArgs<BoundingBox>)

Raises the on bound changed.

protected void RaiseOnBoundChanged(BoundChangeArgs<BoundingBox> args)

Parameters

args BoundChangeArgs<BoundingBox>

The arguments.

RaiseOnBoundSphereChanged(BoundChangeArgs<BoundingSphere>)

Raises the on bound sphere changed.

protected void RaiseOnBoundSphereChanged(BoundChangeArgs<BoundingSphere> args)

Parameters

args BoundChangeArgs<BoundingSphere>

The arguments.

RaiseOnTransformBoundChanged(BoundChangeArgs<BoundingBox>)

Raises the on transform bound changed.

protected void RaiseOnTransformBoundChanged(BoundChangeArgs<BoundingBox> args)

Parameters

args BoundChangeArgs<BoundingBox>

The arguments.

RaiseOnTransformBoundSphereChanged(BoundChangeArgs<BoundingSphere>)

Raises the on transform bound sphere changed.

protected void RaiseOnTransformBoundSphereChanged(BoundChangeArgs<BoundingSphere> args)

Parameters

args BoundChangeArgs<BoundingSphere>

The arguments.

RemovePostEffect(string)

Removes the post effect.

public void RemovePostEffect(string effectName)

Parameters

effectName string

Name of the effect.

RemoveSelf()

Removes self from scene graph.

public bool RemoveSelf()

Returns

bool

Render(RenderContext, DeviceContextProxy)

Renders the specified context.

public void Render(RenderContext context, DeviceContextProxy deviceContext)

Parameters

context RenderContext

The context.

deviceContext DeviceContextProxy

The device context.

RenderCustom(RenderContext, DeviceContextProxy)

Renders the custom.

public void RenderCustom(RenderContext context, DeviceContextProxy deviceContext)

Parameters

context RenderContext

The context.

deviceContext DeviceContextProxy

The device context.

RenderDepth(RenderContext, DeviceContextProxy, ShaderPass?)

Renders the custom.

public void RenderDepth(RenderContext context, DeviceContextProxy deviceContext, ShaderPass? pass)

Parameters

context RenderContext

The context.

deviceContext DeviceContextProxy

The device context.

pass ShaderPass

RenderShadow(RenderContext, DeviceContextProxy)

Renders the shadow.

public void RenderShadow(RenderContext context, DeviceContextProxy deviceContext)

Parameters

context RenderContext

The context.

deviceContext DeviceContextProxy

The device context.

SetAffectsRender<T>(ref T, T)

protected bool SetAffectsRender<T>(ref T backingField, T value)

Parameters

backingField T
value T

Returns

bool

Type Parameters

T

SetAffectsSceneGraph<T>(ref T, T)

Sets the affects scene graph.

protected bool SetAffectsSceneGraph<T>(ref T backingField, T value)

Parameters

backingField T

The backing field.

value T

The value.

Returns

bool

Type Parameters

T

TestViewFrustum(ref BoundingFrustum)

View frustum test.

public virtual bool TestViewFrustum(ref BoundingFrustum viewFrustum)

Parameters

viewFrustum BoundingFrustum

The frustum.

Returns

bool

TryGetPostEffect(string, out IEffectAttributes?)

Tries the get post effect.

public bool TryGetPostEffect(string effectName, out IEffectAttributes? effect)

Parameters

effectName string

Name of the effect.

effect IEffectAttributes

The effect.

Returns

bool

Update(RenderContext)

Updates the element total transforms, determine renderability, etc. by the specified time span.

public virtual void Update(RenderContext context)

Parameters

context RenderContext

The time since last update.

UpdateNotRender(RenderContext)

public virtual void UpdateNotRender(RenderContext context)

Parameters

context RenderContext

UpdateRenderOrderKey()

Updates the render order key.

public void UpdateRenderOrderKey()

Events

Attached

Occurs when [attached].

public event EventHandler? Attached

Event Type

EventHandler

BoundChanged

Occurs when [on bound changed].

public event EventHandler<BoundChangeArgs<BoundingBox>>? BoundChanged

Event Type

EventHandler<BoundChangeArgs<BoundingBox>>

BoundSphereChanged

Occurs when [on bound sphere changed].

public event EventHandler<BoundChangeArgs<BoundingSphere>>? BoundSphereChanged

Event Type

EventHandler<BoundChangeArgs<BoundingSphere>>

Detached

Occurs when [detached].

public event EventHandler? Detached

Event Type

EventHandler

Invalidated

Occurs when invalidation has happened. This is a bubble up event.

public event EventHandler<InvalidateTypes>? Invalidated

Event Type

EventHandler<InvalidateTypes>

MouseDown

Occurs when [mouse down].

public event EventHandler<SceneNodeMouseDownArgs>? MouseDown

Event Type

EventHandler<SceneNodeMouseDownArgs>

MouseMove

Occurs when [mouse move].

public event EventHandler<SceneNodeMouseMoveArgs>? MouseMove

Event Type

EventHandler<SceneNodeMouseMoveArgs>

MouseUp

Occurs when [mouse up].

public event EventHandler<SceneNodeMouseUpArgs>? MouseUp

Event Type

EventHandler<SceneNodeMouseUpArgs>

NameChanged

public event EventHandler<StringArgs>? NameChanged

Event Type

EventHandler<StringArgs>

TransformBoundChanged

Occurs when [on transform bound changed].

public event EventHandler<BoundChangeArgs<BoundingBox>>? TransformBoundChanged

Event Type

EventHandler<BoundChangeArgs<BoundingBox>>

TransformBoundSphereChanged

Occurs when [on transform bound sphere changed].

public event EventHandler<BoundChangeArgs<BoundingSphere>>? TransformBoundSphereChanged

Event Type

EventHandler<BoundChangeArgs<BoundingSphere>>

TransformChanged

Occurs when [on transform changed].

public event EventHandler<TransformArgs>? TransformChanged

Event Type

EventHandler<TransformArgs>

VisibleChanged

Occurs when [visible changed].

public event EventHandler<BoolArgs>? VisibleChanged

Event Type

EventHandler<BoolArgs>