Meshes
There are predefined helper functions for common shapes:
quad(halfSideX, halfSideY)- z-axis facing quad with given half-dimensionsbiQuad(halfSideX, halfSideY)- two-sided quad visible from both sidescube(halfSide)- cube with given half-edgesphere(radius, slices, sectors)- sphere with given radius and tessellationcylinderSide(height, radius, sectors)- cylindrical surface without basesconeTop(height, radius, sectors)- conical surface without basedisk(radius, sectors)- flat disk in xz planeobj("models/file.obj")- loads a mesh from a Wavefront .obj filepipeMesh(id, segments, dynamic, block)- shape consisting of multiple connected cylinders (pipes)
It's also possible to generate custom meshes via the customMesh helper function:
customMesh("road", 4, 6) {
pos(Vec3(-0.5f, 0f, 0f), Vec3(-0.5f, 0f, 32f), Vec3(0.5f, 0f, 32f), Vec3(0.5f, 0f, 0f))
tex(Vec2(0f, 0f), Vec2(0f, 32f), Vec2(1f, 32f), Vec2(1f, 0f))
index(0, 1, 2, 0, 2, 3)
}
Additional MeshInitializer methods for advanced geometry:
normal(vararg Vec3)- vertex normals for lightingattr(attribute, vararg values)- custom per-vertex attributesattrBytes(attribute, rawBytes)- custom attributes from raw byte dataattrSet(attribute, index, value)- set a single vertex attributeindexBytes(rawBytes)- indices from raw byte dataembed(prototype, transform, colorTexIndex)- embed another mesh with optional transform
Other mesh declaration methods:
mesh(id, mesh)- create a mesh declaration from an existingMeshobjectcompositeMesh(id, prototypes, attributes, instancingParameters, dynamic, block)- combine multiple prototype meshes into a single instanced meshheightField(id, cellsX, cellsZ, cellWidth, height)- heightfield mesh from a height functionloadMesh(meshDeclaration)- eagerly load a mesh from a declaration (returnsDeferred<Mesh>)
Note that if dynamic is set to true for customMesh or pipeMesh, the mesh data can be updated each frame.