POV-Ray : Newsgroups : povray.binaries.images : city buildings-- WIP 9_29_2020 : Re: city buildings-- WIP 9_29_2020 Server Time
25 Apr 2024 09:58:29 EDT (-0400)
  Re: city buildings-- WIP 9_29_2020  
From: BayashiPascal
Date: 30 Sep 2020 09:35:06
Message: <web.5f74886832341a55acc53c020@news.povray.org>
You may find some useful resource for collision detection here:

https://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169

In your case, the objects are axis-aligned as far as I can see, so AABB
collision detection may even be sufficient. Have a look here too:

https://manbeardgames.com/tutorials/aabb-2d-collision-checks/




"Bill Pragnell" <bil### [at] hotmailcom> wrote:
> "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.