Table of Contents

Class TextureModel

Namespace
HelixToolkit.SharpDX
Assembly
HelixToolkit.SharpDX.dll

Texture model contains TextureInfoLoader and a Guid to identify specific texture. TextureInfoLoader is being called to load texture during GPU texture resource creation.

Helixtoolkit provides basic implementation for texture info loaders.

User can provide own implementation for TextureInfoLoader for better texture resource/data management.

[TypeConverter(typeof(StreamToTextureModelConverter))]
public sealed class TextureModel
Inheritance
TextureModel
Inherited Members

Constructors

TextureModel(Color4[], int)

Initializes a new instance of the TextureModel class.

public TextureModel(Color4[] colorArray, int width)

Parameters

colorArray Color4[]

The color array.

width int

The width.

Exceptions

ArgumentException

Width = {width} does not equal to the Color Array Length {colorArray.Length}

TextureModel(Color4[], int, int)

Initializes a new instance of the TextureModel class.

public TextureModel(Color4[] colorArray, int width, int height)

Parameters

colorArray Color4[]

The color array.

width int

The width.

height int

The height.

Exceptions

ArgumentException

Width * Height = {width * height} does not equal to the Color Array Length {colorArray.Length}

TextureModel(Color4[], int, int, int)

Initializes a new instance of the TextureModel class.

public TextureModel(Color4[] colorArray, int width, int height, int depth)

Parameters

colorArray Color4[]

The color array.

width int

The width.

height int

The height.

depth int

The depth.

Exceptions

ArgumentException

Width * Height * Depth = {width * height * depth} does not equal to the Color Array Length {colorArray.Length}

TextureModel(byte[], Format, int)

Initializes a new instance of the TextureModel class.

public TextureModel(byte[] data, Format pixelFormat, int width)

Parameters

data byte[]

The image data.

pixelFormat Format

The image pixel format.

width int

The width.

Exceptions

ArgumentException

Width = {width} does not correspond to the Data Array Length {data.Length}

TextureModel(byte[], Format, int, int)

Initializes a new instance of the TextureModel class.

public TextureModel(byte[] data, Format pixelFormat, int width, int height)

Parameters

data byte[]

The image data.

pixelFormat Format

The image pixel format.

width int

The width.

height int

The height.

Exceptions

ArgumentException

Width * Height = {width * height} does not correspond to the Data Array Length {data.Length}

TextureModel(byte[], Format, int, int, int)

Initializes a new instance of the TextureModel class.

public TextureModel(byte[] data, Format pixelFormat, int width, int height, int depth)

Parameters

data byte[]

The image data.

pixelFormat Format

The image pixel format.

width int

The width.

height int

The height.

depth int

The depth.

Exceptions

ArgumentException

Width * Height * Depth = {width * height * depth} does not correspond to the Data Array Length {data.Length}

TextureModel(Guid, ITextureInfoLoader)

Provides interface for user defined texture loader. HelixToolkit will call Load(Guid) to start loading content into GPU. HelixToolkit will call Complete(Guid, TextureInfo?, bool) once content has been loaded into GPU.

public TextureModel(Guid contentId, ITextureInfoLoader loader)

Parameters

contentId Guid

The content identifier.

loader ITextureInfoLoader

The loader.

TextureModel(Stream, bool)

Initializes a new instance of the TextureModel class.

public TextureModel(Stream stream, bool autoCloseStream = false)

Parameters

stream Stream

The compressed texture stream. Supports Jpg, Bmp, Png, Tiff, DDS, Wmp

autoCloseStream bool

Close the stream after being uploaded into GPU. Use with caution since the stream cannot be re-used after being closed.

TextureModel(nint, Format, int)

Initializes a new instance of the TextureModel class.

public TextureModel(nint data, Format pixelFormat, int width)

Parameters

data nint

The image data.

pixelFormat Format

The image pixel format.

width int

The width.

Exceptions

ArgumentException

Width = {width} does not correspond to the Data Length

TextureModel(nint, Format, int, int)

Initializes a new instance of the TextureModel class.

public TextureModel(nint data, Format pixelFormat, int width, int height)

Parameters

data nint

The image data.

pixelFormat Format

The image pixel format.

width int

The width.

height int

The height.

Exceptions

ArgumentException

Width * Height = {width * height} does not correspond to the Data Length

TextureModel(nint, Format, int, int, int)

Initializes a new instance of the TextureModel class.

public TextureModel(nint data, Format pixelFormat, int width, int height, int depth)

Parameters

data nint

The image data.

pixelFormat Format

The image pixel format.

width int

The width.

height int

The height.

depth int

The depth.

Exceptions

ArgumentException

Width * Height * Depth = {width * height * depth} does not correspond to the Data Length

TextureModel(string)

Initializes a new instance of the TextureModel class.

public TextureModel(string textureFile)

Parameters

textureFile string

The texture file.

Properties

Guid

Gets the unique identifier.

public Guid Guid { get; }

Property Value

Guid

The unique identifier.

Tag

Gets the tag.

public object? Tag { get; }

Property Value

object

The tag.

TextureInfoLoader

Gets the texture information loader.

public ITextureInfoLoader TextureInfoLoader { get; }

Property Value

ITextureInfoLoader

The texture information loader.

TextureModelRepository

Gets or sets the texture model repository. Repository is used to load texture from file path.

You can customize the repository to provider your own implementation. Helixtoolkit will ask repository to load texture on-demand.

public static ITextureModelRepository TextureModelRepository { get; set; }

Property Value

ITextureModelRepository

The texture model repository.

Methods

Complete(TextureInfo, bool)

Completes loading

public void Complete(TextureInfo info, bool succ)

Parameters

info TextureInfo

The information.

succ bool

if set to true [succ].

Create(Stream)

Creates texture model from specified stream.

public static TextureModel? Create(Stream stream)

Parameters

stream Stream

The stream.

Returns

TextureModel

Create(string)

Creates texture model from specified texture path.

public static TextureModel? Create(string texturePath)

Parameters

texturePath string

The texture path.

Returns

TextureModel

Load()

Loads the texture info.

public TextureInfo Load()

Returns

TextureInfo

Operators

implicit operator TextureModel?(Stream?)

Performs an implicit conversion from Stream to TextureModel.

public static implicit operator TextureModel?(Stream? stream)

Parameters

stream Stream

The stream.

Returns

TextureModel

The result of the conversion.