Morph Cube



For one of my university courses on computer graphics I studied B-splines surfaces and decided to do something fun with it. As I still had some Java libraries hanging around, I thought it would be a nice idea to make some sort of software rendering Java demo which I could put on the web.


The demo is basically a cube which consists of B-spline surfaces that are interpolated using Cox/De Boor knot-insertion and sub-divisions algorithms. Using these B-spline surfaces the cube can smoothly morph into all sorts of shapes and have funky animation effects on it as well.


The Java platforms available at the time, J2SE 1.3 and 1.4, had no real support for 3D rendering. As a result, the whole applet is hand-written and uses no hardware acceleration (its all pure software!). In order to get the polygon rasterizer, B-spline interpolations and shading algorithms fast enough, the entire engine is implemented using fixed-point integer math. In general this yields satisfactory results but sometimes the Z-buffer and colour interpolations across polygon surfaces suffer from lack of numeric resolution and create artefacts. This is especially visible when being close to the polygon surface.


The shading model includes both diffuse and specular reflections and is not restricted to just a single light-source (although each additional light-source inflicts a significant computational penalty). Currently only flat-shading and Gouraud shading are implemented but I had a half-finished version with Phong shading lying around somewhere as well (but lost it, doh!). Have fun tweaking with the rendering parameters.


Screenshots









Java demo

Java demo (with some more info)


Downloads

morph_cube_sources.zip (175 KB)


Download some code samples.