The HFVal Script
There has been a discussion about placing objects along the line of a heightfield on the IRTC list in the last few days, and I needed this several times too, so here it is!
Note: You need perl to run this utility. Perl is one great scripting language and is available for about a zillion platforms, including Win95 and NT. UNIX folks won't have to worry, they'll already have it. Windows people can get it from http://www.activestate.com
More Note: The program names I use here may change for other platforms, so is hlx the UNIX version of hflab. I think the DOS executable has a different name. That's why the demo.sh doesn't have a companion named demo.bat. Sorry for that.
The main script hfval.pl will read uncompressed 8bit grayscale targa and 24bit targa. The format of the 24bit targa files works with what John Beale's hflab outputs.
I created the above images with the following handful of scripts:
- hftest.scr:
-
This is a hflab script that generates the testbed heightfield.
- gencoords.pl:
-
Nothing complicated here, just a script to generate a test dataset. In general, it's nothing more than a nested for-loop, that generates a 32 x 32 grid of coordinates in the range 0..<1.
Run it with
perl gencoords.pl >2dcoords.lst - hfval.pl:
-
This is the guy that does the job. You pass a heightfield as parameter, and feed the coordinate pairs into STDIN. It'll output the resulting triplets to STDOUT.
Use it like this:
perl hfval.pl hf.tga 2dcoords.lst >3dcoords.lst - genspheres.pl:
-
I needed something to create POV objects from the raw data, and this is exactly what this script does. Again, looking at the code will reveal, here happens nothing complicated.
Here's how to call it:
perl gensphere.pl 3dcoords.lst - hftest.pov:
-
A sample POV-scene, which more or less creates the above images.
- demo.sh:
-
A sample run. Non-UNIX folks have to do it by hand, sorry. You can also call them all in one nice and handy pipe like this:
perl gencoords.pl | perl hfval.pl hf.tga | gensphere.pl >spheres.incTest the result with
povray +ihftest.pov
Here's everything packed into a zipfile (5K), or as a tar-archive (3K).
Please send suggestions, corrections,
or just some blurb to mike AT lamertz DOT net

