Rocktools
Rocktools is a collection of command-line tools for the creation and manipulation of open or closed triangular meshes in 3D space. It is especially adept at detailing triangular meshes according to three-dimensional random walks. It is written in ANSI C and only requires libpng and the standard C libraries to compile.
Thanks go to Steven Pigeon for his program POVRockGen 1.0, which gave me the idea for creating rocktools. There is also a program called MacRock that uses the above code.
Files
Rocktools is now being hosted at https://github.com/markstock/rocktools. On a Unix system, you should be able to run the following commands:
git clone https://github.com/markstock/rocktools.git
cd rocktools
make
Most tools take the -h option and will echo usage and a list of available options.
Features
Rocktools includes the following programs
- rockconvert can convert obj, raw, msh, or tin files into raw, rad, pov, obj, tin, or rib files; surface normals and texture coordinates are not always preserved
- rockcreate creates rock-like triangle meshes from the convex hull of a distribution of points, it is ideal for creating starter meshes; see the rockcreate options page; program is now self-contained and includes new options for point initialization
- rockdetail recursively roughens a triangular mesh by splitting each triangle into three or four new triangles; see the rockdetail options page; new spline-fitting and perturb-all-nodes schemes result in much higher-quality meshes, see images below
- rockdice recursively split a (large) trimesh file into smaller files using rocksplit and convert them all to Radiance triangle mesh files (Perl script)
- rockerode iteratively erode a triangular mesh file, moving mass from hills and elevated areas, and creating valleys and watersheds
- rockinfo dumps node and triangle counts, and min/max bounds of tri mesh
- rockmarker is designed to write out simple markers (spheres or rectangles) aligned to and upon a triangle mesh
- rockpng creates a trimesh from a greyscale PNG heightfield
- rocksmooth removes sharp corners via a Laplacian smoothing filter and calculates surface normals; see the rocksmooth options page
- rocksplit splits a trimesh into two meshes along an axial plane
- rocktrim selectively removes triangles from a triangle mesh file based on bounds in global x, y, and z directions
- rockxray will create a PGM or PNG "x-ray" or density image of a mesh
Images
An 8-level detailing of an icosahedron illustrating the
distance-dependent detaling option; the command was
rockdetail icosahedron0.obj -d 8 -dt .1 1 0 0 -oobj > partial8a.obj
A 7-level detailing of a hexagon using the
edge-clamping feature; the command was rockdetail hex0.obj -seed 12
-ce -d 7 -n 0.2 -b 0 -oobj > hex7b.obj
A 7-level detailing of a simple rock
Here's a view of the results of the rockerode tool. The erosion algorithm still needs work.
This image is a preview of the threshholding feature in rockdetail. It shows selective triangle splitting based on distance from an arbitrary viewpoint.
A MPEG animation made by varying the rockdetail parameters (1.6 MB), thanks to Jeff Balcerski
Output of rockxray with the "-s" (surface) option
Output of rockxray with the "-v" (volume) option
Future plans
Future versions of Rocktools may include the following:
- More realistic erosion behavior (lakes, waterfalls, landslides)
- Reading multiple input files, and reading from stdin
- More tools and input/output formats
- Volume-conserving smoothing
- Shattering a closed mesh into properly-fitting pieces
Please e-mail me if you'd like to see some particular feature in Rocktools, or if you use it to make something creative.
References
Rocktools has been used in the following research:
C.L. Lin and J.D. Miller, 3D characterization and analysis of particle shape using X-ray microtomography (XMT), Powder Technology 154 (1) 61-69, (2005) [link]