Builder

class Builder

The Builder is used to construct an immutable surface orientation helper.

Clients provide pointers into their own data, which is synchronously consumed during build(). At a minimum, clients must supply a vertex count. They can supply data in any of the following combinations:

  1. normals only ........................... not recommended, selects arbitrary orientation

  2. normals + tangents ..................... sign of W determines bitangent orientation

  3. normals + uvs + positions + indices .... selects Lengyel's Method

  4. positions + indices .................... generates normals for flat shading only

Additionally, the client-side data has the following type constraints:

  • Normals must be 3-element float arrays

  • Tangents must be 4-element float arrays

  • UVs must be 2-element float arrays

  • Positions must be 3-element float arrays

  • Triangles must be 3-element index arrays (ushort or uint)

Currently, mikktspace is not supported because it requires re-indexing the mesh. Instead we use the method described by Eric Lengyel in "Foundations of Game Engine Development" (Volume 2, Chapter 7).

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard

Generates quaternions or returns null if the submitted data is an incomplete combination.

Link copied to clipboard

Specifies the vertex normals. Stride is the byte offset between consecutive normals.

Link copied to clipboard

Specifies the vertex positions. Stride is the byte offset between consecutive positions.

Link copied to clipboard

Specifies the vertex tangents. Stride is the byte offset between consecutive tangents.

Link copied to clipboard

Specifies the number of triangles in the mesh.

Link copied to clipboard

Specifies 32-bit triangle indices, 3 per triangle.

Specifies 16-bit triangle indices, 3 per triangle.

Link copied to clipboard
fun uvs(buffer: FloatArray, stride: Int = 0): SurfaceOrientation.Builder

Specifies the vertex texture coordinates. Stride is the byte offset between consecutive UVs.

Link copied to clipboard

Specifies the vertex count. This attribute is required.