Marching Cubes Doc

5
Ruaumoko Iso-surface creation suite for Unity created by Dr. Ben 

Transcript of Marching Cubes Doc

 

RuaumokoIso-surface creation suite for Unity

created by Dr. Ben 

 

Contents1. Introduction2. Demos3. Package Contents4. How-To Documentation

a. Marching Cubesb. Ruaumoko Surface/Density Generator

1. Introduction

This package provides the core functionality to generate amazing, professional iso-surface terrain. The results can be fully destructible and deformable on-the-fly, either generated in the editor or paged infinitely in your game!

The heart of this engine is a Marching Cubes implementation, which can generatepolygonal meshes for an iso-surface from any 3D scalar field data (also called voxels).Details of the algorithm can be found at

http://en.wikipedia.org/wiki/Marching_cubes

Inspiration for the Ruaumoko implementation came from GPU Gems 3:

http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html

2. Demos

Included with the package are several demo scenes to display some of the capabilitiesof this engine. Some details are presented here:

IceSculpting

A destructible/constructible world demo. Blocks of voxel data are created and the playerdropped inside. Using ray-casts against the blocks' mesh colliders the blocks are melted& regrown at the player's whim.

Primary functionality is on the SculptTool (attached to the First Person Controller) andthe DynamicSculpture blocks.

 

The Sculpting Tool exposes the following parameters:• Range: how far the sculpt ray-casts reach• Strength: how quickly the "dynamic sculptures" melt or grow• Impact Radius: the "brush size" of the tool• Growth Cut Off Distance: the near-distance at which point growth (freezing) will

stop. This prevents the player from freezing the surface over themselves andfalling through the world.

Isosurface World

This demo generates a section of a world using octaves of classic noise, loads a 3Dscalar field, and then "marches cubes" to extract the polygonal mesh for the player towalk on.

The Terrain Density Generator script contains all of this functionality. Typical settings areshown in the image below:

 

Terrain Density Generator Parameters:• My Material: the material to apply to the terrain.• Surface Threshold: where to extract the isosurface from the voxelized data• Size: how many cells to generate (try larger–it takes longer to load)• Block_size: how many voxels to lump into one mesh. Try other sizes!• Noise Strengths: the octaves of noise for generating the terrain. Powers of 2

generate more conventional terrain (16, 8, 4, 2, etc) while other scales producemore twisted, unrealistic surfaces. Element 0 is the lowest octave.

• Lowest Octave Frequency: period of lowest noise octave. Smaller producessmoother surfaces, higher produces rougher surfaces.

Paging Terrain

This demo uses a paging mechanism to dynamically generate blocks of terrain as theplayer explores the world. The "DynamicTerrain" object contains all the mainfunctionality and the "Dynamic Painted Terrain Gen" script does all the real work. Ascreen shot of the typical settings are included below.

 

3. Package Contents

MarchingCubes.cs

The marching cubes script runs on any data that can be sampled for density values (i.e.values under 0 are inside the mesh surface, values over 0 are outside). Surfaces aregenerated as 3-dimensional arrays filled with many octaves of noise. If you can find away to represent what you want to build in a 3-D array then the cubes that march canmake it for you!

…. TBC ….