POV-Ray : Newsgroups : povray.general : Macros and arrays : Re: Macros and arrays Server Time
7 Aug 2024 17:23:18 EDT (-0400)
  Re: Macros and arrays  
From: Gail Shaw
Date: 13 Aug 2001 10:43:00
Message: <3b77e774@news.povray.org>
"ingo" <ing### [at] homenl> wrote in message
news:Xns### [at] povrayorg...
> in news:3b77cd84@news.povray.org Gail Shaw wrote:
>
> > // very pseudo-code
> >
> > #declare ObjectsArray=array[4] {Object1,Object2,Object3,Object4}
> > #declare ProbArray = array[4] {0.5,0.2,0.2,0.1}
> >
> > Pile(ObjectsArray,ProbArray)
> >
> > In the above case 50% of the pile will be object1, 20% object2 etc
> >
> >
>
> You'll have to do it in a few steps:
>

I've got the probability part. The way I've done it (which is probably not
the best)
is to create a second probability array. Using the above example the second
array would read {0.5,0.7,0.9,0.1}

I generate a random number between 0 and 1 then read along the array
checking
to see if the random number is smaller than the array value. If it is I use
the
array index as an index into the object array and stop checking, otherwise I
increment the
array index.

The problem I have is if one of the objects is created using a macro then
the macro is evaluated
when the object is assigned to the ObjectsArray and I'd like to find a way
to only evaluate the
macro when the object is actually created in the scene.

Gail
--
*************************************************************************
* gsh### [at] monotixcoza                *   Step into the abyss,           *
* http://www.rucus.ru.ac.za/~gail/   *   and let go.          Babylon 5 *
*************************************************************************
* The difficult we do immediately, the impossible takes a little longer *
*************************************************************************


Post a reply to this message

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