CustomMesh.FromMeshDataBuilder


class CustomMesh.FromMeshDataBuilder


Builder for CustomMesh providing raw data directly.

This will implicitly create a MeshBuffer for you. You provide the VertexLayout along with the raw vertex and index data:


val builder = CustomMesh.FromMeshDataBuilder(session, myLayout)
     .addVertexData(myVertexData)
     .setIndexData(myIndexData)

From here, you have two options for defining the mesh topology:

  • You can explicitly add one or more subsets:


builder.addSubset(MeshSubset(MeshSubsetTopology.TRIANGLES, 0, subset1Count))
builder.addSubset(MeshSubset(MeshSubsetTopology.TRIANGLES, subset1Count, subset2Count))
  • Or, if the entire mesh uses the same topology, you can define a single subset that spans all the provided index data:


builder.setTopology(MeshSubsetTopology.TRIANGLES)

Finally, build the mesh:


val mesh = builder.build()

Summary

Public constructors

FromMeshDataBuilder(session: Session, vertexLayout: VertexLayout)

Public functions

CustomMesh.FromMeshDataBuilder

Adds a MeshSubset defining a part of the mesh.

CustomMesh.FromMeshDataBuilder

Adds vertex data for a single buffer.

CustomMesh

Builds a new CustomMesh.

CustomMesh.FromMeshDataBuilder

Sets an optional user-supplied bounding box for culling.

CustomMesh.FromMeshDataBuilder

Sets the index data.

CustomMesh.FromMeshDataBuilder

Sets the MeshSubsetTopology to use for the entire mesh, defining a single subset that spans all provided index data.

Public constructors

FromMeshDataBuilder

Added in 1.0.0-alpha15
FromMeshDataBuilder(session: Session, vertexLayout: VertexLayout)

Public functions

addSubset

Added in 1.0.0-alpha15
fun addSubset(subset: MeshSubset): CustomMesh.FromMeshDataBuilder

Adds a MeshSubset defining a part of the mesh.

This cannot be used in combination with setTopology.

Throws
IllegalStateException

if a topology has already been set

addVertexData

Added in 1.0.0-alpha15
fun addVertexData(vertexData: ByteBufferRegion): CustomMesh.FromMeshDataBuilder

Adds vertex data for a single buffer.

The order in which this method is called determines the buffer index. The first call provides data for buffer index 0, the second for buffer index 1, etc. The data is copied, so the original java.nio.ByteBuffer can be modified or released without affecting the underlying MeshBuffer.

build

Added in 1.0.0-alpha15
@MainThread
fun build(): CustomMesh

Builds a new CustomMesh.

Throws
IllegalStateException

if index data or vertex data are missing, or if both or neither of subsets and topology are provided.

setBounds

Added in 1.0.0-alpha15
fun setBounds(bounds: BoundingBox): CustomMesh.FromMeshDataBuilder

Sets an optional user-supplied bounding box for culling.

If not provided, the auto-computed bounding box of the entire MeshBuffer will be used.

setIndexData

Added in 1.0.0-alpha15
fun setIndexData(indexData: ByteBufferRegion): CustomMesh.FromMeshDataBuilder

Sets the index data.

The data is copied, so the original java.nio.ByteBuffer can be modified or released without affecting the underlying MeshBuffer.

setTopology

Added in 1.0.0-alpha15
fun setTopology(topology: MeshSubsetTopology): CustomMesh.FromMeshDataBuilder

Sets the MeshSubsetTopology to use for the entire mesh, defining a single subset that spans all provided index data.

This cannot be used in combination with addSubset.

Throws
IllegalStateException

if subsets have already been added