POV-Ray : Newsgroups : povray.programming : Random and array : Re: Random and array Server Time
13 Jul 2024 10:27:09 EDT (-0400)
  Re: Random and array  
From: clipka
Date: 22 May 2009 13:55:00
Message: <web.4a16e6062809831692f9e9e10@news.povray.org>
I was a bit too quick with my answer; there's another flaw in your code, which
will result the t-shirt color to be random, but still the same for all people:

> //------------------------------------------
> #declare kolorek = str((Rand_Array_Item(lors,RS))
>
> #declare chopek = union{
> [...]
>
>    #local Index1 = 1;
> #local Index3 = 0;
> #while(Index1 <= 20)
>
>    #local Index2 = 0;
>    #while(Index2 <= 280)
>
>       object {chopek translate <Index3, Index1*0.5, Index2*0.5> pigment { color
> kolorek }
>         [...]

You pick the "kolorek" value before the loop. However, I guess you want to pick
the value at random for each element in the loop; in order to do this, the
structure of your code should be:

#declare chopek = union {
  ...
  #while (...)
    #declare kolorek = Rand_Array_Item(lors,RS);
    object { chopek ... pigment { color kolorek } }
    ...
  #end
}

That is, you need to explicitly pick a new color for every iteration of the
loop.


Post a reply to this message

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