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
GfxVertex
and texture::Allocator
traits, then implement MeshTypes
to bundle them
together.
Modules§
- Updating meshes as their source data changes.
- Traits for textures used by the meshes this library generates.
Structs§
- A triangle mesh for a single
Block
. - Basic vertex data type for a
BlockMesh
. Implement
(and usuallyFrom
<BlockVertex
>GfxVertex
) to provide a specialized version fit for the target graphics API. - Index ranges and other metadata about a
SpaceMesh
, excluding the vertices and indices themselves. - Parameters for creating meshes that aren’t the block/space data itself (or the texture allocator, since that may need to be mutable).
- A triangle mesh representation of a
Space
(or part of it) which may then be rasterized.
Enums§
- Describes the two ways a
BlockVertex
may be colored; by a solid color or by a texture. - Identifies a back-to-front order in which to draw triangles (of a
SpaceMesh
), based on the direction from which they are being viewed. - Data for meshes’ index lists, which may use either 16 or 32-bit values.
Traits§
- A custom representation of
BlockVertex
suitable for a specific graphics system. - Bundle of types chosen to support a specific graphics API or other mesh format.
Functions§
- Computes
BlockMeshes
for blocks currently present in aSpace
. Pass the result toSpaceMesh::new()
to use it.
Type Aliases§
- Array of
BlockMesh
indexed by aSpace
’s block indices; a convenience alias for the return type ofblock_meshes_for_space
. Pass it toSpaceMesh::new()
to use it.