POV-Ray : Newsgroups : povray.programming : Random and array Server Time
21 Dec 2024 08:58:32 EST (-0500)
  Random and array (Message 1 to 7 of 7)  
From: Jimi aka James
Subject: Random and array
Date: 22 May 2009 10:20:01
Message: <web.4a16b372ce522aaafb1f3ffe0@news.povray.org>
Hi :-),
I need help, I am making a stadium and I want to do people on it, I made it,
everything was good but, all of them had the same t-shirt, so I wanted to use
randomize function (this is my code):


#include "colors.inc"
#include "textures.inc"
#include "arrays.inc"

#declare lors = array[5] {Black,White,Red,Green,Blue}
#declare RS = seed(1215);

// camera ---------------------------------
camera {location <0.0 , 20 ,-34>
        look_at  <0.0 , 0.0 , 0.0>}
// sun ------------------------------------
light_source{<150,2500,150> color White}

// sky -----------------------------------
sky_sphere {
    pigment {
        gradient <0,1,0>
        color_map { [0.00 rgb <0.6,0.7,1.0>]
                    [0.35 rgb <0.0,0.1,0.8>]
                    [0.65 rgb <0.0,0.1,0.8>]
                    [1.00 rgb <0.6,0.7,1.0>]
                  }
                scale 2
            } // end of pigment
           } //end of skysphere -----------
// ground ---------------------------------
plane{ <0,0.0001,0>, 0
       texture{
          pigment {color White}
               } // end of texture
     } // end of plane
//------------------------------------------
#declare kolorek = str((Rand_Array_Item(lors,RS))

#declare chopek = union{
difference {
  sphere { <0, 0, 0>, 0.2  scale <0,4,0>}
  box {<0,0,0>, <1,0,1> }
          pigment {color Red}
          }

  sphere { <0, 0.7, 0>, 0.1  pigment {color Yellow} scale <0,1.3,0>}
                   }

   #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 }
        #if (Index2= 20 | Index2=65 | Index2 = 110 | Index2 = 155 | Index2 = 200
| Index2 = 245)
          #local Index2 = Index2 + 5;


        #else
      #local Index2 = Index2 + 1;
      #end
   #end

   #local Index1 = Index1 + 1;
   #local Index3 = Index3 +1;
#end



Any ideas, solutions to my problem? I have error  in the line:
--object {chopek translate <Index3, Index1*0.5, Index2*0.5> pigment { color
kolorek }--
I tried declared "kolorek" with object and brackets and without it but it still
does'nt work. Please help friends.


Post a reply to this message

From: clipka
Subject: Re: Random and array
Date: 22 May 2009 13:45:00
Message: <web.4a16e4772809831692f9e9e10@news.povray.org>
"Jimi aka James" <pat### [at] gmailcom> wrote:
>
> #declare lors = array[5] {Black,White,Red,Green,Blue}

Here, you declare "lors" as an array of colors...

> #declare kolorek = str((Rand_Array_Item(lors,RS))

.... here you seem to read out the array, and convert it to a string (why?? and
I'm rather surprised that you don't get an error here already)...

>       object {chopek translate <Index3, Index1*0.5, Index2*0.5> pigment { color
> kolorek }

.... while here again you want to have it interpreted as a color.

I guess it should work fine if you remove the "str()" from the declaration of
"kolorek"; actually, I think it should read:

#declare kolorek = Rand_Array_Item(lors,RS);


Post a reply to this message

From: clipka
Subject: Re: Random and array
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

From: Jimi aka James
Subject: Re: Random and array
Date: 23 May 2009 06:15:00
Message: <web.4a17cbe128098316fb19e9110@news.povray.org>
Thx a lot guys... I was thinking a lot about this, and with your ideas I find
solution :)  This is the working code:

#local Index1 = 1;
#local Index3 = 0;
#declare chopek = union{
difference {
  sphere { <0, 0, 0>, 0.2  scale <0,4,0>}
  box {<0,0,0>, <1,0,1> }
            }

                       } // end of union

#declare glowa = union {
              sphere { <0, 0.7, 0>, 0.1 scale <0,1.3,0> pigment {color Yellow}}}
#while(Index1 <= 20)

   #local Index2 = 0;
   #while(Index2 <= 280)
      #declare kolorek = (Rand_Array_Item(lors,RS));
      object {chopek translate <Index3, Index1*0.5, Index2*0.5> pigment { color
kolorek }}
      object {glowa translate <Index3, Index1*0.5, Index2*0.5>}
        #if (Index2= 20 | Index2=65 | Index2 = 110 | Index2 = 155 | Index2 = 200
| Index2 = 245)
          #local Index2 = Index2 + 5;


        #else
      #local Index2 = Index2 + 1;
      #end
   #end

   #local Index1 = Index1 + 1;
   #local Index3 = Index3 +1;
#end

The declare of my chopek (man) and glowa (head) have to be declared before loop.
Str wasn't thing what I needed as you said.

And now as a dessert my work, people on the stadium on the bottom seats :-)

http://patryknowak.pl/stadion3.jpg

Once again thx for help :-)


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Random and array
Date: 23 May 2009 16:50:37
Message: <4a18619d@news.povray.org>
Jimi aka James wrote:

> And now as a dessert my work, people on the stadium on the bottom seats :-)

Looks very nice. However, you should add a small random element to
the position as well, it's a bit too regular for people. Also, making
the glowas a tiny bit larger and using color "Tan" instead of
"Yellow" could help, too.

Also note that your statements "scale <0,N,0>" actually mean
"scale <1,N,1>". Although POV can handle this for being able to
imply use "scale N*y", writing the 0 explicitely is misleading.


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Random and array
Date: 24 May 2009 01:12:58
Message: <4a18d759@news.povray.org>
Jimi aka James wrote:
> Hi :-),
> I need help, I am making a stadium and I want to do people on it, I made
> it, everything was good but, all of them had the same t-shirt, so I wanted
> to use randomize function (this is my code):

This is the wrong group for this question.  This group is for discussion of
the POV-Ray source code, not general questions of using POV-Ray.  Questions
about using POV-Ray should be asked/made in either povray.general or
povray.newusers.

-- 
Nicolás
(again, posting before Thorsten has to :D)


Post a reply to this message

From: Jimi aka James
Subject: Re: Random and array
Date: 8 Jun 2009 11:40:00
Message: <web.4a2d3000280983163f1e88cf0@news.povray.org>
Nicolas Alvarez <nic### [at] gmailcom> wrote:
> Jimi aka James wrote:
> > Hi :-),
> > I need help, I am making a stadium and I want to do people on it, I made
> > it, everything was good but, all of them had the same t-shirt, so I wanted
> > to use randomize function (this is my code):
>
> This is the wrong group for this question.  This group is for discussion of
> the POV-Ray source code, not general questions of using POV-Ray.  Questions
> about using POV-Ray should be asked/made in either povray.general or
> povray.newusers.
>
> --
> Nicolás
> (again, posting before Thorsten has to :D)

I know it's wrong group, but I want to show final effect of my work.

Here is the link to youtube http://www.youtube.com/watch?v=K6puZu9MxY4 .

I'm beginner in using POv-ray so don't laugh :P


Post a reply to this message

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