ModelReaderOptions
Description
- 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:
-
3D model structure
Many model files contain a hierarchy of nodes, which gets flattened or retained during processing by the model reader. Use ModelNames to control this behaviour. The IsModelNameKept method can be used to check whether a node name will be retained. Simplification via IModel.Simplify can be controlled via Simplify. Additional customization can be performed with ReadModelFlags.ModelGroup and RootUnit. -
Texture file lookup
Use TextureNameReplace, TexturePath and TextureFileReplace to configure texture name mapping and file lookup. With TextureName1, ResolveTexturePath and TextureFile1, texture lookups may be performed, similarly to the model reader. The TextureUnresolved property maintains a list of texture names for which lookup has failed. -
Geometry post-processing
The geometry data of a model file can be post-processed. To configure this, set the FixWinding, Flags and Transform properties accordingly. TheProcess*
methods are helpers that apply post-processing to the given data, similarly to the model reader. -
Material tweaking
Use BumpScale, GlossinessScale, ReflectivityScale, RootMaterial and ReadModelFlags.NormalIsBump to customize import of materials, for example if the 3D model file contains badly authored data.
- See also
Public / Methods
IsModelNameKept
Checks if the given model name shall be kept, including its hierarchical structure.
The names of the models to keep are listed in ModelNames.
- See also
ModelName
Specifies whether to keep the given model name or not.
The names of the models to keep are listed in ModelNames.
- See also
PostProcessVertices
2 overloads
Returns a transformation matrix for performing post processing on vertex data:
Performs in-place post processing on the given vertex data:
TextureFile
2 overloads
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:
-
The given texture path is resolved (see ResolveTexturePath).
-
If a model texture object has been specified earlier for the resolved texture path via TextureFileReplace, that object is used.
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:
-
The given texture path is resolved (see ResolveTexturePath).
-
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.
TextureFileReplace
Replaces a texture file.
The given texture file path will be resolved (see ResolveTexturePath), if necessary.
TextureName
2 overloads
Returns the model texture name replacement for the given texture name.
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:
-
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).
-
The texture name is interpreted as a file path and resolved (see Path.Resolve) using the configured texture path (see TexturePath).
-
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.
Public / Attributes
BumpScale
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
.
- See also
FixWinding
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
.
GlossinessScale
Scale factor to apply to IMaterial.Glossiness. MaterialPart.Value of all read materials.
Defaults to 1.0
.
ModelNames
Names of the model nodes to keep, including their hierarchical structure.
If ReadModelFlags.ModelNames is present, this property is ignored.
- See also
ReflectivityScale
Modulation color to apply to IMaterial.Reflectivity. MaterialPart.Value of all read materials.
Defaults to ColorF.White.
Simplify
The model simplification actions that will be performed by IModelReader.ReadModel before returning the final IModel.
Defaults to ModelSimplifyFlags.All.
TexturePath
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.
TextureUnresolved
Returns the texture names (see TextureName1 and TextureName2) that could not have been resolved.
Transform
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.