Building Creator - creates buildings

A short story: I’m working on a zombie survival game. Typical, I know, but I’ve got a few reasons. First off, I just want to get some more experience and work under my belt before I really try at a big project. Second, my plan isn’t a game like Left 4 Dead, where you’re given a gun and piles upon piles of ammo. I’ve designed the zombies to be something you really, really don’t want to bump into. They react to both sound and sight - and depending on which they’re reacting to they may move at a walking pace or faster than you can run. Lastly, my friends and I have wanted a game to play between just us so it’s something we’re all working together on and collaborating ideas with.
So I’ve created a system that infinitely generates a city. Based on the chosen seed your surroundings will change. Buildings are loaded by lot, and some buildings can take up to 4 lots (2x2). I wrote a very simple compiler for a language in which one designs the buildings. Very quickly I got tired of writing 2 lines of building design, and running it to make sure it was right; too much hassle when I’m already doing that in Java xD so I created a building designer. It’s a graphical designer that allows you to point and click to create full, detailed buildings and output the source when you’ve finished.
My question is if anyone would be interested in designing a few buildings for the game. Once there’s actually a bit of a selection of buildings (maybe 8-10) I’ll finalize the zombie AI code and release a demo. Also, once I get on my work computer I’ll post some pictures and a video of me using the building designer to show how simple it is.
Current supported building features:
+Multiple floors
+Multiple lots
+Definable materials (simply create your material in jMP and put it in the assets.jar, then load them in the Material menu.)
+Custom models (I’ll include a template OBJ file so the scale is correct)
+Ability to output the source of the building to the console

So, if you’re interested, comment here! Videos and images soon.
PS: I figured this would fit better in General than in User Code and Projects since it’s just a request for some input from other game designers.

1 Like

Why not generate the buildings procedurally too and get a (nearly) infinite number of them?

@zarch I wouldn’t know where to begin. I’m not really good with the infinite generation thing, as much as I’d love to. A long while ago I did try, though, and it didn’t work very well really. However with the new system I could give it another go. If I’m going to do that, I’ll need to port the whole lot-managing and loading system to another thread so the generation doesn’t kill performance.

Generating a building doesn’t have to use a lot of performance.

There are lots of different building-generation algorithms online (and pspeed has one in mythruna as well) that you can read up on. I’d just start with something really simple though and then add complexity over time.

@zarch exactly what I did.

That’s what’s been done on a test-case building generator so far. Since then I’ve fixed the existing bugs and added floor generation. Maybe there’s some hope after all. xP

Yeah, building generation as a general thing can get quite complicated… especially if you want to produce nice results. Even Mythruna uses a few layers of templates so that I can control the look.

There are a few SIG-GRAPH papers on this subject along and probably more than a few doctoral theses. :slight_smile:

In my case, I model floors and ceilings as part of the parts themselves but you have to worry about merging and transitions if you will be going into the buildings. I have the benefit of having a world of blocks and can create some simple rules on what happens if one block type tries to merge with another, etc… That helps me a lot.

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&ved=0CDAQFjAB&url=http%3A%2F%2Farxiv.org%2Fpdf%2F1211.5842&ei=NYXvUcrGBI6y9gT404DIAQ&usg=AFQjCNFXn-acLvWU3mkE1ZxWIpji_C4dAw&bvm=bv.49641647,d.eWU
Yeah, voxel-generation would be much easier in this case. However I do have a somewhat controllable grid-based system for building generation. Here’s my thoughts so far:
-Generate outer walls, as I currently do
-Get the type of building (depending on where in the city it is; there won’t be suburban homes in a down-town area, and there won’t be towers in a neighborhood) and decide the rooms based on that.
—3 types of rooms - service, personal, social. Service is smallest - things like closets, bathrooms, etc. Personal is medium sized - bedrooms. Social is largest - kitchen, living room, dining room…
—decide the area of each type of room. (maybe take full area building, random amount between 40-60% is social, 2/3 of what’s left is personal, the rest is service)
—place a large(ish) room near the entrance as the main room, smaller rooms branch off, subtracting from allotted volume for corresponding type
—When remaining area allotted for a type is too low to generate a room of the decided type, add it to the next lowest

The only really difficult part will be deciding the location of the rooms. I’ve got some ideas though, so I suppose we’ll see how that goes.

One thing to be careful of is adding too many constraints. Some irregularities are easy for the mind to explain as long as they are plausible but every constraint you add will reduce the variation. For example, a house with extra doors or two staircases my have once been a duplex that was expanded, etc… At minimum you just want to be functional. My advice would be to make sure that all of your rooms connect to the rest of the building somehow and then only deal with the outrageous outliers… they things that would make someone think “Man, this generator is doing a bad job” instead of just wondering how you got so much variation.

Back to the original topic, Mythruna builds structures like lego. I have corner pieces, “side” pieces, etc… roofs have more variation for me since I have peaked roofs. There are two types of corners in that case and some may only join with others. Mine are based on my voxel sizes and I let corners be one of two sizes, a larger or a smaller (4x4 or 6x6 I think, for corners) The only rule is that the 6x6 versions must include enough wall to join next to a 4x4 (one block back at minimum, basically). Something like that.

Anyway, overall buildings are then made from template sets. A square building would be some number of 2x2 corner pieces stacked with a 2x2 roof. Another might be 2x2 corner pieces with a 2x2 roof that must be roof corners.

The blocks have descriptors that describe whether they can be fully rotated or just mirrored. For example, in a building that has a peaked roof, the ridge line must run in a consistent direction. So you can mirror those roof pieces but you can’t rotate them 90 degrees.

I can and will have templates more complicated than that. For example, I could have a 2x3 building with the first floor 4 corners and two sides while the second floor is two roof corners and a 2x2 four-corner floor… with potentially multiple stories.

Most parts are non-functional… the exception is fireplaces (tricky, avoid if possible. :)), stairs, and doors. I make sure every building has at least one door and every floor has at least one staircase (though actually this is broken except on the first floor…). Some blocks have internal doors and some have open walls. This information is available to me but I don’t use it yet to make sure all rooms are reachable.

“kitchen”, “living room”, “bedroom”, etc. will be decided afterwards. A room could be many different things and I will only eliminate the most heinous of oddities in this case. Again, many things can be explained away with a little imagination… and if each stage of the algorithm builds on the previous then it makes things more plausible. It just depends on how intelligent you make things. For example, in my case, it is better to apply some logic that puts some kind of bookshelf or wooden screen between a bed and the front door than it is to have a rule that says the bedroom can’t be in the same block as the front door. If feasible.

Stuff like this is why my generator makes cool lofts and stuff even when I never programmed them. :slight_smile:

may I have a copy of your algorithms, because this is amazing

Hey, it looks like I lived long enough to see someone do the thing i did before :stuck_out_tongue:
Kidding… In fact I did a generative city framework with Shape grammar and stuffs for my racing game before. But I see you come up with different approach so here is my two cents:

I have the same idea with @pspeed about the “constraints” problems. Let’s say you have : block A have to be “align” with some block B, and C and D… and “fit” into the area X. Overal the area X should be 40% covered with grass and have a park within.

The constraints solver can be very complicated if you want to some how “solve” it from the “constrainst” space. Let look another way around as you can “generate” the slots ( sastified the area constrainst) and road, blocks ( sastified the align constrainst). So, basiclly you to it “top down” not “bottom up” to break downs and didive to conquer each requirement.

In my game, I also generate very detailed house with wall and furniture. so basiclly each house have “information” about its placement and neirborhoods. Overall the city or the street has fashionalbe theme, has architecture style which descipted with shape grammar and customable material. My approach is very close to and influenced by CityEngine and the citygen projects because I did it after reading that papers particularly.

In conclusion, my advice is to carefully concern about the generative approach compare to “constrainst” approach because the “constrainst” problem not always as easy to visualize and solve as a single “align block A to block B” puzzle.

Have a nice day,

About nothing :

  1. you game make me think about “7 days to die”. No problem in that.
  2. You talk about a survival game BUT ou want to procedurally generate something. Even if i love procedural generation, you are going in the wrong direction. Actually, the place where the player (or the players ?) will be is not that much a problem, you should focus on the rest before. Create with some tools a very basic “anera” or use the example of the terrain with heightmap and don’t loose time and effort on something that is not the core of the game. When you’ll have a correct AI, a good networking (if you want to have multiplayer), a good handling of the inventory and the gui, then you’ll be able to change the place where the action will happen. But, then, you’ll also have a multiplayer game playable.
  3. If you arrive to this point, i also think that you should consider the option of creating a bunch a building and place them randomly, not create randomly buildings. This advice is only if you don’t plan to go into these buildings. But, if you want to go in them see 4.
  4. Most of game has non-transparent textures on their glass on their buildings. This is because the interior of the building is not modelised. AND it’s not modelised because it would increase the number of vertex dramatically for nothing. You cannot have a city full of rooms. It’s because of this that morrowind/oblivion/skyrim teleport you inside the buildings : they cannot render them directly, it would “overload” the gpu (and the ppu).
  5. good luck :slight_smile: