https://github.com/takagi/marching-cubes.git
git clone 'https://github.com/takagi/marching-cubes.git'
(ql:quickload :marching-cubes)
A marching cubes algorithm implementation in Common Lisp based on Paul Bourke's (http://paulbourke.net/geometry/polygonise/)
MARCHING-CUBES density-function min-position max-position delta isolevel => triangles
Extracts a surface from density field represented with density-function
and returns triangles
which is a list of triangles. density-function
is a function that takes three arguments representing the position of a point and returns density as a scalar at the point. min-position
and max-position
are vec3
values and specify the minimun point and the maximun point of a grid to be processed. delta
is a scalar that specifies the size of a cell in a grid to be processed. isolevel
is a scalar that specifies the threshold of mesh construction.
MARCHING-CUBES-SMOOTH density-function normal-function min-position max-position delta isolevel => smooth-triangles
Same as marching-cubes
except that marching-cubes-smooth
returns a list of smooth triangles which have normal vectors at each vertex. normal-function
is a function that takes three arguments representing the position of a point and returns a normal vector at the point. Other arguments are same as marching-cubes
's.
See example/ directory.
Copyright (c) 2012 Masayuki Takagi (kamonama@gmail.com)
Licensed under the LLGPL License.