class
MeshUtility
Performs various operations on mesh geometry.
Public
Methods
staticCalculateNormals
Calculates per-vertex normals based on the provided vertices and indices.
- vertices
- Set of vertices containing vertex positions.
- indices
- Set of indices containing indexes into vertex array for each triangle.
- vertexCount
- Number of vertices in the array.
- indexCount
- Number of indices in the array. Must be a multiple of three.
- normals
- Pre-allocated buffer that will contain the calculated normals. Must be the same size as the vertex array.
- indexSize
- Size of a single index in the indices array, in bytes.
staticCalculateTangents
Calculates per-vertex tangents and bitangents based on the provided vertices, uv coordinates and indices.
- vertices
- Set of vertices containing vertex positions.
- normals
- Set of normals to use when calculating tangents. Must the the same length as the number of vertices.
- uv
- Set of UV coordinates to use when calculating tangents. Must the the same length as the number of vertices.
- indices
- Set of indices containing indexes into vertex array for each triangle.
- vertexCount
- Number of vertices in the , and arrays.
- indexCount
- Number of indices in the array. Must be a multiple of three.
- tangents
- Pre-allocated buffer that will contain the calculated tangents. Must be the same size as the vertex array.
- bitangents
- Pre-allocated buffer that will contain the calculated bitangents. Must be the same size as the vertex array.
- indexSize
- Size of a single index in the indices array, in bytes.
- vertexStride
- Number of bytes to advance the , and arrays with each vertex. If set to zero them each array is advanced according to its own size.
staticCalculateTangentSpace
Calculates per-vertex tangent space (normal, tangent, bitangent) based on the provided vertices, uv coordinates and indices.
- vertices
- Set of vertices containing vertex positions.
- uv
- Set of UV coordinates to use when calculating tangents.
- indices
- Set of indices containing indexes into vertex array for each triangle.
- vertexCount
- Number of vertices in the "vertices" array.
- indexCount
- Number of indices in the "indices" array. Must be a multiple of three.
- normals
- Pre-allocated buffer that will contain the calculated normals. Must be the same size as the vertex array.
- tangents
- Pre-allocated buffer that will contain the calculated tangents. Must be the same size as the vertex array.
- bitangents
- Pre-allocated buffer that will contain the calculated bitangents. Must be the same size as the vertex array.
- indexSize
- Size of a single index in the indices array, in bytes.
staticClip2D
Clips a set of two-dimensional vertices and uv coordinates against a set of arbitrary planes.
- vertices
- A set of vertices in Vector2 format. Each vertex should be bytes from each other.
- uvs
- A set of UV coordinates in Vector2 format. Each coordinate should be bytes from each other. Can be null if UV is not needed.
- triangleCount
- Number of triangles to clip (must be number of vertices/uvs / 3).
- vertexStride
- Distance in bytes between two separate vertex or UV values in the provided and buffers.
- clipPlanes
- A set of planes to clip the vertices against. Since the vertices are two-dimensional the plane's Z coordinate should be zero.
- writeCallback
- Callback that will be triggered when clipped vertices and UV coordinates are generated and need to be stored. Vertices are always generate in tuples of three, forming a single triangle.
staticClip3D
Clips a set of three-dimensional vertices and uv coordinates against a set of arbitrary planes.
- vertices
- A set of vertices in Vector3 format. Each vertex should be bytes from each other.
- uvs
- A set of UV coordinates in Vector2 format. Each coordinate should be bytes from each other. Can be null if UV is not needed.
- triangleCount
- Number of triangles to clip (must be number of vertices/uvs / 3).
- vertexStride
- Distance in bytes between two separate vertex or UV values in the provided and buffers.
- clipPlanes
- A set of planes to clip the vertices against.
- writeCallback
- Callback that will be triggered when clipped vertices and UV coordinates are generated and need to be stored. Vertices are always generate in tuples of three, forming a single triangle.
staticPackNormals
Encodes normals from 32-bit float format into 4D 8-bit packed format.
- source
- Buffer containing data to encode. Must have entries.
- destination
- Buffer to output the data to. Must have entries, each 32-bits.
- count
- Number of entries in the and arrays.
- inputStride
- Distance between two entries in the buffer, in bytes.
- outputStride
- Distance between two entries in the buffer, in bytes.
staticPackNormals
Encodes normals from 32-bit float format into 4D 8-bit packed format.
- source
- Buffer containing data to encode. Must have entries.
- destination
- Buffer to output the data to. Must have entries, each 32-bits.
- count
- Number of entries in the and arrays.
- inputStride
- Distance between two entries in the buffer, in bytes.
- outputStride
- Distance between two entries in the buffer, in bytes.
staticUnpackNormals
Decodes normals from 4D 8-bit packed format into a 32-bit float format.
- source
- Buffer containing data to encode. Must have entries, each 32-bits.
- destination
- Buffer to output the data to. Must have entries.
- count
- Number of entries in the and arrays.
- stride
- Distance between two entries in the buffer, in bytes.
staticUnpackNormals
Decodes normals from 4D 8-bit packed format into a 32-bit float format.
- source
- Buffer containing data to encode. Must have entries, each 32-bits.
- destination
- Buffer to output the data to. Must have entries.
- count
- Number of entries in the and arrays.
- stride
- Distance between two entries in the buffer, in bytes.
staticUnpackNormal
Decodes a normal from 4D 8-bit packed format into a 32-bit float format.