2

I am trying to create a procedual dungeon generator. I have the floor working perfectly and have created a list of edge vertices for the walls. I duplicate the edge vertices and raise them up by the wall height and now I want to fill in the vertices with the actual wall mesh aka the tris. This is how it looks The edge vertices

Essentially I have to connect the dots However I have concluded my winding order is incorrect. Incorrect winding order

When I generate the edge vertices I run it in a nested for loop that goes along the Z axis first and then the X axis.

for(int z = 0; z < dungeonLength; z++) {
   for(int x = 0; x < dungeonWidth; x++) {
      // Generate verts here
   }
}

All I want it to do is wrap around the level. An example level of what I wish to wrap around

So at the end what do I have. I have a list of vertices, they are not ordered correctly as they go along the Z points first then the X, generating it as it is right now yields broken results How it currently looks with generated mesh

Any advice on how to handle this would be appriciated.

Lyraedan
  • 41
  • 1
  • 6
  • I think you should remove the vertical layer (walls). Currently you are connecting verts of the one wall with the opposite wall which is of course absolutely not what you want to do ;) Rather firs of all generate only the 2D floors. Then use an extrude algorithm for generating the walls from only the outside edges as a separate step – derHugo Apr 11 '22 at 07:28
  • I did try something similar where (without the vertical layer) I'd flag the direction I want the wall to face when I assign the vertices so that I can place a "wall plane" facing in the said direction. And this worked great except I would place it at each vertex point so at corners on one side it would overextend and the diagonal intersections would clog up – Lyraedan Apr 11 '22 at 09:21

1 Answers1

0

I finally figured out a solution.

I have a function called "AddEdge" where I can pass in an edge position and the direction I want it to face. This will construct my quad.

Since I'm running off a grid I pass the current cell I'm checking into a "DrawWall" function if its a wall tile or corner tile.

This DrawWall function will check any adjacent cells to that tile. If any adjacent cells are either null (outside the grid) or empty it will check the direction of that adjacent cell and add a edge accordingly.

Rinse and repeat this process for each wall.

The end result looks how I want it to look The end result

Think of it like a voxel environment where you have a chunk of cubes and you want to only render faces that are not obscuring eachother.

Lyraedan
  • 41
  • 1
  • 6