|
|
/*
random.inc
This include file allows for a self-reseeding random
number. When you use the two macros, your scene starts with
a different random number each time. It works be creating
and using a file called "randseed.pov". the get_seed()
function includes randseed.pov and the update_seed()
function writes the new seed into randseed.pov. On the
windows function I can ust hit alt-G every time I want to
change the randomness. Enjoy!
Note: the first time you use the macros, the error
message will come up. THis is because randseed.pov does
not exist yet. This is ok. You should only see it once.
Further note: call get_seed() at the top of your .pov
file and call update_seed() at the very very end of your .pov
file.
Last note: tested on OFFICIAL povray 3.1 on windows
and miggy. Should be fine on Mac??
Pete
*/
// get seed from the seed file and seed rseed with it
#macro get_seed()
#if (file_exists("randseed.pov") = 1)
#include "randseed.pov"
#end
#ifndef (rseed)
#render "\nrseed not set - serious error. Faking it\n"
#declare rseed = seed(39631791); // any 8 digit number
#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: ", str(new_seed, 0, 0), "\"\n")
#fclose F1
#end
#end
/* actual end of this file */
Post a reply to this message
|
|