TriLib
Search Results for

    Show / Hide Table of Contents

    Class ReaderBase

    Represents the base class for file-format Readers. Defines the core functionality and workflow for loading a model into a IRootModel.

    Inheritance
    object
    ReaderBase
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: TriLibCore
    Assembly: TriLibCore.dll
    Syntax
    public abstract class ReaderBase

    Constructors

    ReaderBase()

    Declaration
    protected ReaderBase()

    Fields

    ProfileStepCallback

    An optional callback for profiling each loading step. Parameters: (operationName, resourceName, duration, memoryUsed).

    Declaration
    public static Action<string, string, TimeSpan, long> ProfileStepCallback
    Field Value
    Type Description
    Action<string, string, TimeSpan, long>

    Properties

    AssetLoaderContext

    Provides access to the AssetLoaderContext used to load the model.

    Declaration
    public AssetLoaderContext AssetLoaderContext { get; }
    Property Value
    Type Description
    AssetLoaderContext

    LoadingStepEnumType

    Gets the Type that defines the loading steps (an enumeration of step definitions).

    Declaration
    protected abstract Type LoadingStepEnumType { get; }
    Property Value
    Type Description
    Type

    LoadingStepsCount

    Gets the total number of loading steps for this reader.

    Declaration
    public virtual int LoadingStepsCount { get; }
    Property Value
    Type Description
    int

    Name

    Gets the name of this reader.

    Declaration
    public abstract string Name { get; }
    Property Value
    Type Description
    string

    Methods

    CreateRootModel()

    Creates a IRootModel specific to the implementing reader.

    Declaration
    protected abstract IRootModel CreateRootModel()
    Returns
    Type Description
    IRootModel

    A new instance of the reader's IRootModel implementation.

    MapName(AssetLoaderContext, ModelNamingData, IModel, string)

    Uses the object reader data to create the final model name. If NameMapper is set, it will be used to generate the model name.

    Declaration
    public string MapName(AssetLoaderContext assetLoaderContext, ModelNamingData data, IModel model, string readerName)
    Parameters
    Type Name Description
    AssetLoaderContext assetLoaderContext

    The current AssetLoaderContext.

    ModelNamingData data

    The naming data (model name, material name, ID, etc.) to consider.

    IModel model

    The loaded model for which to generate a name.

    string readerName

    The name of this reader.

    Returns
    Type Description
    string

    The resulting name for the model.

    PostProcessModel(ref IRootModel)

    Applies final naming, pivot, and organizational transformations to the model after loading is complete. Also merges a single child if MergeSingleChild is set.

    Declaration
    protected void PostProcessModel(ref IRootModel model)
    Parameters
    Type Name Description
    IRootModel model

    The top-level IRootModel loaded by this reader.

    ReadExternalFile(string)

    Reads an external file into a Stream, trying any defined external data mapper first. If the file is not provided by the mapper, attempts to locate it via FindFile(string, string, bool).

    Declaration
    public virtual Stream ReadExternalFile(string path)
    Parameters
    Type Name Description
    string path

    The relative or absolute path to the external file.

    Returns
    Type Description
    Stream

    A Stream for the requested file, or null if the file could not be found.

    ReadStream(Stream, AssetLoaderContext, string, Action<AssetLoaderContext, float>)

    Reads a model from the specified stream using the given assetLoaderContext, optionally associating a filename and progress callback onProgress.

    Declaration
    public virtual IRootModel ReadStream(Stream stream, AssetLoaderContext assetLoaderContext, string filename = null, Action<AssetLoaderContext, float> onProgress = null)
    Parameters
    Type Name Description
    Stream stream

    The Stream containing the model data to load.

    AssetLoaderContext assetLoaderContext

    The context that provides loading options and tracks loaded data.

    string filename

    An optional filename for this model if loading from local storage; used for naming or reference.

    Action<AssetLoaderContext, float> onProgress

    An optional callback invoked to report loading progress (LoadingProgress).

    Returns
    Type Description
    IRootModel

    The loaded root model, or null if no model is loaded in this method.

    SetupStream(ref Stream)

    Ensures that the given stream is buffered in memory if needed, based on the BufferizeFiles setting.

    Declaration
    public void SetupStream(ref Stream stream)
    Parameters
    Type Name Description
    Stream stream

    The Stream to possibly replace with a buffered MemoryStream.

    UpdateLoadingPercentage(float, int, float)

    Updates the model loading progress percentage. This method is typically called at various stages of the loading and post-processing pipeline.

    Declaration
    public void UpdateLoadingPercentage(float value, int step = 0, float maxValue = 0)
    Parameters
    Type Name Description
    float value

    A floating-point value representing the current sub-step progress.

    int step

    The zero-based index of the current step.

    float maxValue

    The maximum expected progress for the current step; if greater than zero, value is normalized by this value.

    Extension Methods

    IObjectExtensions.TryToDispose<T>(object)
    In this article
    Back to top Generated by DocFX