|
![](/i/fill.gif) |
ChaoZ nous apporta ses lumieres en ce 05/04/2006 11:36:
> 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.
>
>
If you can cope with a regular, but displaced, placement, like aproximating a gird.
Use a pair of #while(<condition>) loops to place your spheres along a regular gird.
The trick is to
use some random displacement when placing them.
As others suggested, define your spheres a the origin: sphere{0,1} Apply any texture
you want, then
your rotation.
Next, generate the final coordinates adding some random values and use those to
translate your
spheres to their final positions. You can use random jitter larger than your gird mesh
size, you
then only need to test against at most 4 other objects to prevent intersections.
--
Alain
-------------------------------------------------
Post a reply to this message
|
![](/i/fill.gif) |