wfc_voxel

Crates.iowfc_voxel
lib.rswfc_voxel
version0.2.0
sourcesrc
created_at2023-05-08 08:13:16.400349
updated_at2023-05-26 13:23:38.887787
descriptionA Wave Function Collapse solver using preliminary voxel files.
homepage
repositoryhttps://github.com/BonsonW/wfc_voxel
max_upload_size
id859584
size1,777,761
Bonson Wong (BonsonW)

documentation

README

Wave Function Collapse for Voxel Input

github crates.io docs.rs

This crate provides a solver for tile-based Wave Function Collapse. It automatically generates rules for map generation from preliminary voxel files. Currently, the crate only supports MagicaVoxel XRAW file formats.

Installation

Add to your current working directory:

cargo add wfc_voxel

Or add to your Cargo.toml:

wfc_voxel = "target_version"

Usage

// Initalize NodeSet from directory
let node_set = NodeSet::new(NODE_SIZE, "path/to/voxel/files", exclusions);

// Initialize Solver
let solver = Solver::new([MAP_WIDTH, MAP_HEIGHT, MAP_WIDTH], node_set.bit_mask(), &node_set);

// Get solved map
let map = solver.solve().unwrap();

// Dimensions of map
let shape = solver.shape();

for x in 0..shape[0] {
    for y in 0..shape[1] {
        for z in 0..shape[2] {
        
            // Get node id and asset name
            let node_id = map[[x, y, z]];
            let asset_name = node_set.get_asset_name(&node_id).unwrap();
            
            // Do something
        }
    }
}

Examples

See Isometric Demo for an example project. Preview

Commit count: 27

cargo fmt