IModel

Description

interface Tinman.Engine.Models.IModel

Extended by

Model sealed

Base interface for classes that represent 3D models.

The coordinate space for untransformed top-level 3D models is defined as follows:

  • X+ : points westwards resp. sidewards.

  • Y+ : points upwards.

  • Z+ : points northwards resp. forwards.

The ground level is expected to be at Y-coordinate zero.

See also

ModelInfo

Public / Methods

Child​At


[Pure]
public method ChildAt → (1)

index in : int32

[0..IModel.ChildCount-1]
The child model index.

returns → IModel

The child model.

Returns the index in-th child model.

The same IModel object may be a child of multiple parent IModel objects. The resulting graph of parent-child relations must not contain any cycles.

Child​Transform​At


[Pure]
public method ChildTransformAt → (1)

index in : int32

[0..IModel.ChildCount-1]
The child model index.

returns → AffineTransform

The transformation from the child model to this model as parent.

Returns the child-to-parent transformation matrix of the index in-th child model.

The transformation matrix uses the unit of measure of the parent model (see Unit).

See also

IModel.ChildAt

Collider​Load


public method ColliderLoad → (1)

data in : ISerializable

The precomputed spatial data structures.

Initializes the Collider object from the given precomputed spatial data structures.

As an alternative to this method, the ModelFlags.ComplexGeometry flag may be used.

If the given data in is unsuitable, this method will return silently and a new IModelCollider will be computed.

Collider​With​Pose


public method ColliderWithPose → (1)

pose in : ModelPose

[not-null]
The model pose to use.

returns → IModelCollider

The posed model collider.

Returns non-shared IModelCollider for this IModel that uses the given model pose in.

The returned collider will take the following into account:

See also

IModel.Collider

Copy


public method Copy → ()

returns → Model

The mutable copy.

Creates a mutable deep copy of this model.

Modifying the returned Model will not affect this model.

Part​At


[Pure]
public method PartAt → (1)

index in : int32

[0..IModel.PartCount-1]
The model part index.

returns → IModelPart

The model part.

Returns the index in-th model part.

The same IModelPart object may be used by zero or more IModel objects.

Prepare​Lazy


public method PrepareLazy → ()

returns → IModel

this

Prepares lazy-loaded data for this model.

This method does not pre-load vertex / index data (see IModelGeometry) or textures (see IModelTexture).

IOException

If an I/O error has occurred while lazy-loading model data.

Simplify


public method Simplify → (1)

flags opt : ModelSimplifyFlags = ModelSimplifyFlags.All

The actions to apply.

returns → IModel

this

Simplifies this model by applying the given actions.

Simplification is performed in-place and only modifies the model hierarchy, without loading or computing any additional model data, such as:

See also

IModel.Copy

Use​Geometry​Instancing


public method UseGeometryInstancing → (1)

instanceBuffer in : IResourceHandle

The resource handle that returns a IVertexBuffer object that holds instance data to use for this model object or null to disable geometry instancing. The instanceBuffer in value will be returned by the IModelGeometry.InstanceBuffer property of the geometry objects of the returned model and all its descendants.

returns → IModel

The resulting model, which may be this.

Configures geometry instancing for this model.

Public / Attributes

Child​Count


public attribute ChildCount → (get)

value : int32

[>=0]
The child model count.

The number of child models.

Collider


public attribute Collider → (get)

value : IModelCollider

[not-null]
The collider object.

The collider object for this model.

Collider objects are often shared between models.

Fade​In


public attribute FadeIn → (get)

value : Fade

The fade-in range for the view distance, in model-space.

The fade-in range of this model.

When Fade.Compute returns 0, the model will not be visible at all.

Defaults to Fade.AlwaysOne, i.e. always faded in.

Fade​Out


public attribute FadeOut → (get)

value : Fade

The fade-out range for the view distance, in model-space.

The fade-out range of this model.

When Fade.Compute returns 1, the model will not be visible at all.

Defaults to Fade.AlwaysZero, i.e. never faded out.

Flags


public attribute Flags → (get)

value : ModelFlags

The model flags.

The model flags.

Defaults to ModelFlags.None.

Name


public attribute Name → (get)

value : string

The model name, will either be null or non-empty.

The name of this model.

Defaults to null.

Part​Count


public attribute PartCount → (get)

value : int32

[>=0]
The model part count.

The number of model parts.

See also

IModel.PartAt

Unit


public attribute Unit → (get)

value : UnitOfMeasure

The model-space unit. If set to null, the default value is returned instead.

The unit of measure in which the vertex coordinates of the model parts are expressed.

Defaults to UnitOfMeasure.Metre.

Extensions

Child​For

2 overloads


[Pure]
public static method ChildFor1 → (2)

name in : string

The model name.

recursive opt : bool = false

true to search all descendant models, using in-order traversal,
false to only search the child models.

returns → IModel

The first matching child model or null if there is none.

Returns the first child or descendant model of the given name (see IModel.Name).


[Pure]
public static method ChildFor2 → (3)

name in : string

The model name.

transform out : AffineTransform

The transformation from the returned model to this model. Will be AffineTransform.Identity if null is returned.

recursive opt : bool = false

true to search all descendant models, using in-order traversal,
false to only search the child models.

returns → IModel

The first matching child or descendant model or null if there is none.

Returns the first child or descendant model of the given name (see IModel.Name).

Child​Transform​With​Unit​Scale​At


[Pure]
public static method ChildTransformWithUnitScaleAt → (1)

index in : int32

[0..model.ChildCount-1]
The child model index.

returns → AffineTransform

The transformation matrix.

Returns the child-to-parent transformation matrix of the index in-th child model.

The transformation matrix uses the unit of measure of the child model (see IModel.Unit).

See also

IModel.ChildAt

Traverse


public static method Traverse → (4)

action in : ModelDelegate

[not-null]
The model action to perform.

includeThis opt : bool = true

Invoke action in for this model?

includeChildren opt : bool = true

Invoke action in for descendant models?

level opt : int32 = 0

[>=0]
The model hierarchy level, where 0 represents the top-most model of the traversal, which is not necessarily the root model of the hierarchy.

Traverses this model hierarchy and performs the given action at each node.

Unit​Scale


[Pure]
public static method UnitScale → (1)

unit opt : UnitOfMeasure = null

The target unit of measure. If null, metres will be used.

returns → float64

The scale factor from model units to target units.

Returns the scale factor for the give model, based on the specified unit of measure.

Wrap


[OwnerReturn]
public static method Wrap → ()

returns → IModelReader

The IModelReader that wraps this model.

Wraps this model in a IModelReader.