ModelReaderOptions

Description

sealed class Tinman.Engine.Models.ModelReaderOptions

Derived from

Versioned abstract

The ModelReaderOptions class provides a set of standard options that can be used to configure the import process for 3D models.

If supported by a IModelReader, the options can be used to control how the read model data is processed:

Public / Constructors

Model​Reader​Options


public constructor ModelReaderOptions → (1)

modelDirectory in : Path

Path to the directory that contains the model file or null if none.

Creates a new instance of ModelReaderOptions.

Public / Methods

Is​Model​Name​Kept


[Pure]
public method IsModelNameKept → (1)

name in : string

The model name.

returns → bool

true if the model shall be kept,
false if it may be merged.

Checks if the given model name shall be kept, including its hierarchical structure.

The names of the models to keep are listed in ModelNames.

Model​Name


public method ModelName → (2)

name in : string

[not-empty]
The model name.

keep opt : bool = true

true to keep name in,
false to not keep name in.

Specifies whether to keep the given model name or not.

The names of the models to keep are listed in ModelNames.

Post​Process​Indices


public method PostProcessIndices → (3)

vertices in : VertexArrays

The vertex data.

indices in : int32 [ ]

The index data to process.

batch in : PrimitiveBatch

The geometry batch.

Performs in-place post processing on the given index data:

Post​Process​Texture​Coords​Normals


public method PostProcessTextureCoordsNormals → (1)

vertices in : VertexArrays

The vertex data to process.

Performs in-place post processing on the given vertex data:

Post​Process​Vertices

2 overloads


public method PostProcessVertices1 → ()

returns → Mat4D

The transformation matrix.

Returns a transformation matrix for performing post processing on vertex data:


public method PostProcessVertices2 → (1)

vertices in : VertexArrays

The vertex data to process.

Performs in-place post processing on the given vertex data:

Resolve​Texture​Path


[Pure]
public method ResolveTexturePath → (1)

texturePath in : Path

[not-null]
The texture path.

returns → Path

The resolved canonical texture path.

Resolves the given texture path, using the current model reader settings.

Resolve​Texture​Path​Reverse


[Pure]
public method ResolveTexturePathReverse → (1)

texturePath in : Path

[not-null]
The resolved texture path.

returns → Path

The texture path (relative if possible).

Reverse-resolves the given texture path.

Texture​File

2 overloads


[Pure]
public method TextureFile1 → (1)

file in : Path

[not-null]
The texture file path.

returns → IModelTexture

The model texture or null.

Returns the model texture object that has been specified for the given texture file.

The model texture object for the given texture file in is obtained by the following steps:

  1. The given texture path is resolved (see ResolveTexturePath).

  2. If a model texture object has been specified earlier for the resolved texture path via TextureFileReplace, that object is used.


public method TextureFile2 → (3)

file in : Path

[not-null]
The texture file path.

srgb in : bool

The ISrgb.Srgb flag to use for encoding the texture. Will be ignored if a cached texture is used.

format opt : TextureFormat = null

The texture format to use or null to choose one automatically. Will be ignored if a cached texture is used.

returns → IModelTexture

The model texture or null.

Returns the model texture object for the given texture file.

The model texture object for the given texture file in is obtained by the following steps:

  1. The given texture path is resolved (see ResolveTexturePath).

  2. If a model texture object has been specified earlier for the resolved texture path via TextureFileReplace, that object is used (the srgb in parameter is ignored in this case). Otherwise, a new model texture object is created and cached, using the canonical path value as the key.

IOException

An I/O error has occurred while reading the image metadata in order to determine the texture format.

ValidatingException

The image reader has reported an error while reading the image metadata for determining the texture format, for example because of a missing file format feature.

Texture​File​Replace


public method TextureFileReplace → (2)

path in : Path

[not-null]
The texture file path.

texture in : IModelTexture

[not-null]
The replacement model texture object.

Replaces a texture file.

The given texture file path will be resolved (see ResolveTexturePath), if necessary.

Texture​Name

2 overloads


[Pure]
public method TextureName1 → (1)

name in : string

The texture name, as found in the 3D model.

returns → string

The model texture name or null iff there is no texture name replacement.

Returns the model texture name replacement for the given texture name.


public method TextureName2 → (3)

name in : string

The texture name, as found in the 3D model.

srgb in : bool

The ISrgb.Srgb flag to use for encoding the texture.

format opt : TextureFormat = null

The texture format to use or null to choose one automatically.

returns → IModelTexture

The model texture or null if name in is null. Will be ModelTexture.Error if the texture name does not resolve to a valid file path or if the resolved texture file does not exist.

Returns the model texture object for the given texture name.

The model texture object for the given texture name in is obtained by the following steps:

  1. The texture name in is replaced, according to the mappings that have been established earlier via TextureNameReplace. If there is no mapping for name in and it is an absolute path to a non-existent file, it will be replaced with the last path element (i.e. the file name).

  2. The texture name is interpreted as a file path and resolved (see Path.Resolve) using the configured texture path (see TexturePath).

  3. This method delegates to TextureFile2, using the resolved texture path.

IOException

An I/O error has occurred while reading the image metadata in order to determine the texture format.

ValidatingException

The image reader has reported an error while reading the image metadata for determining the texture format, for example because of a missing file format feature.

Texture​Name​Replace


public method TextureNameReplace → (2)

original in : string

[not-null]
The original texture name.

corrected in : string

[not-null]
The corrected texture name.

Replaces a texture name.

Texture​Unresolved​Clear


public method TextureUnresolvedClear → ()

Clears the list of unresolved texture names.

Public / Attributes

Bump​Scale


public attribute BumpScale → (get,set)

value : float64

The relative bump height. This value is interpreted relative to the dimensions of the unit square of normalized texture coordinates. A value of 1 will extrude the unit square to the unit cube.

Relative height of bump maps.

Instead of a normal map, a model may define a bump height map. In this case, a tangent-space normal map can be generated from the bump map, using the given bump height.

Defaults to 0.

Fix​Winding


public attribute FixWinding → (get,set)

value : int32

Given a triangle (a,b,c), vertex winding is fixed using the face normal N and the cross product X=(b-a)x(c-a):
> 0 : Fix triangle winding so that dot(N,X) is positive.
< 0 : Fix triangle winding so that dot(N,X) is negative.
= 0 : Do not fix triangle winding.

Fix vertex winding of indexed triangle list primitives?

If the model does not have normal vectors, vertex winding will never be fixed. This fix is applied after ReadModelFlags.FlipWinding.

Defaults to 0.

Flags


public attribute Flags → (get,set)

value : ReadModelFlags

The flags.

The flags to use for reading the 3D model.

Defaults to ReadModelFlags.None.

Glossiness​Scale


public attribute GlossinessScale → (get,set)

value : float32

[>=0]
The gloss scale.

Scale factor to apply to IMaterial.Glossiness. MaterialPart.Value of all read materials.

Defaults to 1.0.

Model​Names


public attribute ModelNames → (get)

value : ISortedSetConst<string>

[not-null]
The set of model names to keep.

Names of the model nodes to keep, including their hierarchical structure.

If ReadModelFlags.ModelNames is present, this property is ignored.

Reflectivity​Scale


public attribute ReflectivityScale → (get,set)

value : ColorF

The reflectivity scale.

Modulation color to apply to IMaterial.Reflectivity. MaterialPart.Value of all read materials.

Defaults to ColorF.White.

Root​Material


public attribute RootMaterial → (get,set)

value : IMaterial

The root material or null.

The material to use for the model root node.

Root​Unit


public attribute RootUnit → (get,set)

value : UnitOfMeasure

The root unit of measure or null.

The unit of measure to use for the model root node.

Simplify


public attribute Simplify → (get,set)

value : ModelSimplifyFlags

The model simplification actions.

The model simplification actions that will be performed by IModelReader.ReadModel before returning the final IModel.

Defaults to ModelSimplifyFlags.All.

Texture​Path


public attribute TexturePath → (get,set)

value : Path

[not-null]
The texture base directory.

The base directory to use for resolving relative texture file paths in the 3D model.

The given base directory can be relative; in this case, it will be resolved using the path of the directory that contains the model file. If there is no path info for the model data (see IFileData.IsPathInfoValid), the current filesystem directory is used instead.

Defaults to Path.Current.

Texture​Unresolved


[Constant]
public attribute TextureUnresolved → (get)

value : ISortedSetConst<string>

[not-null]
The unresolved texture names. Will be empty iff all texture names have resolved successfully.

Returns the texture names (see TextureName1 and TextureName2) that could not have been resolved.

Transform


public attribute Transform → (get,set)

value : Mat4D

The transformation matrix.

Optional transformation matrix to apply to the model geometry.

The transformation matrix is applied as the last transformation step, before the custom post processors are invoked.

Defaults to Mat4D.Identity.