A tile-based method for roofing arbitrarily shaped gridded buildings

Update, 20 Aug 2012
I finished the whole thing yesterday, and gave it a write-up of its own. The original article continues below the break.


I went back to my sketchpad after my first attempt at roofing failed spectacularly, and now I have a better method, which is as follows:

  1. Create a new heightmap in the shape of your building. Give all outer walls/doors/windows a height of 0.
  2. Proceed into the building, giving a height of 1 to any tile adjacent to a tile that has zero height.
  3. Repeat Step 2 until all of the building’s tiles have been allocated heights.

You then use this height information to instantiate sloped tiles at the given heights, such that they appear to be a single smooth slope.

Pretend there are no gaps, act impressed or something. It’s only been a few hours!

This approach is fast, and can slot into pretty much any tile-handling system you like, but requires a fair amount of work and comes with its own downsides.

  • You’ll need properly-shaped roof tiles. They’re really simple to make, but so far I have ten twelve unique roof tiles, and will probably need some more (the gaps in the picture above may be edge cases where I’d require a special tile) (the gaps are cases where special masking rules are required to fill them in with the correct tile).
  • The code is circuitous so far. I’ve really just hacked this together to make sure it works, but it’s taken 500+ lines for the tile rotation definitions alone. However, the code is very redundant, which means it can be condensed.
  • You need to loop over your heightmap array a lot. I’ve decided on a height limit of 9, which means that I have to loop through the entire map nine times. Assigning heights to your tiles in a single loop results in a wonky, off-center roof height.
Cowface

Tags:  

    

Nike Air Max classic Nike Free Run sale Nike Air Max kopen Nike Air Max shop Nike Air Max classic goedkoop Nike Air Max 90 goedkoop Nike Air Max 1 kopen Nike Air Max sale Nike Air Max 90 sale Nike Air Max kopen online