|
|
Hello,
I'm in the process of creating a number of basic objects using the *declare*
statement. Ultimately, I'd like to have a large collection of objects from
which a subset would be randomly selected and placed on a flat surface,
with each of these scenes being rendered and saved. The objects should not
overlap. Suggestions on how this may be accomplished would be appreciated.
Currently, I'm only creating objects from the basic primitives with
different colours and textures and a known maximum size.
Thanks.
Post a reply to this message
|
|
|
|
netquest wrote:
>Hello,
>
>I'm in the process of creating a number of basic objects using the *declare*
Roughly speaking,
#declare Xcount = -5;
#while (Xcount < 5)
#declare Zcount = -5;
#while (Zcount < 5)
#if(rand(RObjects) > 0.5)
object { ArrayOfObjects[floor(10*rand(RObjects))] }
#end
#declare Zcount = Zcount + MaxSize;
#end
#declare Xcount = Xcount + MaxSize;
#end
Of course, over the area you want, and you could use #switch instead of an
array, but basically, iterate over the two axis in steps big enough to avoid
a collision, and choose randomly whether or not to place an object.
For a less grid-like look, you could iterate in steps of twice-maxsize and
place an object at xcount,zcount +/- maxsize, (or combine the two randoms -
randomly place an object or not, randomly placed near the current point).
You get the idea, I hope. Don't forget to seed() your randoms and initialize
your array and so on.
--Chris
Post a reply to this message
|
|
|
|
Chris Amshey wrote:
> object { ArrayOfObjects[floor(10*rand(RObjects))] }
*cough* Of course, that object { } should include a translate to somewhere
resembling <Xcount, SomeHeight, Zcount> *cough* ...
(and of -course- I never make mistakes like that with real code and end up
staring at a convoluted mess wondering what went wrong... ;))
--Chris
Post a reply to this message
|
|