TerrainModel

Description

sealed class Tinman.Engine.Components.TerrainModel

Describes a 3D model that is placed somewhere onto the terrain.

The position properties of the TerrainModel class refer to the coordinate origin of the model-space of Model.

When using a ISpatialCallback with the ISpatialQuery interface, the child indices provided by ISpatialCallback.ChildPush correlate with IModel.ChildAt for Model.

Public / Constructors

Terrain​Model

5 overloads


public constructor TerrainModel1 → (1)

visibleMask opt : int64 = ~0

The initial value for IVisibleMask.VisibleMask.

Creates a new instance of TerrainModel.


public constructor TerrainModel2 → (2)

flags in : TerrainModelFlags

Initial value for Flags.

visibleMask opt : int64 = ~0

The initial value for IVisibleMask.VisibleMask.

Creates a new instance of TerrainModel.


public constructor TerrainModel3 → (3)

withPose in : bool

Set Pose to a new ModelPose object?

flags opt : TerrainModelFlags = TerrainModelFlags.Default

Initial value for Flags.

visibleMask opt : int64 = ~0

The initial value for IVisibleMask.VisibleMask.

Creates a new instance of TerrainModel.


public constructor TerrainModel4 → (4)

model in : IModel

The initial value for Model.

withPose opt : bool = false

Set Pose to a new ModelPose object?

flags opt : TerrainModelFlags = TerrainModelFlags.Default

Initial value for Flags.

visibleMask opt : int64 = ~0

The initial value for IVisibleMask.VisibleMask.

Creates a new instance of TerrainModel.


public constructor TerrainModel5 → (5)

transform in : AffineTransform

The initial value for Transform.

model opt : IModel = null

The initial value for Model.

withPose opt : bool = false

Set Pose to a new ModelPose object?

flags opt : TerrainModelFlags = TerrainModelFlags.Default

Initial value for Flags.

visibleMask opt : int64 = ~0

The initial value for IVisibleMask.VisibleMask.

Creates a new instance of TerrainModel.

Public / Methods

Bounds


public method Bounds → (1)

bounds in : BoxSoup

[not-null]
The output box soup.

Outputs the bounds of this terrain model to the given box soup.

Decoration​Dirty


public method DecorationDirty → ()

Invalidates the current 3D model decoration, if any.

This method must be called in the following situations:

  • The model (see Model) has been modified externally, for example by adding child models or model parts.

  • The pose (see Pose) has been modified in a way that affects the decorator (see Decorator), for example by hiding descendant models for a decorator that processes the whole model hierarchy.

Setting different model, pose or decorator objects automatically invalidates the model decoration. In these cases, this method does not need to be called.

Decoration​Update


public method DecorationUpdate → ()

Applies the current 3D model decorator.

This method may be called repeatedly. If necessary, it will rebuild the model decoration (which may take some time) or update the existing model decoration (which usually completes quickly). If there is no work to do, the method returns instantly.

Instance​Update


public method InstanceUpdate → (4)

pose in : AffineTransform

The instance pose.

color opt : int64 = ~0

The instance color (low dynamic range).

intensity opt : float32 = 1

The instance color intensity (high dynamic range).

worldSpace opt : bool = true

true to apply AffineTransform.Translation in world-space,
false to apply AffineTransform.Translation in model-space.

Updates the next model instance.

This method may only be called between calls to InstanceUpdateBegin and InstanceUpdateEnd. Alternatively, model instance data (see ModelGeometry.InstanceFormat) may also be written directly to the model instance buffer (see InstanceUpdateBuffer).

Instance​Update​Begin


public method InstanceUpdateBegin → (4)

view in : TerrainView

[not-null]
The terrain view.

first opt : int32 = 0

[0..TerrainModel.InstanceCount]
The first instance that will be updated.

count opt : int32 = -1

[-1..TerrainModel.InstanceCount-first]
The number of instances that will be updated. If -1, all remaining instances will be updated.

flag opt : GpuUpdateFlag = GpuUpdateFlag.Discard

The update flag to use for accessing the instance buffer on the GPU.

returns → int32

The number of instances that are expected to be updated subsequently, by calling the InstanceUpdate method once for each one.

Begins to update the instance data of this model for the given view.

Instance​Update​Buffer


public method InstanceUpdateBuffer → ()

returns → ByteBuffer

The buffer that holds the model instance data (see ModelGeometry.InstanceFormat) or null if not between a pair of calls to InstanceUpdateBegin and InstanceUpdateEnd. The buffer is positioned at the next model instance. The caller is responsible for writing correct model instance data to the returned buffer. The InstanceUpdate method may be used to write correct model instance data safely, at the cost of flexibility.

Returns the buffer for updating model instances.

Instance​Update​End


public method InstanceUpdateEnd → ()

Ends the current instance data update.

Public / Attributes

Decoration


public attribute Decoration → (get)

value : IModel

The decoration model or null if there is no decorator or if the model is instanced.

Returns the current 3D model decoration, building / updating it if necessary.

Building a new decoration may incur additional computational overhead, whereas updating it usually completes quickly. The DecorationUpdate method may be used to perform the building work eagerly, instead of lazily via this property.

Decorator


public attribute Decorator → (get,set)

value : IModelDecorator

The decorator.

The decorator to use for building the decoration for non-instanced 3D models.

Defaults to null.

Flags


public attribute Flags → (get,set)

value : TerrainModelFlags

The flags.

The behaviour flags of this 3D model.

Instance​Count


public attribute InstanceCount → (get,set)

value : int32

[>=0]
The number of model instances or 0 to disable instancing.

The number of model instances.

Defaults to 0.

Instance​Range


public attribute InstanceRange → (get,set)

value : RangeI

The model instance range.

The range of model instances to render.

If InstanceCount is zero, this property is ignored. Otherwise it is clamped to the valid range of instance indices.

Defaults to RangeI.Zero.

Instance​Updater


public attribute InstanceUpdater → (get,set)

value : IInstanceUpdater

The instance updater to use or null to update instance data manually.

The IInstanceUpdater to use for this terrain model.

When an instance updater is present and InstanceCount is greater than zero, the TerrainView will call IInstanceUpdater.UpdateTerrainModelInstances from within IRenderable.Render automatically. Defaults to null.

Is​Valid


public attribute IsValid → (get)

value : bool

true if this 3D model is value, false if not.

Is this 3D model valid?

Only valid models will be processed and rendered.

Model


public attribute Model → (get,set)

value : IModel

The 3D model or null.

The 3D model.

Defaults to ModelDecorator.None.

Model​Collider


public attribute ModelCollider → (get)

value : IModelCollider

[not-null]
The model collider.

Returns the IModelCollider of Model which takes Pose into account, if present.

Pose


public attribute Pose → (get,set)

value : ModelPose

The 3D model pose or null.

The 3D model pose.

Defaults to null.

Transform


public attribute Transform → (get,set)

value : AffineTransform

The model transform.

The transformation from model-space (in terrain units) to terrain-space (in terrain units), not taking into account the model pose.

Transform​Unit​Pose


public attribute TransformUnitPose → (get)

value : AffineTransform

The model transform.

The transformation from model-space (in model units) to terrain-space (in terrain units), taking into account the current model pose.