All Projects → bonsairobo → Building Blocks

bonsairobo / Building Blocks

Licence: mit
A voxel library for real-time applications.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Building Blocks

pymadcad
Simple yet powerful CAD (Computer Aided Design) library, written with Python.
Stars: ✭ 63 (-55%)
Mutual labels:  geometry, rendering, mesh
Vxr
General purpose engine written in C++ with emphasis on materials rendering (PBR, clear coat, anisotropy, iridescence)
Stars: ✭ 181 (+29.29%)
Mutual labels:  gamedev, 3d, rendering
Hole fixer
Demo implementation of smoothly filling holes in 3D meshes using surface fairing
Stars: ✭ 165 (+17.86%)
Mutual labels:  3d, mesh, geometry
3d Machine Learning
A resource repository for 3D machine learning
Stars: ✭ 7,405 (+5189.29%)
Mutual labels:  3d, mesh, voxel
Assetkit
🎨 Modern 2D/3D - Importer • Exporter • Util - Library, also called (AssetIO)
Stars: ✭ 97 (-30.71%)
Mutual labels:  3d, mesh
Bgfx
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
Stars: ✭ 10,252 (+7222.86%)
Mutual labels:  gamedev, rendering
Jeelizglassesvtowidget
JavaScript/WebGL glasses virtual try on widget. Real time webcam experience, robust to all lighting conditions, high end 3D PBR rendering, easy to integrate, fallback to server-side rendering
Stars: ✭ 134 (-4.29%)
Mutual labels:  3d, rendering
Polylidar
Polylidar3D - Fast polygon extraction from 3D Data
Stars: ✭ 106 (-24.29%)
Mutual labels:  mesh, geometry
Two
c++ toolkit for rapid development of live graphical apps and games
Stars: ✭ 1,288 (+820%)
Mutual labels:  gamedev, rendering
Renderer
A shader-based software renderer written from scratch in C89
Stars: ✭ 1,366 (+875.71%)
Mutual labels:  3d, rendering
Diligentsamples
Sample projects demonstrating the usage of Diligent Engine
Stars: ✭ 138 (-1.43%)
Mutual labels:  gamedev, rendering
Trimesh
Python library for loading and using triangular meshes.
Stars: ✭ 1,303 (+830.71%)
Mutual labels:  mesh, geometry
Plexus
Polygonal mesh processing.
Stars: ✭ 90 (-35.71%)
Mutual labels:  mesh, geometry
Qake
Qake voxel-engine demo
Stars: ✭ 100 (-28.57%)
Mutual labels:  gamedev, voxel
3dhop
3D Heritage Online Presenter
Stars: ✭ 89 (-36.43%)
Mutual labels:  3d, mesh
Tinyraycaster
486 lines of C++: old-school FPS in a weekend
Stars: ✭ 1,383 (+887.86%)
Mutual labels:  3d, rendering
Svg.skia
An SVG rendering library.
Stars: ✭ 122 (-12.86%)
Mutual labels:  rendering, geometry
Gamedev Resources
🎮 🎲 A wonderful list of Game Development resources.
Stars: ✭ 2,054 (+1367.14%)
Mutual labels:  gamedev, 3d
Hilo3d
Hilo3d, a WebGL Rendering Engine.
Stars: ✭ 123 (-12.14%)
Mutual labels:  3d, rendering
Cityengine Sdk
CityEngine is a 3D city modeling software for urban design, visual effects, and VR/AR production. With its C++ SDK you can create plugins and standalone apps capable to execute CityEngine CGA procedural modeling rules.
Stars: ✭ 137 (-2.14%)
Mutual labels:  3d, geometry

building-blocks

Crates.io Docs.rs license Crates.io Discord

Building Blocks is a voxel library for real-time applications.

Meshing

Wireframe

LOD Terrain

The primary focus is core data structures and algorithms. Features include:

  • 2D and 3D data storage
    • a ChunkMap with generic chunk storage
    • chunk compression and caching
    • structure-of-arrays (SoA) storage of multiple data channels per spatial dimension
    • OctreeSet hierarchical set of voxel points
    • all storages are serializable with serde
  • mesh generation
    • Surface Nets isosurface extraction
    • Minecraft-style greedy meshing
    • height maps
  • spatial queries
    • sparse traversal and search over octrees
    • ray casting and sphere casting against octrees with ncollide3d
    • Amanatides and Woo ray grid traversal
    • pathfinding
  • level of detail
    • OctreeChunkIndex as a hierarchical index of chunk IDs
    • ChunkPyramid for multiresolution voxel data and downsampling
    • algorithms for finding active chunks and updates to a 3D clipmap
    • multiresolution Surface Nets (TODO)
  • procedural generation
    • sampling signed distance fields
    • constructive solid geometry with sdfu

Short Code Example

The code below samples a signed distance field and generates a mesh from it.

use building_blocks::{
    core::sdfu::{Sphere, SDF},
    prelude::*,
    mesh::{SurfaceNetsBuffer, surface_nets},
};

let center = Point3f::fill(25.0);
let radius = 10.0;
let sphere_sdf = Sphere::new(radius).translate(center);

let extent = Extent3i::from_min_and_shape(Point3i::ZERO, Point3i::fill(50));
let mut samples = Array3x1::fill_with(extent, |p| sphere_sdf.dist(Point3f::from(p)));

let mut mesh_buffer = SurfaceNetsBuffer::default();
let voxel_size = 2.0; // length of the edge of a voxel
surface_nets(&samples, samples.extent(), voxel_size, &mut mesh_buffer);

Learning

Design and Architecture

There is a terse design doc that gives an overview of design decisions made concerning the current architecture. You might find this useful as a high-level summary of the most important pieces of code.

Docs and Examples

The current best way to learn about the library is to read the documentation and examples. For the latest stable docs, look here. For the latest unstable docs, clone the repo and run

cargo doc --open

There is plentiful documentation with examples. Take a look in the examples/ directory to see how Building Blocks can be used in real applications.

Getting Started

This library is organized into several crates. The most fundamental are:

  • core: lattice point and extent data types
  • storage: storage for lattice maps, i.e. functions defined on Z^2 and Z^3

Then you get extra bits of functionality from the others:

  • mesh: 3D mesh generation algorithms
  • search: search algorithms on lattice maps

To learn the basics about lattice maps, start with these doc pages:

After that, you might be interested in hierarchical structures to help you scale your voxel application. For that, you'll want to read the multiresolution module doc page.

Benchmarks

To run the benchmarks (using the "criterion" crate), go to the root of a crate and run cargo bench. As of version 0.5.0, all benchmark results are posted in the release notes.

Configuration

LTO

It is highly recommended that you enable link-time optimization when using building-blocks. It will improve the performance of critical algorithms like meshing by up to 2x. Just add this to your Cargo.toml:

[profile.release]
lto = true

Cargo Features

Building Blocks is organized into several crates, some of which are hidden behind features, and some have features themselves, which get re-exported by the top-level crate. By default, most features are enabled. You can avoid taking unnecessary dependencies by declaring default-features = false in your Cargo.toml:

[dependencies.building-blocks]
version = "0.5"
default-features = false
features = ["foo", "bar"]

Math Type Conversions

The PointN types have conversions to/from glam, nalgebra, and mint types by enabling the corresponding feature.

Compression Backends and WASM

Chunk compression supports two backends out of the box: Lz4 and Snappy. They are enabled with the "lz4" and "snappy" features. "lz4" is the default, but it relies on a C++ library, so it's not compatible with WASM. But Snappy is pure Rust, so it can! Just use default-features = false and add "snappy" to you features list.

VOX Files

".VOX" files are supported via the dot_vox crate. Enable the dot_vox feature to expose the generic encode_vox function and Array3x1::decode_vox constructor.

Images

Arrays can be converted to ImageBuffers and constructed from GenericImageViews from the image crate. Enable the image feature to expose the generic encode_image function and From<Im> where Im: GenericImageView impl.

Signed Distance Field Utilities (sdfu)

The sdfu crate provides convenient APIs for constructive solid geometry operations. By enabling this feature, the PointN types will implement the sdfu::mathtypes traits in order to be used with these APIs. The sdfu crate also gets exported under building_blocks::core::sdfu.

Development

We prioritize work according to the project board.

If you'd like to make a contribution, please first read the design philosophy and contribution guidelines.

License: MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].