Re: [vox] Couple Questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox] Couple Questions
On Wed, Sep 05, 2001 at 03:16:23AM -0700, Tom wrote:
> Would you Post:
>
> 1) Seed / Inst for those Fractal Worlds
Well, as Henry said, I didn't actually use a seed. However, after the
meeting, at Baker's square, we discussed some ways to make 'ppmforge'
generated different views of a particular 'planet' (that is, sphere-mapped
fractal :) )
Running ppmforge with the "-h" (help) option shows the following
options are available:
usage: ppmforge
[-width|-xsize <x>] [-height|-ysize <y>] [-mesh <n>]
[-clouds] [-dimension <f>] [-power <f>] [-seed <n>]
[-hour <f>] [-inclination|-tilt <f>] [-ice <f>] [-glaciers <f>]
[-night] [-stars <n>] [-saturation <n>]
Let's assume we can live with the following defaults that ppmforge uses:
* default size (256 wide x 256 high)
* default 'mesh' (a value which affects the realism of the
generated image; the higher the mesh, the more RAM ppmforge uses) (256x256)
* default 'dimension' (the 'roughness' of the terrain) (2.4)
* default 'power law scale' value (affects 'elevation' of terrain) (1.2)
* default 'ice' value (how far glacier caps go towards the equator) (0.4)
* default 'glaciers' value (how high terrain needs to be to be icy) (0.75)
* default 'stars' value (10th of percent of pixels that are stars) (100)
and
* default 'saturation' value (how colorful the stars will appear) (125)
All we need to do to make a sequence of pictures of a particular planet
rotating is to feed the same seed (for the random number generator; using
the same seed each time causes the same landscape and stars) and
different values for 'hour' (12 = high noon, BTW)..
#!/bin/sh
for h in 00 01 02 03 04 05 06 07 08 09 10 11 \
12 13 14 15 16 17 18 19 20 21 22 23
do
ppmforge -seed 1234 -hour $h > planet-$h.ppm
done
This creates 24 PPM images, named "planet-00.ppm" through "planet-23.ppm"
which all look the same, except the lighting is different.
Note: the "\" at the end of the 'for' line causes the next line to
be a continuation. (It's as if there were no "\" and end-of-line).
Here are a few tweaks:
1. Make the seed a command-line option:
ppmforge -seed $1 -hour $h > planet-$h.ppm
So if you run the above shell script like so:
./draw-planets.sh 93468
ppmforge would use "93468" as the seed.
2. Add the seed to the filename (so you can run multiple times, and
keep each set of 24 images without overwriting them):
ppmforge -seed $1 -hour $h > planet-$1-$h.ppm
So in the above example, we'd have 24 images named "planet-93468-00.ppm"
throguh "planet-93468-23.ppm".
3. Make the program spit out JPEGs instead of large, uncompressed PPMs :)
ppmforge -seed $1 -hour $h | cjpeg > planet-$1-$h.jpg
(The output of "ppmforge"--its "stdout"--is not redirected into a file...
instead, it is 'piped' ("|") into the "cjpeg" program. "cjpeg", not
seeing any filename, decides to read from it "stdin", thus reading the
PPM data coming out of "ppmforge". It then writes a JPEG version of
that PPM data to its "stdout", which is THEN redirected (">") into
a new JPEG file)
WHEW!
I also mentioned that one could create a simple CGI program which
spat out a fresh "ppmforge"'d image using the current time. :)
------------------------
#!/bin/sh
echo "Content-type: image/gif"
echo
ppmforge -seed 12345 -hour `date +%H` | ppmquant 256 | ppmtogif
------------------------
When this CGI is accessed by a web browser, it first tells the browser
"I am a picture, in GIF format".
It then runs "ppmforge" with a particular seed (I picked "12345").
For the "-hour" value, we actually run the Unix "date" command and
ask it to display only the current hour ("+%H").
The PPM data spat out by "ppmforge" is then piped to "ppmquant" to make
sure it's at most 256 colors. The now-256-color PPM data is then spat
out to "ppmtogif", and GIF data is sent to "stdout" (the web browser).
Now, you can just "<img src="planet.cgi" width=256 height=256 alt="planet">"
in an HTML page to waste lots of CPU! :)
Reload an hour later and the lighting will change. :)
> 2) How-to get a font to take the Custom Color (from Gradient color bar)
See my next message :)
-bill!
PS - Henry, odd that ppmforge isn't available on all systems. Its man page
dates it from October 1991! (It's almost 10 years old! Happy bday!)
|