Search Results for

    Show / Hide Table of Contents

    Class USDRuntime

    Represents the runtime for handling USD (Universal Scene Description) files in Evergine. This class provides methods to read, parse, and process USD files, including their materials, nodes, and geometries.

    Inheritance
    object
    ModelRuntime
    USDRuntime
    Namespace: Evergine.Runtimes.USD
    Assembly: Evergine.Runtimes.USD.dll
    Syntax
    public class USDRuntime : ModelRuntime

    Constructors

    USDRuntime(GraphicsContext, AssetsService, AssetsDirectory)

    Initializes a new instance of the USDRuntime class.

    Declaration
    public USDRuntime(GraphicsContext graphicsContext, AssetsService assetsService, AssetsDirectory assetsDirectory)
    Parameters
    Type Name Description
    GraphicsContext graphicsContext

    Graphics Context instance.

    AssetsService assetsService

    Assets Service instance.

    AssetsDirectory assetsDirectory

    Assets Directory instance.

    Fields

    FACE

    Constant for face-varying interpolation type.

    Declaration
    public const string FACE = "faceVarying"
    Field Value
    Type Description
    string

    Instance

    Gets a default instance of the class, resolving the required services using the default Evergine container.

    Declaration
    public static readonly USDRuntime Instance
    Field Value
    Type Description
    USDRuntime

    LEFT_HANDED

    Constant for left-handed orientation.

    Declaration
    public const string LEFT_HANDED = "leftHanded"
    Field Value
    Type Description
    string

    LinearClampSampler

    The sampler state for linear filtering with clamp addressing mode.

    Declaration
    public SamplerState LinearClampSampler
    Field Value
    Type Description
    SamplerState

    LinearWrapSampler

    The sampler state for linear filtering with wrap addressing mode.

    Declaration
    public SamplerState LinearWrapSampler
    Field Value
    Type Description
    SamplerState

    RIGHT_HANDED

    Constant for right-handed orientation.

    Declaration
    public const string RIGHT_HANDED = "rightHanded"
    Field Value
    Type Description
    string

    VERTEX

    Constant for vertex interpolation type.

    Declaration
    public const string VERTEX = "vertex"
    Field Value
    Type Description
    string

    Properties

    Extension

    Gets the file extension associated with this runtime.

    Declaration
    public override string Extension { get; }
    Property Value
    Type Description
    string
    Overrides
    ModelRuntime.Extension

    Methods

    Read(Stream, Func<MaterialData, Task<Material>>)

    Reads a USD file from a stream and processes its content.

    Declaration
    public override Task<Model> Read(Stream stream, Func<MaterialData, Task<Material>> materialAssigner = null)
    Parameters
    Type Name Description
    Stream stream

    The stream containing the USD file data.

    Func<MaterialData, Task<Material>> materialAssigner

    Optional function to assign materials.

    Returns
    Type Description
    Task<Model>

    A task representing the asynchronous operation, returning the processed model.

    Overrides
    ModelRuntime.Read(Stream, Func<MaterialData, Task<Material>>)
    Exceptions
    Type Condition
    ArgumentException

    Thrown if the stream is not readable or seekable.

    Read(string, Func<MaterialData, Task<Material>>)

    Reads a USD file from the specified file path and processes its content.

    Declaration
    public Task<Model> Read(string filePath, Func<MaterialData, Task<Material>> materialAssigner = null)
    Parameters
    Type Name Description
    string filePath

    The path to the USD file.

    Func<MaterialData, Task<Material>> materialAssigner

    A function to assign materials dynamically during the USD file processing.

    Returns
    Type Description
    Task<Model>

    A task representing the asynchronous operation, returning the processed model.

    ReadPythonUSD(string)

    Reads a USD file using Python integration and parses its content.

    Declaration
    public USDScene ReadPythonUSD(string filePath)
    Parameters
    Type Name Description
    string filePath

    The path to the USD file.

    Returns
    Type Description
    USDScene

    The parsed USD scene.

    ReadTexture(string, bool)

    Reads a texture from the specified image path. This method supports both standalone USD files and USDZ archives.

    Declaration
    public Task<Texture> ReadTexture(string imagePath, bool isGamma)
    Parameters
    Type Name Description
    string imagePath

    The relative or absolute path to the image file.

    bool isGamma

    Specifies if the texture has gamma correction.

    Returns
    Type Description
    Task<Texture>

    A task representing the asynchronous operation. The result contains the loaded Texture object, or null if the texture could not be loaded.

    Remarks
    • If the file extension is ".usdz", the method attempts to locate and read the texture from within the USDZ archive.
    • If the file is not part of a USDZ archive, it resolves the path relative to the working directory and loads the texture.
    • The method ensures that the image stream is properly disposed after reading.
    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the imagePath is null or empty.

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In this article
    Back to top
    Generated by DocFX