JZB - a 3D viewer for indexed face lists

Steffen Weber, Eric Harlow, 1999

Credits: In JZB have implemented the zbuffer engine of E.Harlow, which in turn seems to be based on the code in Tonny Espeset's book: Java Kick-Ass Programming.

I wrote this Java program mainly to be able to display some models with intersecting polygons correctly. In my other programs I usually use vector graphics, which makes displaying intersections correctly a little tricky. Actually, I use vector graphics mainly to be able to write scalable PostScript output. With JZB I offer another possibility to obtain correct PostScript graphics. JZB can write MATHEMATICA notebooks for the displayed model. You may then let MATHEMATICA do the job of producing the correct vector graphics PostScript output. JZB also exports pixel graphics in GIF, JPG or PostScript format.

I wrote JZB for my own needs so it uses one of my own input formats, which I call indexed face list files (*.ifl). Indexed face lists are also used in VRML files or in the OFF file format.

Sometimes I also use the Java3D VRML viewer from the Java3D-VRML working group, but that one presently lacks essential interactive features, which is why I decided to write JZB.

download JZB (requires JDK1.2)

advantages of JZB over the Java3D-VRML viewer:

disadvantages of JZB compared to the Java3D-VRML viewer:

The list of advantages reflects only my point of view, since I use JZB only for displaying purely polygon list -based models of quasicrystal occupation domains, where I don't want Gouraud shading.

how to use JZB:

mouse events

  • left mouse button drag - rotate about x- and y-axes
  • right mouse button drag - rotate about z-axis
  • left mouse button triple click - toggle between zbuffer mode and wire frame painters mode

  • right mouse button triple click - toggle between zbuffer mode and solid painters mode

in "edit color" mode

  • right mouse button click - assign new color to clicked polygon

  • right mouse button double click - reassigns old color to clicked polygon (like an undo option)

keyboard events

  • hit space bar to make control panel appear

how to edit polygon colors:

On the control panel you can envoke the color chooser by clicking the third color button or from the menu. The selected color will then be used as the new fill color for polygons. Then activate the "edit color" mode. The display goes to solid painters mode with border lines drawn. Furthermore the center of each polygon is marked with a black dot. Click near that dot of a polygon in order to assign the new color to it. (right mouse button) If it does not fill then rotate the model a bit to make that polygon come to lie more parallel to the screen and try again. If polygons are too small you should enlarge the display area for enlarging the model. If you accidently fill the wrong polygon you can undo the fill by double clicking at that same polygon (right mouse button). It will then change to the original color. When you are done with editing don't forget to switch the "edit color" mode off again!

 

The Indexed Face List format (*.ifl)

Basically the format is like this :

vertices
.....
faces
....
end

This can be repeated, if you want to merge several models into one. The advantage over similar file formats lies in the way the face lists can be specified. Basically *.ifl lets you skip specifying the numbers of vertices per polygon if you have only triangles for example. Also the RGB color you only need to specify once for a group of polygons. This aims at reducing the file size of the model, since I usually deal with models with several thousand polygons.

Several options for specifying the number of vertices per polygon and the polygon color are possible. The colors are specified as RGB integer values.

 

1) detailed - specifies color and vertex number for each individual polygon 2) short - common colors and vertex number for all polygons 3) groups - common vertex number and groups of polygons of different colors
vertices
-0.1935 0.5377 0.6286
0.1439 1.3159 0.5804
-0.3882 1.9496 0.3879
-0.1935 0.5377 0.6286
-0.9796 0.4835 0.9464
-1.0529 0.1486 1.7238
-0.1935 0.5377 0.6286
0.4275 0.7173 1.1798
0.7650 1.4955 1.1315
-0.1935 0.5377 0.6286
.......
-0.7257 1.1714 0.4362

faces
3 0 1 2 255 0 0
4 1 3 4 5 0 255 0
3 6 7 8 255 0 51
...
3 9 10 11 255 0 0
3 12 13 14 125 0 133
5 15 16 17 18 19 55 67 103
end
repeat if necessary (without leaving an empty line)
vertices
-0.1935 0.5377 0.6286
0.1439 1.3159 0.5804
-0.3882 1.9496 0.3879
-0.1935 0.5377 0.6286
-0.9796 0.4835 0.9464
-1.0529 0.1486 1.7238
-0.1935 0.5377 0.6286
0.4275 0.7173 1.1798
0.7650 1.4955 1.1315
-0.1935 0.5377 0.6286
.......
-0.7257 1.1714 0.4362

faces nvertex 3 color 255 0 0
0 1 2
3 4 5
6 7 8
...
9 10 11
12 13 14
15 16 17

end
repeat if necessary (without leaving an empty line)
vertices
-0.1935 0.5377 0.6286
0.1439 1.3159 0.5804
-0.3882 1.9496 0.3879
-0.1935 0.5377 0.6286
-0.9796 0.4835 0.9464
-1.0529 0.1486 1.7238
-0.1935 0.5377 0.6286
0.4275 0.7173 1.1798
0.7650 1.4955 1.1315
-0.1935 0.5377 0.6286
.......
-0.7257 1.1714 0.4362

faces nvertex 3
0 1 2
color 255 0 0
3 4 5
6 7 8
...
9 10 11
12 13 14
color 135 0 125
15 16 17

end
repeat if necessary (without leaving an empty line)

 

screen shot:

Control panel and display with sample model in painters mode. The black and the white color buttons in the control panel are for the background color. The color of the third button can be specified with a color chooser. This color will be used as a new color for selected polygons when in "edit color" mode.

home