by carsten whimster
this cs679 (splines and their uses in computer graphics)
project implements Forsey and Bartel's paper Hierarchical B-Spline
Refinement [1]. it is missing a couple of minor features, such as
trimming curves inside the refined patches, and using greville points to
manipulate the surface, but the majority of the rest is implemented. i
had a lot of fun implementing it, so i might keep working on it after i
finish the course. it should only take a day or two of focused work to
implement the above two features.
the initial default patch size is 17x17 knots, ie. 13x13 control
points, and is a cubic b-spline. actually, the surface in this project is
rendered with opengl nurbs. i would like to switch to rendering my own,
but didn't have the time for this project.
anywhere there are 2 control points on either side of the selected
control point, the surface can be "refined", ie. a smaller but more
detailed patch can be overlaid on top of the base patch, or on top of
another overlay. this refined patch will have 7x7 control points, which
will cause the surface to coincide with the one it is lying on top of.
the middle vertex can be selected and moved about, which gives a finer
level of resolution than the base layer, due to the control points lying
twice as close to each other, approximately.
the refinement algorithm is called the oslo algorithm,
and can be found in [2]. basically, it calculates a weighted average
of the surrounding control points on the layer below. i used 7x7 new
control points, but by using a knot vector with quadrupled end knots,
it should be possible to use a 5x5 control point array instead. these
control points would have to be calculated from evaluating the surface,
as opposed to averaging the existing control points, however, to get
down to the surface and attaching there.
although i could have used various schemes to keep memory use to a
minimum, i preferred going for interactive speed, which means keeping as
much as possible in memory, and recalculating as little as possible. for
this reason each overlay has a complete set of control points stored, as
well as the offsets required to recalculate in case the parent surface is
changed. this way while the control points for a single layer are
modified, little calculation is done. when a parent is modified, the
changes recurse down the tree to the children, but this is unavoidable.
memory being as cheap as it is, and given that any computer can be brought
to its knees by merely upping the resolution, this seemed a sane approach.
here are two images of a session in progress in fill mode, and in
wireframe mode, so that the layers of refinement can be seen. one middle
layer is currently selected in the second image.
here is a face i made in about 2 minutes. with higher resolution,
and a couple of minor feature additions, it should be possible to make
quite realistic faces, but it would be time-consuming, and i would need to
measure someone's face. yes, it never got measured last time :)
finally, here is a link to an avi of a session in progress. note
that the currently selected patch is red, and the control points can
be seen for this patch. the blue ones are not selected, and the green
ones are selected. one can move selected vertices around. the unselected
areas are skin coloured. i have also included an animated gif, although
it tends to run slower than it is supposed to.
smooth.avi
smooth.gif
[1] Hierarchical B-Spline Refinement, Forsey, Bartels,
Computer Graphics, Volume 22, Number 4, August 1988
[2] An Introduction to Splines for Use in Computer Graphics
& Geometric Modeling,
Bartels, Beatty, Barsky; Morgan Kaufmann