Expand description
Data structures and algorithms for converting all_is_cubes voxel data to triangle
meshes for rendering or export.
All of the algorithms here are independent of graphics API, but they require providing vertex and texture data types suitable for the API or data format you wish to use.
Restrictions and caveats:
- The algorithms always generate triangles with counterclockwise winding order.
- The generated meshes are designed for rendering and not for purposes which require “watertight” meshes such as 3D printing systems.
- The generated meshes are in the “blocky” style (have the appearance of being made of
axis-aligned cubes) rather than attempting to present a smooth surface (as would be
produced by, for example, the marching cubes algorithm); this is consistent with the
approach used by
all_is_cubesas a whole.
§Getting started
BlockMesh and SpaceMesh are the key types; everything else supports their
creation and usage. For real-time dynamically modified meshes, use
dynamic::ChunkedSpaceMesh.
To support a new API/format, you will need to create suitable implementations of the
Vertex and texture::Allocator traits, then implement MeshTypes to bundle them
together.
§Package features
This package defines the following feature flags:
"auto-threads": Enables implicit use of threads for parallel and background processing, including via [rayon]’s global thread pool."dynamic": Enable thedynamicmodule. Incompatible withno_stdplatforms.
Modules§
- dynamic
- Updating meshes as their source data changes.
- texture
- Traits for textures used by the meshes this library generates.
Structs§
- Aabbs
- Axis-aligned bounding boxes of a
SpaceMeshorBlockMesh. - Block
Mesh - A triangle mesh for a single
Block. - Block
Vertex - Built-in vertex type for
BlockMeshes. - Depth
Ordering - Sorting and culling of transparent triangles of a
SpaceMesh. - Depth
Sort Info - Performance information returned by
SpaceMesh::depth_sort_for_view(). - Depth
Sort Result - Outcome of
SpaceMesh::depth_sort_for_view(), specifying what changed. - Mesh
Meta - Index ranges and other metadata about a
SpaceMesh, excluding the vertices and indices themselves. - Mesh
Options - Parameters for creating meshes that aren’t the block/space data itself (or the texture allocator, since that may need to be mutable).
- MeshRel
- Coordinate system marker type for points within a
SpaceMesh. - Space
Mesh - A triangle mesh representation of a
Space(or part of it).
Enums§
- Coloring
- Two ways a
BlockVertexmay be colored: by a solid color or by a texture. - Index
Slice - Data for meshes’ index lists, which may use either 16 or 32-bit values.
Traits§
- GetBlock
Mesh - Source of
BlockMeshvalues to be assembled into aSpaceMesh. - Mesh
Types - Bundle of types chosen to support a specific graphics API or other mesh format.
- Vertex
- Vertex types for use in
BlockMeshandSpaceMesh.
Functions§
- block_
meshes_ for_ space - Computes
BlockMeshesfor blocks currently present in aSpace. Pass the result toSpaceMesh::new()to use it.
Type Aliases§
- Block
Meshes - Array of
BlockMeshindexed by aSpace’s block indices; a convenience alias for the return type ofblock_meshes_for_space. Pass it toSpaceMesh::new()to use it. - PosCoord
- Type used for the coordinates of vertex Positions.
- Position
- A vertex position within a
BlockMeshorSpaceMesh.