SceneObject

Description

abstract class Tinman.Engine.Scenes.SceneObject

Derived from

Disposable abstract
ISceneObject

Extended by

SceneEntityBase abstract
SceneEntityView abstract

Abstract base class for ISceneObject implementations.

By convention, scene objects serialize property values to JSON via the IJsonizable interface only for properties that are annotated with JsonProperty.

Subclasses shall signal their dirty state by calling the DirtyState method, optionally overriding the DirtyStateCheck method to implement custom dirty state checks. All dirty state processing should be performed in the subsequent call to DoUpdateState.

Subclasses should call ChildBindings whenever their scene binding state changes (for example, attach to / detach from a scene, upon disposal). Then, the following helper may be used by them, in order to manage their aggregated child objects:

To manage aggregated IMeshBound child objects at a lower level, these methods can be used:

The default implementations of ISceneObject.QueryDistance and ISceneObject.QueryRay produce no query results. Overriding methods may use the following helpers:

The default implementation of ISceneObject.CallbackMask returns SceneObjectCallback.All.

Protected / Constructors

Scene​Object


protected constructor SceneObject → (1)

callbackMask in : SceneObjectCallback

The value for ISceneObject.CallbackMask.

Creates a new instance of SceneObject.

Protected / Methods

Assert​Attached


[Assertion]
protected method AssertAttached → (1)

source in : string @ Tag

The error source tag.

Asserts that this entity is attached to a scene.

Child​Binding

2 overloads


protected virtual method ChildBinding1 → (2)

child in : object

The aggregated child object whose binding state to update. If null, this method returns silently.

attach in : bool

true if child in needs to be attached,
false if child in needs to be detached.

Updates the scene binding state of child in.

If ISceneObject.Scene returns null when this method is called, it will return silently. Otherwise, its default implementation will call the following methods:

Subclasses may override this method in order to provide additional binding logic.


protected method ChildBinding2 → (2)

previous in : object

The object to unbind.

current in : object

The object to bind.

Updates the scene binding state of the previous in object (detach) and current in (attach), by delegating to ChildBinding1 accordingly.

This method is intended to be called from the setters of properties of subclasses, which are used to set aggregated objects (for example, a ITerrainTransform object). Doing so will update the scene binding state of both the old and the new object, in a null-safe way.

Child​Binding​All

2 overloads


protected method ChildBindingAll1 → (2)<T ref>

children in : T [ ]

The child element container or null.

attach in : bool

true if children in need to be attached,
false if children in need to be detached.

This helper method iterates over children in and calls ChildBinding1 for each element.


protected method ChildBindingAll2 → (2)<T ref>

children in : IEnumerable<T>

The child element container or null.

attach in : bool

true if children in need to be attached,
false if children in need to be detached.

This helper method iterates over children in and calls ChildBinding1 for each element.

Child​Bindings


[EmptyBody]
protected virtual method ChildBindings → (1)

attach in : bool

true if having been attached,
false if about to be detached

This method is called when a scene object is attached to / detached from a scene or a scene view.

Implementing methods should call ChildBinding1 (passing attach in), in order to update the scene binding state of the objects they aggregate. When this method is called, ISceneObject.Scene always returns a non-null value.

If the implementing class has aggregated child objects which may be configured via properties, those should make use of ChildBinding2.

Dirty​Frame


protected method DirtyFrame → ()

This method may be called to indicate that the dirty state of this scene object requires that a new frame is rendered.

After calling this method, the next call to IUpdateableFrameTime.UpdateFrameTime will return true, which will trigger rendering of a new frame. This method is called automatically after DoUpdateState, so usually it is not necessary to call it explicitly.

Dirty​State


protected method DirtyState → ()

Marks the state of this scene object as dirty, so that ISceneObject.NeedsUpdateState will return true.

Calling this method will trigger a subsequent call to DoUpdateState, followed by a call to DirtyFrame. To skip dirty state processing and just trigger rendering of a new frame, call the DirtyFrame method instead of DirtyState.

Dirty​State​Check


[EmptyBody]
protected virtual method DirtyStateCheck → ()

Subclasses may override this method in order to perform custom dirty state checks, and to call DirtyState as result.

Dirty​State​If​Outdated


protected method DirtyStateIfOutdated → (2)

version in : int32

The version to check for.

versioned in : IVersioned

The versioned object. If null, the current version is assumed to be 0.

returns → int32

The current version of versioned in.

Calls DirtyState if the current version of versioned in is not equal to version in.

Do​Update​State


[EmptyBody]
protected virtual method DoUpdateState → ()

Updates the state of this scene object, in order to reflect all recent changes.

This method will be called from within ISceneObject.UpdateState only when ISceneObject.NeedsUpdateState is true. The ISceneObject.NeedsUpdateState flag is reset to false before this method is called. The DirtyFrame method is called after calling this method.

Mesh​Attach


protected method MeshAttach → (1)

meshBound in : IMeshBound

[not-null]
The object to bind to the terrain mesh. If IMeshBound.MeshBind throws an TinmanException, this method will call IMeshBound.MeshUnbind in turn and return silently.

Attaches the given IMeshBound object to the underlying terrain mesh, by calling IMeshBound.MeshBind on it.

This scene object must be attached to a scene.

Mesh​Detach


protected method MeshDetach → (1)

meshBound in : IMeshBound

[not-null]
The object to unbind from the terrain mesh.

Detaches the given IMeshBound object from the underlying terrain mesh, by calling IMeshBound.MeshUnbind on it.

This scene object must be attached to a scene.

Query​Filter


[Pure]
protected method QueryFilter → (1)

mask in : int64

The spatial query filter mask.

returns → bool

true to include this scene object in the spatial query,
false to ignore it.

Checks if this scene object shall be included in a spatial query.

This method is intended to be used in implementations of ISceneObject.QueryDistance. It should not be used in other implementations of ISceneQueryProvider, where the ISceneQueryResultBuilder.ResultCheck1 method should be used instead.

Query​Model​Result


protected method QueryModelResult → (3)

model in : TerrainModel

[not-null]
The terrain model.

ray in : Ray

The ray.

builder in : ISceneQueryResultBuilder

[not-null]
The query result builder.

returns → bool

true if a query result has been output to builder in,
false if there is no query result.

Performs a ray intersection query for the given terrain model.

If the ray hits the given model in, a ModelResult is generated, using ISceneObject.QuerySceneObjectResult as IParentObjectContainer.ParentObject.

Query​Screen​Label​Result

2 overloads


protected method QueryScreenLabelResult1 → (4)

sceneView in : ISceneView

[not-null]
The scene view.

screenLabel in : int32

The screen label ordinal, as returned by ScreenLabelPlacement.Add.

point in : Vec2I

The point, in screen-space (see ISceneView.Bounds).

builder in : ISceneQueryResultBuilder

[not-null]
The query result builder.

returns → bool

true if a query result has been output to builder in,
false if there is no query result.

Performs an intersection query for the given screen label.

If the point hits the given screenLabel in, a ScreenLabelResult is generated, using ISceneObject.QuerySceneObjectResult as IParentObjectContainer.ParentObject.


protected method QueryScreenLabelResult2 → (6)

sceneView in : ISceneView

[not-null]
The scene view.

bounds in : Box2I

The screen label bounds, see ScreenLabelPlacementEntry.Bounds.

depth in : float32

The screen label depth, see ScreenLabelPlacementEntry.Depth.

label in : IScreenLabel

[not-null]
The screen label, see ScreenLabelPlacementEntry.Label.

point in : Vec2I

The point, in screen-space (see ISceneView.Bounds).

builder in : ISceneQueryResultBuilder

[not-null]
The query result builder.

returns → bool

true if a query result has been output to builder in,
false if there is no query result.

Performs an intersection query for the given screen label.

If the point hits the given screen label, a ScreenLabelResult is generated, using ISceneObject.QuerySceneObjectResult as IParentObjectContainer.ParentObject.