POV-Ray : Newsgroups : povray.newusers : trouble using random numbers : trouble using random numbers Server Time
4 Sep 2024 18:16:57 EDT (-0400)
  trouble using random numbers  
From: Justin Smith
Date: 4 Oct 2002 04:00:14
Message: <web.3d9d49943158db03e07c96340@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.