Skinned Metaball Builder Manual -Introduction-
"Skinned Metaball Builder" is a Unity Asset that provides a functionality of Making Mesh data via metaball with features:
- Works on editor and at runtime.
- No dependency on platforms.
- Created mesh can be saved as an asset.
- Skinned (optional) so that mesh can be animated.
- With "skeleton" objects for various use.
- Support simple linear-projection texture mapping
- Fully implemented with Unity C# script, letting you customize.
<Turn on "CC" for explanation.
- Drag and drop "Metaball/Prefabs/SkinnedSeed" into your scene.
- Choose "SkinnedSeed/SourceTree" in hierarchy.
- "Ctrl+Shift+C" or "Command+Shift+C" to create a new metaball node.
- Move it, modify its "base radius" as you like.
- Repeat 3-4 (Changing node selection to be the parent of new node).
The hierarchy under "SourceTree" is reflected into the "skeleton" generated later.
- "Ctrl+Shift+R" or "Command+Shift+R" to generate mesh.
- Press "run" button in editor,
select some node under "SkinnedSeed/BoneRoot",
and rotate it to confirm that your mesh transforms.
- "Metaball->SavePrefab" to save full prefab
or "Metaball->SaveMesh" to save mesh only.
Three samples within package.
Each implementation is quite simple and easy,
but introduces well about this asset.
"Dungeon" sample shows how to modify mesh at runtime.
You can walk and dig through metaball-modeled dungeon.
A,W,S,D to move
Space to "dig"
Mouse move to look around
"Animation" sample shows how to animate skinned mesh.
Two objects are contained:
-"Golem" : Unity animation
-"Tentacle" : Physics (joint)
Various objects :)
Knowing about the algorithm helps you to find good parameter values.
Creating a metaball surface
1. Calcurate and fill scalar field by metaballs information (center, radius and density).
2. Create mesh data from the scalar field via "marching cubes" algorithm( Marching cubes - Wikipedia, the free encyclopedia ).
- Numbers of grid cells and vertices are limited (1000000/300000 by default).
These are defined in MetaballBuilder.cs.
Search "_maxGridCellCount", "_maxVertexCount".
Be careful : building mesh with too large values may Freeze your system.
- Rebuilding mesh may take long time depending largely on the grid size.
Per-frame rebuild is not recommended (excluding cases that you require low-resolution metaball or you suppose your application to run on a monster PC).
- Only one material can be applied per mesh.
- Texture mapping is supported but simple linear-projection only.