Class TMaterial
TMaterial is an adaptation of texture mapping for haptic rendering.
Namespace: Tanvas.TanvasTouch.Resources
Assembly: Tanvas.TanvasTouch.dll
Syntax
public sealed class TMaterial : TResource
Remarks
A TMaterial controls how TTextures are mapped onto a TSprite. TMaterial also offers limited texture blending support: if multiple textures are mapped onto a single TMaterial, the textures will be averaged.
Up to three TTextures can be assigned to a TMaterial.
A TMaterial does not own the TTextures it references, and therefore does not dispose those TTextures when it is disposed.
Constructors
TMaterial()
Declaration
public TMaterial()
Methods
AddTexture(Int32, TTexture)
Declaration
public void AddTexture(int index, TTexture texture)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | |
TTexture | texture |
Remarks
The default UV coordinates for a material's texture maps the full texture onto the material's sprite, i.e. they are [(0, 0), (1, 0), (1, 1), (0, 1)]. The default wrapping mode is Clamp.
After adding a texture, the UV coordinates and wrapping mode of that texture may be changed using SetUVs(Int32, TVec2f[]) and SetWrappingMode(Int32, TMaterial.WrappingMode) respectively.
GetTexture(Int32)
Gets the TTexture at the given index.
Declaration
public TTexture GetTexture(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of a TTexture. |
Returns
Type | Description |
---|---|
TTexture | The TTexture at the given index, or null if there is no texture at that index. |
GetTextures()
Declaration
public TTexture[] GetTextures()
Returns
Type | Description |
---|---|
TTexture[] | An array of referenced TTextures. |
Remarks
The length of the returned TTexture array is always equal to the maximum number of TTextures allowed on a TMaterial. Indices without a corresponding TTexture will contain null.
GetUVs(Int32)
Gets the UV coordinates for the TTexture at the given index.
Declaration
public TVec2f[] GetUVs(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of a TTexture. |
Returns
Type | Description |
---|---|
TVec2f[] | The UV coordinates for the TTexture at the given index. |
Remarks
If there is no TTexture at a given index, this method will still return UV coordinates for that index. This is an artifact of implementation details; you can expect this behavior to change in future minor revisions of the .NET API.
GetWrappingMode(Int32)
Gets the wrapping mode for the TTexture at the given index.
Declaration
public TMaterial.WrappingMode GetWrappingMode(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of a TTexture. |
Returns
Type | Description |
---|---|
TMaterial.WrappingMode |
ReleaseHandle()
Declaration
protected override void ReleaseHandle()
Overrides
RemoveTexture(Int32)
Declaration
public void RemoveTexture(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
SetUVs(Int32, TVec2f[])
Sets the UV coordinates for the TTexture at the given index.
Declaration
public void SetUVs(int index, TVec2f[] coordinates)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of a TTexture. |
TVec2f[] | coordinates | The new UV coordinates for the TTexture. |
Remarks
This function makes a copy of the UV coordinates in coordinates
. Therefore,
changes made to coordinates
will not have an effect on texture mapping
until this method is invoked with the updated array.
SetWrappingMode(Int32, TMaterial.WrappingMode)
Sets the wrapping mode for the TTexture at the given index.
Declaration
public void SetWrappingMode(int index, TMaterial.WrappingMode mode)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index of the TTexture to change its wrapping mode |
TMaterial.WrappingMode | mode | the new wrapping mode for the TTexture |