ModelRenderer

Description

sealed class Tinman.Engine.Models.ModelRenderer

Derived from

Disposable abstract
IBeginEnd

The ModelRenderer class performs 3D rendering of IModel objects.

When IBeginEnd.Begin is called, the following properties are reset to their default value:

The calls to IBeginEnd.Begin and IBeginEnd.End must not be nested.

To use frustum culling, set Frustum. Then, pass true to the Render method as the culling parameter.

To use distance culling, set Viewport and then pass true to the Render method as the culling parameter.

Public / Constructors

Model​Renderer


public constructor ModelRenderer → (2)

context in : IGraphicsContext

[not-null]
The graphics context to use.

cache opt : IResourceCache = null

The resource cache to use. If null, IGraphicsContext.Cache of context in will be used.

Creates a new instance of ModelRenderer.

RenderException

If a graphics subsystem error has occurred.

Public / Methods

Flush​Queue


[BeginEnd]
public method FlushQueue → (2)

queue in : int32

Bitmask that chooses the render queues to flush:
1 : opaque geometry
2 : transparent geometry

flags opt : int32 = 0

Bitmask of optional flags:
1 : use order-independent transparency?

Flushes the given render queues.

Render work is only submitted to the GPU when this method is called.

Flush​State


[BeginEnd]
public method FlushState → ()

Flushes the remembered render state and ends the render effect.

Call this method when before using other render effects between calls to IBeginEnd.Begin and IBeginEnd.End.

Render


[BeginEnd]
public method Render → (2)

model in : IModel

The 3D model to render or null.

culling opt : bool = true

Do frustum and distance culling (see Frustum and Viewport)?

Renders the given 3D model.

The following properties are used for rendering the model:

  • Instances:
    The instance range to use for rendering instanced geometry (see IModelGeometry.InstanceBuffer). This property is ignored for geometry that is not instanced.

  • Mode

  • TransformPush:
    The top-most transformation matrix is applied last, just before the coordinate system origin is applied.

  • Pose:
    Can be used to modify the model hierarchy without changing model properties.

  • Unit

Calling this method merely buffers render jobs for model geometry. Actual render work for the GPU is only submitted when the FlushQueue method is called, the IBeginEnd.End method does implicitly perform a flush.

Statistics​Clear


public method StatisticsClear → ()

Clears the current statistic values.

Transform​Pop


[BeginEnd]
public method TransformPop → ()

Pops the top-most transformation matrix from the stack.

Transform​Push


[BeginEnd]
public method TransformPush → (1)

transform in : AffineTransform

The transformation matrix to push.

Pushes the given transformation matrix onto the stack.

Public / Attributes

Debug


[BeginEnd]
public attribute Debug → (get,set)

value : int32

The material debug mode, see MaterialParameters.Debug.

The material debug mode to use for models during rendering.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

Defaults to 0.

Fade


[BeginEnd]
public attribute Fade → (get,set)

value : RangeF

The model fade range, given as camera distance values.

The fade range to apply to models during rendering.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

Models will start to become visible at RangeF.Start and will have become invisible again at RangeF.End.

This fade range is overridden by IModel.FadeIn and IModel.FadeOut, if present.

Set to RangeF.Zero to disable fading.

Defaults to RangeF.Zero.

Fade​Offset


public attribute FadeOffset → (get,set)

value : float32

The custom factor offset.

A custom offset factor for fade ranges.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

The fade offset is added to camera distance values, before applying the fade ranges.

Defaults to 0.

Flags


public attribute Flags → (get,set)

value : ModelRendererFlags

The model renderer flags to use.

The model renderer flags.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

The default value is ModelRendererFlags.None.

Frustum


public attribute Frustum → (get,set)

value : IFrustum

The frustum to use or null to disable frustum culling.

Optional frustum to use for discarding invisible model parts.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

Defaults to null.

Has​Opaque


public attribute HasOpaque → (get)

value : bool

true if there is some opaque render work,
false if not.

Is there any queued render work in the opaque queue?

Has​Transparent


public attribute HasTransparent → (get)

value : bool

true if there is some transparent render work,
false if not.

Is there any queued render work in the transparent queue?

Instances


[BeginEnd]
public attribute Instances → (get,set)

value : RangeI

The instance range (see IGraphicsContext.SetGeometryBuffer).

The range of model geometry instances to draw.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

Will be ignored if model geometry is not instanced.

Defaults to RangeI.Zero.

Mode


public attribute Mode → (get,set)

value : ModelRendererMode

The render mode.

The render mode to use.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

Parameters​Camera


public attribute ParametersCamera → (get)

value : CameraParameters

[not-null]
The camera parameters.

Returns the camera parameters.

When IBeginEnd.Begin is called, the following camera parameters are copied and used for viewport and distance culling:

Render effect parameters are taken into account when the render queues are flushed, see FlushQueue.

Parameters​Lighting


public attribute ParametersLighting → (get)

value : LightingParameters

[not-null]
The lighting parameters.

Returns the lighting parameters.

Render effect parameters are taken into account when the render queues are flushed, see FlushQueue.

Parameters​Shadow


public attribute ParametersShadow → (get)

value : ShadowParameters

[not-null]
The shadow-mapping parameters.

Returns the shadow-mapping parameters.

Render effect parameters are taken into account when the render queues are flushed, see FlushQueue.

Pose


public attribute Pose → (get,set)

value : ModelPose

The model pose container or null if no model pose is used.

The model pose container that is used for rendering.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

Defaults to null.

Statistics


public attribute Statistics → (get)

value : ModelRendererStats

The statistics.

Returns statistics for the current IBeginEnd.Begin/IBeginEnd.End cycle.

Statistic values are accumulated until StatisticsClear is called.

Unit


public attribute Unit → (get,set)

value : UnitOfMeasure

The world-space unit. If null, UnitOfMeasure.Metre will be used.

The unit of measure of world-space coordinates.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

The world-space and model-space units (see IModel.Unit) are used to compute a proper scaling factor for rendering.

Defaults to UnitOfMeasure.Metre.

Viewport


public attribute Viewport → (get,set)

value : Viewport

The viewport to use or null to disable distance culling.

Optional viewport to use for computing screen-space sizes, based on world-space sizes.

The depth offset for rendering surface layers is (see IModelPart.Layer) is computed so that it spans the world-space size that corresponds to roughly one screen pixels.

Distance culling computes the screen-space size of the bounding sphere of each model and skips the model if it would be too small on the screen.

The value of this property is taken into account on each call to Render, modifying it will not affect earlier calls.

Defaults to null.