Crate all_is_cubes_mesh

Crate all_is_cubes_mesh 

Source
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_cubes as 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 the dynamic module. Incompatible with no_std platforms.

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 SpaceMesh or BlockMesh.
BlockMesh
A triangle mesh for a single Block.
BlockVertex
Built-in vertex type for BlockMeshes.
DepthOrdering
Sorting and culling of transparent triangles of a SpaceMesh.
DepthSortInfo
Performance information returned by SpaceMesh::depth_sort_for_view().
DepthSortResult
Outcome of SpaceMesh::depth_sort_for_view(), specifying what changed.
MeshMeta
Index ranges and other metadata about a SpaceMesh, excluding the vertices and indices themselves.
MeshOptions
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.
SpaceMesh
A triangle mesh representation of a Space (or part of it).

Enums§

Coloring
Two ways a BlockVertex may be colored: by a solid color or by a texture.
IndexSlice
Data for meshes’ index lists, which may use either 16 or 32-bit values.

Traits§

GetBlockMesh
Source of BlockMesh values to be assembled into a SpaceMesh.
MeshTypes
Bundle of types chosen to support a specific graphics API or other mesh format.
Vertex
Vertex types for use in BlockMesh and SpaceMesh.

Functions§

block_meshes_for_space
Computes BlockMeshes for blocks currently present in a Space. Pass the result to SpaceMesh::new() to use it.

Type Aliases§

BlockMeshes
Array of BlockMesh indexed by a Space’s block indices; a convenience alias for the return type of block_meshes_for_space. Pass it to SpaceMesh::new() to use it.
PosCoord
Type used for the coordinates of vertex Positions.
Position
A vertex position within a BlockMesh or SpaceMesh.