|
|
The random-number generator of POV-Ray will always
yield the same row of numbers, no matter which
frame of animation your in. Just imagine you'd randomly
placed an object in a box, it would be jumping all
over the box for each new frame, something not very
desirable.
Also, what you're doing, is initializing the seed again
every time you require a new random number, and thus
get the first random number from those series.
You should rather use:
#declare Seed=seed(1);
and then "rand(Seed)" everywhere where you require a
random number.
In your case:
#declare Conifer_Cluster =
union
{
#declare numNeedles = 5 + rand(seed(12))*5;
#declare iter = 0;
#while(iter [ numNeedles)
#declare IterSeed=seed(iter);
object { Conifer_Needle rotate
[rand(IterSeed)*80,0,rand(IterSeed)*80] }
#declare iter = iter+1;
#end
rotate [-40,0,-40]
rotate [90,0,0]
}
Still, every new frame of an animation will use the
same random-numbers, you could only go about this
like this:
#declare IterSeed=seed(iter+clock*1000);
Look at the docs about rand / seed to find out more
about the pseudo-random-stream this function returns.
Regards, Tim
--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde
> I have this object that uses a whole bunch of random values, but it seems
> that every time I run the scene, it looks exactly the same. Here's the
> relevent code (since regular inequality signs won't work in web view here,
I
> am replacing them in this message with [ and ]):
>
> #declare Conifer_Cluster =
> union
> {
> #declare numNeedles = 5 + rand(seed(12))*5;
> #declare iter = 0;
> #while(iter [ numNeedles)
> object { Conifer_Needle rotate
> [rand(seed(iter))*80,0,rand(seed(iter))*80] }
> #declare iter = iter+1;
> #end
> rotate [-40,0,-40]
> rotate [90,0,0]
> }
>
> This is to generate a cluster of pine needles. The object referred to in
the
> code called "Conifer_Needle" is just a simple slender cylinder. Every time
> I run this, there are exactly 5 needles created and they are always in the
> same position. So I'm not getting some aspect of the random number
> generation in POV-Ray... What do I need to do to get different results
each
> time? The reason it needs to be different is that later on I am going to
> have another object that will refer to this object within a #while loop.
>
>
Post a reply to this message
|
|