UVAtlas.Create Method |
Language: |
Creates one or more UV texture atlases.
Visual Basic Public Shared Function Create( _
ByVal mesh As Mesh, _
ByVal maxChartNumber As Integer, _
ByVal maxStretch As Single, _
ByVal width As Integer, _
ByVal height As Integer, _
ByVal gutter As Single, _
ByVal textureIndex As Integer, _
ByVal adjacency() As Integer, _
ByVal imtArray() As Single, _
ByVal callback As PercentageCompleteCallback, _
ByVal callbackFrequency As Single _
) As UVAtlasOutputC# public static UVAtlasOutput Create(
Mesh mesh,
int maxChartNumber,
float maxStretch,
int width,
int height,
float gutter,
int textureIndex,
int[] adjacency,
float[] imtArray,
PercentageCompleteCallback callback,
float callbackFrequency
);C++ public:
static UVAtlasOutput Create(
Mesh^ mesh,
int maxChartNumber,
float maxStretch,
int width,
int height,
float gutter,
int textureIndex,
array<int>^ adjacency,
array<float>^ imtArray,
PercentageCompleteCallback^ callback,
float callbackFrequency
);JScript public static function Create(
mesh : Mesh,
maxChartNumber : int,
maxStretch : float,
width : int,
height : int,
gutter : float,
textureIndex : int,
adjacency : int[],
imtArray : float[],
callback : PercentageCompleteCallback,
callbackFrequency : float
) : UVAtlasOutput;
mesh Microsoft.DirectX.Direct3D.Mesh
Input mesh used to calculate the atlas. The atlas must have a position channel and at least a 2-D texture channel.maxChartNumber System.Int32
The maximum number of charts required for the atlas. If this is 0, the atlas will be parameterized based solely on stretch.maxStretch System.Single
The maximum stretch resulting from the atlasing algorithm. 0 means do not stretch; 1 means any amount of stretching is allowed.width System.Int32
The width of the texture the atlas will be used on.height System.Int32
The height of the texture the atlas will be used on.gutter System.Single
The minimum distance, in texels between two charts on the atlas. The gutter is scaled by the width. For example, if a gutter of 2.5 is used on a 512x512 texture, then the minimum distance between two charts (in texels) will be 2.5 / 512.0 in uv space.textureIndex System.Int32
Specifies which texture coordinate to write to in the output mesh (which is cloned from the input mesh). Useful if your vertex has multiple texture coordinates.adjacency System.Int32[]
An array with 3 Int32s per face, indicating which triangles are adjacent to each other.imtArray System.Single[]
An array with 3 floating-point values per face, describing the integrated metric tensor for that face. See remarks.callback Microsoft.DirectX.Direct3D.PercentageCompleteCallback
A callback function that can be used to monitor progress.callbackFrequency System.Single
How often the callback specified by will be used. Use 0.0001f as a default value.
Microsoft.DirectX.Direct3D.UVAtlasOutput
Contains data about the created texture atlases.
This function has two modes of operation:
- Based on the number of charts
- Based on the maximum allowed stretch. If the maximum allowed stretch is 0, each triangle will likely be in its own chart.
Integrated Metric Tensor Array
The IMTArray is an array of integrated metric tensors. Each element uses 3 Singles to describe an IMT for a single face. The IMT controls how the triangle is stretched in the atlas. The IMT (3 singles - (a,b,c)) contains a symmetric 2x2 matrix as shown here:
a b b cGiven a vector (s,t) and two vectors v1 and v2:
vector v1 vector v2 = v1 + (s,t)The distance between vector v1 and v2 is:
sqrt((s, t) * M * (s, t)^T)In other words, the vector (s,t) enables you to specify the magnitude of the stretch in an arbitrary direction in u-v space; where s is the direction from the first to the second vertex, and t is the cross product of the normal and s. For example: a = b = 1 would scale the vector (1,1) by 2, and the vector (1,-1) by 0. Note that this is multiplying the edge length by the square of the matrix; if you want the face to stretch to twice its size with no shearing, the IMT value should be (2, 0, 2), which is the identity matrix times 2.
You can calculate IMTs from texture or vertex signal data by using the methods in the IntegratedMetricTensor class.
Exceptions
Direct3DXException The operation failed.
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.