POV-Ray : Newsgroups : povray.newusers : Random Numbers : Re: Random Numbers Server Time
2 Nov 2024 17:17:55 EDT (-0400)
  Re: Random Numbers  
From: Warp
Date: 30 Oct 2003 19:25:23
Message: <3fa1abf3@news.povray.org>
Matthew Pace <mat### [at] lycoscom> wrote:
> Can someone please explain how to get POVRAY to produce random numbers?  
> I checked the Docs, and i was confused by them.  I have not heard of 
> output streams in POV, so if anyone can clarify, that would be wonderful.

  Have you tried what the docs suggested?

  Anyways, here's an example which should get you started:

camera { location <0,6,-6> look_at 0 angle 35 }
light_source { <100,200,-50>, 1 }

#declare Seed = seed(0); // Note *where* I initialize the seed

#declare Ind = 0;
#while(Ind < 200) // 200 spheres
  // rand(Seed) returns a value between 0 and 1
  #declare RandomLocation = <rand(Seed)*4-2, 0, rand(Seed)*4-2>;
  #declare RandomColor = <rand(Seed), rand(Seed), rand(Seed)>;

  sphere { RandomLocation, .05 pigment { rgb RandomColor } }

  #declare Ind = Ind+1;
#end

plane { y, -.05 pigment { checker rgb 1, rgb .5 } }


-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

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