POV-Ray : Newsgroups : povray.binaries.images : city buildings-- WIP 9_29_2020 : Re: city buildings-- WIP 9_29_2020 Server Time
28 Apr 2024 16:19:03 EDT (-0400)
  Re: city buildings-- WIP 9_29_2020  
From: Bill Pragnell
Date: 30 Sep 2020 07:40:01
Message: <web.5f746dfc32341a551b6c6b3a0@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
[snip]
> Btw, I don't know if it's noticable in these renders, but I made no attempt
> (yet) to 'correctly' place the greebles on the building roofs; they are just
> randomly placed, and most likely intersect each other. I have to admit that I
> still don't know the algorithm or technique for placing randomly-located objects
> that don't overlap, each object having its own space. It is a long-standing
> mystery to me. I know it has been discussed in the newsgroups from time to time.

You can store objects in an array, and check each new one against existing
positions and bounds, for example in dodgy pseudocode:
 Declare array of N objects
 Loop for N
   Make new object
   Loop until new object is ok
     Make location
     Loop over existing objects
       Check new location + bounds against existing object location + bounds
       If collision, new object not ok
     If no collisions were found, new object is ok
   Store new object in array

Using spheres for bounds testing is easiest.

Alternatively, you can subdivide your region of interest, then pick a single
random location in each sub-region. This has the advantage of not requiring
extensive looping and testing, although subdivision might be non-trivial. For
rectangles it's not too bad.

If your objects are all roughly the same sort of size, you can lay a grid down,
perturb the grid positions by some distance smaller than the grid spacing, then
place objects at the perturbed grid positions. Using only a subset of the grid
positions makes it look more random.

There are surely other possibilities!

Bill


Post a reply to this message

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