MeshData

data class MeshData(val vertexData: VertexData, val polygons: List<IndexedPolygon>) : IMeshData(source)

Represents data for a 3D mesh. Implements the IMeshData interface and provides additional methods for manipulating and combining mesh data. This class is immutable and includes operations for triangulation, conversion to polygons, and joining multiple meshes.

Constructors

Link copied to clipboard
constructor(vertexData: VertexData, polygons: List<IndexedPolygon>)

Properties

Link copied to clipboard
val IMeshData.bounds: Box

Provides the bounding box of the mesh based on its polygons and associated vertex data.

Link copied to clipboard
open override val polygons: List<IndexedPolygon>

A list of polygons defined using indexed vertex data.

Link copied to clipboard
open override val vertexData: VertexData

The vertex data associated with the mesh, including positions, normals, tangents, texture coordinates, colors, and bitangents.

Functions

Link copied to clipboard

Checks if all polygons in the mesh are triangular.

Link copied to clipboard
open override fun join(other: IMeshData): IMeshData

Combines the current mesh data with another mesh data instance.

Link copied to clipboard
open override fun toMeshData(): MeshData

Converts the current mesh data into an immutable MeshData instance.

Link copied to clipboard
open override fun toMutableMeshData(): MutableMeshData

Converts the current mesh data into a mutable representation.

Link copied to clipboard
open override fun toPolygons(): List<Polygon>

Converts the current mesh data into a list of polygons.

Link copied to clipboard
fun IMeshData.toVertexBuffer(elementOffset: Int = 0, vertexBuffer: VertexBuffer? = null): VertexBuffer

Converts the current mesh data into a VertexBuffer representation, preparing geometry for rendering.

Link copied to clipboard
open override fun triangulate(): MeshData

Converts the current mesh data into a fully triangulated form.

Link copied to clipboard
fun IMeshData.weld(positionFractBits: Int, textureCoordFractBits: Int = -1, colorFractBits: Int = -1, normalFractBits: Int = -1, tangentFractBits: Int = -1, bitangentFractBits: Int = -1): MeshData

Welds the mesh data by consolidating vertices based on specified fractional bit precision for attributes such as positions, texture coordinates, colors, normals, tangents, and bitangents. This reduces redundant vertices and optimizes the mesh structure.

Link copied to clipboard
fun IMeshData.wireframe(): List<List<Vector3>>

Generates a wireframe representation of the mesh.