Friday, November 22, 2024
spot_img

Randomly generate polygonal obstacles from Delaunay triangulation


The hyperbolic facet is larger issue than lead suggests as a result of as you’ve got found, it presents a major problem to utilizing Perlin / Simplex noise. These features are one of many first issues I’d attempt for making procedurally generated blob shapes.

These features are helpful on this context as a result of they’ve a great stability between randomness and continuity. By continuity, I imply that there aren’t quite a lot of abrupt modifications and the values in a really native area are usually related (versus say sampling instantly from random noise). However due to the randomness, they do not have repeating patterns. (At the very least not often. Patterns both end result from implementation errors or algorithms which can be much like, however not the identical as precise gradient noise features).

They don’t seem to be the one possibility although. Abstractly, we would like to have the ability to flag contiguous groupings of triangles in a way that is suitable with the hyperbolic airplane requirement. Because you’re already utilizing a Delaunay triangulation a associated idea that must be obtainable is a Voronoi diagram. (Mathematically, a Voronoi diagram is the twin of a Delaunay triangulation. We are able to use a Voronoi diagram to partition your area and from there develop methods to pick teams of triangles.

I already had a 2D Poisson disk sampler (generates blue noise), so I used that to provide the next Delaunay triangulation:

Delaunay triangulation

Subsequent, I generated a Voronoi diagram:

Voronoi diagram

One key factor to note is that the typical Voronoi cell measurement is a number of instances bigger than the typical triangle cell measurement. One other is that this Voronoi diagram isn’t the twin of the Delaunay triangulation I had within the earlier step. It’s a separate randomly generated construction.

I used a distance perform inside the cells to additional prohibit the areas of curiosity:

distance function inside Voronoi cells

Lastly, use the areas of curiosity to pick triangles to be obstacles. I used a strict overlap – if the triangle touched the realm of curiosity, I flagged it as an impediment. I’ve superimposed a semitransparent model of the earlier picture excessive to point out how the obstacles (in orange) cowl the ball shaped on every distance perform.

triangles masked by distance function balls

There’s quite a lot of room for experimentation. This is another method the place I first chosen random pairs of Voronoi cells. Particularly, I choose a random cell, then I see if it has an adjoining cell that’s each unselected & not touching another chosen cells – if each standards are met, I add the pair:

Voronoi cell pairs

Then used your complete cell (relatively than a distance perform inside the cell) to masks out obstacles within the triangle mesh. Once more, I’ve superimposed the earlier step to point out how the obstacles triangles cowl the realm of curiosity.

triangles masked with cell pairs

Listed here are another tunable parameters and issues to experiment with:

Voronoi cell measurement

I chosen a cell measurement that was massive sufficient relative to my masking technique such that I received attention-grabbing islands of obstacles. If the cell measurement is simply too small, you may find yourself deciding on too many triangles. On the opposite finish, if the cells are to massive, you get an excessive amount of empty area and little or attainable no clumps that bridge between adjoining Voronoi cells. Additionally, the triangles set the granularity of the output. If the distinction in scale between the triangles and the Voronoi cells is huge sufficient, the triangles efficient act like pixels and you will see the sample generated by the Voronoi cells themselves.

Voronoi cell choice

I picked a few easy choices as a place to begin. For one thing extra complicated, you possibly can probabilisticly develop islands of cells or modify a maze era algorithm to tunnel by the Voronoi diagram.

Triangle choice

As a substitute of a full overlap/collision calculation, you possibly can test the triangle vertices or the centroids. For extra complicated instance, you possibly can use the triangle vertices to pattern the gap perform within the Vornonoi cell and solely flag the triangle if the sum of the samples exceeded some threshold.

The entire above have some interdependence and altering one will probably require tweaking the others.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles