Skip to content
Wave Function Collapse 3D | openFrameworks Addon
C++ Makefile QML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example-advance
example-basic
src
LICENSE
README.md
ofxaddons_thumbnail.png
symmetry.png
wfc_git_01.png
wfc_git_02.png

README.md

Wave Function Collapse

A C++ implementation of the Wave Function Collapse Tile-Model algorithm by @mxgmn ready for OpenFrameworks.

wfc_git_01

wfc_git_02

About

ofxWFC3D works in 3 dimensions, uses XML configuration files and outputs ofNode elements.

It supports the original symmetry, rotations and subsets. It also implements new functionalities.

ofxWFC3D does not require any specific hardware or external libraries and work in every OS.

symmetry

Usage

// instance the WFC3D
ofxWFC3D wfc;

// config_name, subset, x, y, z, periodic=false, ground_name="", surround_name=""
wfc.SetUp("data.xml", "default", width, height, length);

// run the WFC3D
// (the algorithm may runs into contradictions)
wfc.Run(seed);

// get the list of ofNodes, using 'world_node' as parent
ofNode world_node;
auto nodes = wfc.NodeTileOutput(world_node, glm::vec3(size_x,size_y,size_z));

Specific tiles instantiation

It reduces entropy and limits randomness creating predictable results.

// instanciate an specific tile on the WFC
wfc.SetTile("tile", x, y, z); 

Special features

+ symmetry

This version of the WFC, includes tiles without symmetry. For complex structures and systems that require a very concrete tile union, use the symmetry type "+".

<tile name="corner" symmetry="+"/>

Height range

<tile name="roof" symmetry="I" min-height="2" max-height="4"/>

Performance

Example basic

// OF 0.10.1 - Arch-Linux | i7-6500U

| Process	| Microsecond   | Attempts  |
| ------------- | ------------- | --------- |
| SetUp		| 3204          | 1         |
| SetUp		| 1452          | 1         |
| SetUp		| 1438          | 1         |
| SetUp		| 451           | 1         |
| Run		| 140883        | 1         |
| Run		| 142980        | 1         |
| Run		| 134868        | 1         |
| Run		| 117848        | 1         |

Example advance

// OF 0.10.1 - Arch-Linux | i7-6500U

| Process	| Microsecond   | Attempts  |
| ------------- | ------------- | --------- |
| SetUp		| 2520          | 1         |
| SetUp		| 2025          | 1         |
| SetUp		| 1463          | 1         |
| SetUp		| 526           | 1         |
| Run		| 59608         | 3         | 2 contradictions
| Run		| 60894         | 4         | 3 contradictions
| Run		| 75666         | 3         | 2 contradictions
| Run		| 64881         | 1         |
| Run		| 69637         | 2         | 1 contradiction

License

ofxWFC3D is distributed under the MIT License.

You can’t perform that action at this time.