|
|
The cafeteria at work has begun to put some things on the
menu. For example: one day they had a pizza burger. The following
day they had a burger pizza. They started to do weird combinations.
As a gag, I wrote a pov script to generate random menu ideas. This
will be two files, "random.inc" and the main file" "leersunch.pov".
To use, run (render) leersunch.pov. This will create a file
called "menu.txt". If the menu.txt file already exists, it will be
appended to. Every render of leersunch.pov will add 20 random
dishes to the file. It can generate some odd combinations.
The code was thrown together real quick so there could
be bugs that I havn't found yet.
Enjoy
---- random.inc ----
/*
a system for self-reseeding randomness in povray. This enables a povray
file have a different random number seed each time it is run.
To use, simply include this file, then call "get_seed()" once. Then use
rseed as your seed troughout your render. The last atatement in your .pov
file should be a call to "update_seed()".
The random seed will be stored in "randseed.pov"
*/
#macro get_seed()
#if (file_exists("randseed.pov") = 1)
#include "randseed.pov"
// what if the file was bad or incomplete?
#ifndef (rseed) // was this defined?
// no. It was not. Fake it and hope better for next time around
#render "bad randseed.pov file ... making a new one\n")
#declare rseed = seed(83963179);
#end
#else
// The file was not found. Fake it and hope better for next time around
#render "no randseed.pov file found ... making a new one\n")
#declare rseed = seed(74747285);
#end
#ifndef (rseed)
#render "\nWTF! rseed STILL not defined! That's impossible!!\n"
#render "\g YOU HAVE A PROBLEM!!!!!\n"
#end
#end
// update the random seed now that we are done with it.
#macro update_seed()
#ifdef (rseed)
#local new_seed = 99999999 * rand(rseed);
#local new_seed = int(new_seed);
#fopen F1 "randseed.pov" write
#write (F1, "#declare rseed = seed(", str(new_seed, 0, 0), ");\n")
#write (F1, "#render \"Seed used is: seed(", str(new_seed, 0, 0), ")
\"\n")
#write (F1, "#render \"\"\n")
#fclose F1
#end
#end
/* actual end of this_file */
---- leersunch.pov ----
#include "random.inc"
get_seed()
#declare ntsc = false;
#declare last_word = "nothing"
#declare num_locations = 9;
#declare locations = array[num_locations] {
"Italian",
"Boston",
"Chicago style",
"Mexican",
"San Francisco",
"New England",
"French",
"Carolina",
"Texas"
}
#declare num_pre_styles = 23;
#declare pre_styles = array[num_pre_styles] {
"Cajun",
"zesty",
"barbecued",
"pulled",
"rubbed",
"jerked",
"marinated",
"skewered",
"boiled",
"grilled",
"fricasseed",
"blackened",
"deluxe",
"old fashioned",
"continental",
"vegetable",
"refried",
"glazed",
"Buffalo",
"caramelized",
"baked",
"pan fried",
"beer battered"
}
#declare num_post_styles = 6;
#declare post_styles = array[num_post_styles] {
"au gratin",
"du jour",
"fondue",
"surprise",
"Santa Fe",
"marinara"
}
#declare num_what_it_is = 13;
#declare what_it_is = array[num_what_it_is] {
"burger",
"chicken",
"pizza",
"salad",
"meatloaf",
"taco",
"gyro",
"omelet",
"spaghetti",
"ziti",
"steak",
"lasagna",
"fish"
}
#declare num_containers = 15;
#declare containers = array[num_containers] {
"wedge",
"sandwich",
"casserole",
"loaf",
"roast",
"wrap",
"omelet",
"pot pie",
"parmagian",
"medley",
"gumbo",
"soup",
"lo mein",
"burrito",
"prima vera"
}
#declare num_side_dish = 19;
#declare side_dish = array[num_side_dish] {
"a side of glazed beets",
"french fries",
"curly fries",
"corn bread",
"mint jelly",
"brussels sprouts",
"vegetable medley",
"onion rings",
"waffle fries",
"biscuit",
"apple sauce",
"cranberry sauce",
"rice pilaf",
"refried beans",
"feta cheese",
"egg roll",
"wonton soup",
"peas and carrots",
"zucchini bread"
}
#macro rnd(n)
#local rnd_result = int((n * rand(rseed)));
rnd_result
#end
#macro print_word(this_word, words)
#write (menufile, concat(words[this_word], " "))
#end
#macro gen_and_print_word(num_words, words)
#local yy = rnd(num_words);
#if (0 = strcmp(words[yy], last_word)) // check to prevent repeats
#local loop_limit = 14;
#while (loop_limit > 0)
#local yy = rnd(num_words); // pick another
#if (0 = strcmp(words[yy], last_word)) // is it different from the last
word?
#local loop_limit = loop_limit - 1; // no, try again
#else
#local loop_limit = 0; // yes, can stop looping now
#end
#end
#end
print_word(yy, words)
#declare last_word = words[yy]
#end
#macro make_lunch()
#local dummy = rand(rseed);
#local dummy = rand(rseed);
#if (rnd(3) > 1)
gen_and_print_word(num_locations, locations)
#end
gen_and_print_word(num_pre_styles, pre_styles)
gen_and_print_word(num_what_it_is, what_it_is)
#if (rnd(3) = 0)
gen_and_print_word(num_what_it_is, what_it_is) // pizza burger, burger
pizza
#end
#if (rnd(2) < 1)
#if (rnd(2) = 0)
gen_and_print_word(num_post_styles, post_styles)
#end
#if (rnd(3) = 0)
gen_and_print_word(num_containers, containers)
#end
#else
#if (rnd(3) = 0)
gen_and_print_word(num_containers, containers)
#end
#if (rnd(2) = 0)
gen_and_print_word(num_post_styles, post_styles)
#end
#end
#if (rnd(4) > 0) // add a side dish
#write (menufile, "with ")
gen_and_print_word(num_side_dish, side_dish)
#end
#write (menufile, " \n")
#end
#fopen menufile "menu.txt" append
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
make_lunch()
#fclose menufile
update_seed()
#if (file_exists("randloop.pov") = 1)
#include "randloop.pov"
#else
camera {
location 0
direction <0, 0, 1.1>
#if (ntsc = true)
right <(640 / 400) * (10/11), 0, 0>
#else
right <(640 / 480), 0, 0>
#end
up <0, 1, 0>
translate <0, 0, -8>
}
sphere {
0, 1
pigment { color rgb 1 }
finish { ambient 1 diffuse 0 }
}
#end
/* actual end of this file */
Post a reply to this message
|
|