Saturday 11 October 2014

Blueprint modular house generation

I decided that I am lazy (aka a fan of saving time), so instead of taking modular pieces and manually building houses out of them inside the engine, I wanted to create a Blueprint construction script which would automatically build me random houses out of my modular pieces.



As I haven't really used Blueprints before, also not a programmer, I was a little worried, however in theory it seemed like it shouldn't be very hard to achieve, so I gave it a shot.

After about a day of trying to get my head around blueprints, I managed to get a basic one working. It was generating a random house out of smaller modular pieces (i.e. corner piece, wall, wall with a single window, wall with a double window, wall with a door etc). BAD IDEA. Good for a small environment, bad (performance-wise, and also overcomplicated) for a large city, as it turns out.

Scrapped the blueprint and decided to do a simpler one, this time to construct the house out of much larger pieces (i.e. ground floor, middle floor(s), roof).




After a bit of fiddling I managed to get it to work almost exactly as I wanted. Here's how it works at the moment:

  • Reads Ground floor, Middle floor and Roof mesh arrays
  • Picks a random ground floor mesh and creates it
  • Reads the Floor Number (defined by me) to know how many middle floor pieces to stack on top of each other
  • Finds the height of the actor and creates the defined amount of random middle floor pieces above the ground floor piece
  • Again finds the height of the actor, picks a random roof mesh and creates it at the top
  • Stores all of the pieces that were used to generate that house in another mesh array
  • Allows me to make any manual changes to the house by switching the meshes in that mesh array
Still have some things to add to the blueprint, but as of right now I am quite happy with how it turned out.





Hopefully I will be able to use this blueprint for majority of the houses, alongside few unique ones and of course hero buildings such as churches/cathedrals.

No comments:

Post a Comment