Procedural meshes for a roguelike?

I’m making a FPS roguelike set in this big office tower, and I found that the Binary Space Partitioning algorithm works really well to create these interior floor plans. The way I’ve got it so far is that it spits out a 2D int array, with each value corresponding to a room index, with -1 being the walls.

Issue is, how do I make this into, well, an actual level? I could go through and make vertices for every corner, and use that to make walls, but that isn’t very flexible. I can’t add windows to walls or anything like that.

But I can’t seem to think of any other ideas to make this into a mesh. Any help?

I usually favor an approach that combines raw procedural geometry (for the simple stuff) with using pre-bakes meshes that I make in Blender3D for the more fine-grained interesting stuff.

For instance, for walls you might have a set of different geometries that would be used to make something interesting each time. One would be blank, one would have a fountain, another would have a huge crack in it, etc.

I also learned a lot from this guy’s scribblings:

http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/

Yeah, that’s one thing I considered. Using pre-made “tiles” means you can add variation whenever, and wherever, but the issue is that I’ve got a 2D array of ints that I’m using for the level, where some cells are marked as walls and others aren’t, so I’ll end up with a lot of gameobjects.

I do also have the list of rooms itself, with all the rects and everything for each rooms size and position.

Making procedural meshes is somewhat complicated. Terrain is the easiest, you only need to work with elevations, but as soon as you go for 3D stuffs, triangles and uv’s start messing with you.
There are two resources I can recommend.
First is this website, containing a lot of amazing stuff. [catlikecoding]
The second is Sebastian Lage’s youtube channel, it can help you with many things, such as your problem. I jumpstarted you to the walls of his cave generator.

1 Like

Ah, don’t worry, I already got the mesh generator going. (first time working with meshes too which is funny)

Thing is, this isn’t very flexible. What if I want a window instead of a wall? Or I want to make some other kind of wall that is practically impossible with proceudral meshes? I’d use prebuilt pieces but with tiles this small it’s not really an option.

Whatever method you use for deciding you want a “wall-like thing” would have its needs satisfied by any number of routines for adding geometry that fits into your definition of “wall like thing,” I guess. That could include window, wall, fence, etc.

Not sure I follow the above logic? I’m saying use the pre-built pieces but only for their source meshes, doing the combination at runtime into the new single mesh, or perhaps just a few meshes total for the level. When I did it for a dungeon game once I made the ceiling a single mesh and the floor a single mesh, and all the walls were a single mesh. Then I went and injected BoxColliders of the right size into each cell, making the physics quite efficient.