Advertisement

how to get polygon borders by 2d vector

Started by July 14, 2023 09:19 AM
4 comments, last by alvaro 1 year, 3 months ago

i have cave generated with help of perlin noise. I have 2d vector with marked borders so I need to split them into polygons to handle collisions with them (i use qt, c++)

Maybe it's just me, but I have no idea what you are asking, or if you are even asking a question.

Advertisement

Just guessing here, but it seems like you want to generate a representation of your Perlin noise caves that you can use for collision detection? If the caves are 2D, you could use the marching squares algorithm to convert it to a series of lines representing the cave walls. In 3D, use the dual contouring or marching cubes algorithm to convert the noise field to a triangle mesh. Then you can use the mesh or lines to do collision detection using standard approaches.

Marching Squares:

https://github.com/sjhalayka/Marching-Squares

If the cave is defined as the points where some noise function is positive, couldn't you just evaluate the function to detect collisions? There are reasons why that might not work, but it's hard to tell without the OP being 20 times more clear on what the question is.

This topic is closed to new replies.

Advertisement