Depth-buffer demonstration applet

Depth-buffer demonstration applet

What is a depth-buffer

A depth-buffer, also called a Z-buffer, is used to decide, which elements of a rendered scene are visible and which not. When a 3d object is rendered, the depth value of each pixel rendered is stored at the corresponding position in the depth-buffer. When another 3d object is rendered, its pixels are rendered only if their depth is lower than the value at the corresponding position in the depth-buffer.
How the applet works

The applet renders a scene with one plane, three cubes and one cone and displays the values in the depth-buffer in shades of gray. The deeper the value is the darker the pixel. The user can rotate the scene using the up, down, left right arrow keys and zoom with the page up, page down keys. To actually see the function of the depth-buffer, the user can turn it on and off using the A key.
The structure of the applet

The depth class takes care of input and display and the creation of the primitive objects.
The depthbuffer class contains the actual depth-buffer and two pixel buffers that contain the images that are drawn by the applet. It also contains the functionality of the depth-buffer. It takes also care of the rendering of the primitive objects.
The point2d, point3d, line2d and polygon3d classes represent geometrical structures with the help of which, the primitive objects are constructed and projected into 2d space.
The cube3d, plane3d, cone3d classes represent the primitive objects.


Applet Koch Snow Author: Jozef Kopaničák, Ivan Kolesár

Algorithm source: