Having suggested, in a previous article (PC Update, November 94), that those, who weren't prepared to directly program ray-tracings of the image pairs needed for stereo viewing with a mirror, might consider shareware ray-tracers, I felt I should at least try them myself. I had read the documentation of POV-Ray and Vivid and was much impressed by their capabilities but had not actually used them. Well, now I have, and am extremely pleased by the results. POV-Ray (Persistence of Vision) is distributed as freeware on international BBSs in the interests of ray-tracing - everybody chips in with suggestions, techniques, pictures, etc. The program is on our BBS and will rapidly get you started as there are about 100 ASCII picture files which your computer can use to generate pictures. With the files and the pictures to compare, you will soon be wanting to improve them or use them as the basis for new concoctions. Vivid is more a one-man effort but is no amateur program. It produces very creditable pictures, its documentation offers some different insights into the 3-D geometry of ray-tracing and it provides useful graphic file conversions, including a picture-splicing tool. It is a relaxed sort of shareware - the author will accept whatever you think is a fair thing, or beer. My main interest being to produce stereo pairs (with the left eye view mirror-flipped onto the left half of the screen), the two programs offered different solutions. Vivid does not provide horizontal inversion so it was necessary to mirror-flip the scenery when drawing the left eye view. First, all items were placed on the right side of the screen and the right half plotted from the viewpoint of the right eye, 3 cm to the right of screen centre and out at viewing distance (40 cm). A second copy of the script file negated all x coordinates of objects, textures, backgrounds and lights, and was plotted from the same viewpoint, 3 cm to the right. Using Vivid's "paste" tool the two pictures were spliced. When viewed with a mirror edge-on to the centreline, the reflection of the left half is on the right half and correctly plotted for a viewpoint 3 cm to the left, which is where the left eye happens to be. Voila! Great stereo! POV-Ray allows for a horizontal flip by using a negative x value in a command called "right." So, as before, with objects on the right side, the right eye view was plotted. Now, the object x coordinates were not changed but the "right" x value was negated. It was also necessary to move the viewpoint to the left to allow the left eye view to be plotted. Unfortunately, POV-Ray does not supply a splicing tool so it was necessary to use Vivid's "paste." POV-Ray produces.TGA files and Vivid has its own .IMG format, but provides conversion tools to and from .TGA and .GIF. The procedure is--convert the two half-screen .TGA files to .IMG, then use "paste" to make the full .IMG, then convert to .GIF or .TGA depending on the viewer you intend to use. Now having ray-traced stereo pictures, the Oliver Twist in us appears and - what do we want? - we want movies! Fortunately, the great world of shareware supplies DTA (Dave's .TGA Animator) which will make a .FLI or .FLC animation from a series of .TGA, .GIF, .IMG or .PCX files. DFV112.ZIP [34 KB] can be downloaded from this link. POV-Ray provides one variable called "clock" which can be fed in from the command line to provide limited animation. You could make separate copies of the script file, changing values to move things around in each frame, which would be rather tedious. There is a solution by using an "include" file which POV-Ray will read to accept any number of variables for use in the current plot. You need a batch file to run a sequence of frames (while you get some sleep) and this needs to write new variables into the "include" file before calling POVRAY.EXE to plot each frame. A master batch file is needed to call the first batch file repeatedly with the a new set of variables as command line parameters to rewrite the "include" file. The one .POV script file produces both views when fed with appropriate variables, the batch file does the file conversions and splicing and the paired image is saved; the intermediate files are overwritten to save disk space. It all sounds pretty confusing but, when sorted out, it works. A two-stroke engine seemed an appropriate subject since POV-Ray allows for CSG or Constructive Solid Geometry. Start with the so-called "primitive" shapes such as sphere, cylinder, cone, plane, box, etc., which may be combined as unions, intersections or differences. Working machinery contains mostly these primitive shapes as seen in the adjacent picture. Get out your piece of mirror. An 18-frame animation, 2STROKE.FLC [770 KB] is available for download (also in compressed form as 2STROKE.ZIP [265 KB]), which illustrates the actions of inlet valve, crankcase compression, transfer port, compression, combustion, expansion and exhaust port. Also available is WAAPLAY.EXE [165 KB] for viewing the animation under Windows.
Reprinted from the April 1995 issue of PC Update, the magazine of Melbourne PC User Group, Australia |