Class OBJRuntime
Runtime for OBJ files.
Namespace: Evergine.Runtimes.OBJ
Assembly: Evergine.Runtimes.OBJ.dll
Syntax
public class OBJRuntime : ModelRuntime
Constructors
OBJRuntime(GraphicsContext, AssetsService, AssetsDirectory)
Initializes a new instance of the OBJRuntime class.
Declaration
public OBJRuntime(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
Instance
Gets the a default instance of the class resolving the required services using the default Evergine container.
Declaration
public static readonly OBJRuntime Instance
Field Value
| Type | Description |
|---|---|
| OBJRuntime |
LinearClampSampler
Default sampler state for linear filtering with clamp mode.
Declaration
public SamplerState LinearClampSampler
Field Value
| Type | Description |
|---|---|
| SamplerState |
LinearWrapSampler
Default sampler state for linear filtering with wrap mode.
Declaration
public SamplerState LinearWrapSampler
Field Value
| Type | Description |
|---|---|
| SamplerState |
Properties
Extension
Gets the file extension for the OBJ runtime.
Declaration
public override string Extension { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
UseSmoothNormals
Gets or sets a value indicating whether to use smooth normals.
Declaration
public bool UseSmoothNormals { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
WorkingDirectory
Gets or sets the working directory for the OBJ file.
Declaration
public string WorkingDirectory { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Read(Stream, Func<MaterialData, Task<Material>>)
Reads a 3D format file from the specified stream and returns a model asset.
Declaration
public override Task<Model> Read(Stream stream, Func<MaterialData, Task<Material>> materialAssigner = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream containing the OBJ file data. |
| Func<MaterialData, Task<Material>> | materialAssigner | A function to assign materials to the model. If null, default materials will be used. |
Returns
| Type | Description |
|---|---|
| Task<Model> | A task that represents the asynchronous operation. The task result contains the loaded Model. |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if the stream is not readable or seekable. |
| Exception | Thrown if the OBJ file fails to load. |
Read(string, Func<MaterialData, Task<Material>>, bool)
Reads a 3D format file from the specified file path and returns a model asset.
Declaration
public Task<Model> Read(string filePath, Func<MaterialData, Task<Material>> materialAssigner = null, bool useSmoothNormals = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | The path to the OBJ file to be read. |
| Func<MaterialData, Task<Material>> | materialAssigner | A function to assign materials to the model. If null, default materials will be used. |
| bool | useSmoothNormals | A boolean indicating whether to compute and use smooth normals for the model. |
Returns
| Type | Description |
|---|---|
| Task<Model> | A task that represents the asynchronous operation. The task result contains the loaded Model. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if the file stream is not readable or if the file cannot be opened. |
ReadTexture(string, bool)
Reads a texture from the specified file name.
Declaration
public Task<Texture> ReadTexture(string diffuseTexname, bool isGamma)
Parameters
| Type | Name | Description |
|---|---|---|
| string | diffuseTexname | The name of the texture file to be read. |
| bool | isGamma | Indicates if the texture has gamma correction. |
Returns
| Type | Description |
|---|---|
| Task<Texture> | A task that represents the asynchronous operation. The task result contains the loaded Texture object. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the texture file name is null or empty. |
| FileNotFoundException | Thrown if the specified texture file does not exist in the assets directory. |
| Exception | Thrown if there is an error during the texture loading process. |