|
![](/i/fill.gif) |
"ChaoZ" <nomail@nomail> wrote in message
news:web.4433e3e993410dd093a9a8530@news.povray.org...
> Hello again,
>
> I'm trying to create a scene a whole bunch of spheres on a plane in a
> tight,
> but somewhat random formation (the spheres, with radius of 1, cannot
> intersect each other). Each sphere is textured and also needs to be
> rotated
> to a random position around the y axis. (perhaps even within a specific
> range, i.e. between -30 to +30 degrees).
>
> Since I'm still somewhat new, I don't really know how to automate this
> process. I know I can define the sphere as a function and plug in values
> for each one, but is there a way to automate this?
>
> Thanks.
>
Hi Chaoz,
I had the same problem to solve about a year ago and came up with a couple
of macros. I've posted a copy on povray.binaries.scene-files.
They use the techniques that Warp and Trevor described in their responses. I
don't find it particularly slow for my own purposes, but if you need a large
number of spheres in a very tight formation, then the parsing time could go
up quite a bit.
The example I've posted tries to fit 500 spheres onto a surface that isn't
really big enough. It therefore detects a lot of 'collisions' and rejects a
lot of points.
It ends up testing 2531 positions to find 356 positions before it reaches
the 'maximum tries' control variable (which defaults to 100). This takes
about 8 seconds. You obviously have to have some sort of control to stop it
looping indefinitely, because it's possible to use settings where it's not
physically possible to get that number of objects in the space available,
but you can increase the 'maximum tries' setting to get a tighter
configuration.
The macros give you a few added extras, so the surface doesn't have to be
flat and you can set control variables to keep objects away from edges. You
can create a 'platform' shape using CSG to bunch your objects as you wish.
e.g. you can define bits of non-contiguous surface using 'union'.
Anyway, feel free to use this if it meets your purposes.
Regards,
Chris B.
Post a reply to this message
|
![](/i/fill.gif) |