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
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
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
colorArrayColor4[]The color array.
widthintThe width.
heightintThe height.
depthintThe 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
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
databyte[]The image data.
pixelFormatFormatThe image pixel format.
widthintThe width.
heightintThe 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
databyte[]The image data.
pixelFormatFormatThe image pixel format.
widthintThe width.
heightintThe height.
depthintThe 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
contentIdGuidThe content identifier.
loaderITextureInfoLoaderThe loader.
TextureModel(Stream, bool)
Initializes a new instance of the TextureModel class.
public TextureModel(Stream stream, bool autoCloseStream = false)
Parameters
streamStreamThe compressed texture stream. Supports Jpg, Bmp, Png, Tiff, DDS, Wmp
autoCloseStreamboolClose 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
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
datanintThe image data.
pixelFormatFormatThe image pixel format.
widthintThe width.
heightintThe 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
datanintThe image data.
pixelFormatFormatThe image pixel format.
widthintThe width.
heightintThe height.
depthintThe 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
textureFilestringThe 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
infoTextureInfoThe information.
succboolif set to
true[succ].
Create(Stream)
Creates texture model from specified stream.
public static TextureModel? Create(Stream stream)
Parameters
streamStreamThe stream.
Returns
Create(string)
Creates texture model from specified texture path.
public static TextureModel? Create(string texturePath)
Parameters
texturePathstringThe texture path.
Returns
Load()
Loads the texture info.
public TextureInfo Load()
Returns
Operators
implicit operator TextureModel?(Stream?)
Performs an implicit conversion from Stream to TextureModel.
public static implicit operator TextureModel?(Stream? stream)
Parameters
streamStreamThe stream.
Returns
- TextureModel
The result of the conversion.