alpaca
11-19-2006, 22:15
When Spurius and I were thinking about the reasons for the unreachable settlements problem when placing cities in mountaineous areas, he asked me what, in my opinion, a tile in RTW and MTW2 is.
What I answered was that it's the smallest entity a game object can stand on, that is, it corresponds to one pixel in map_regions.tga
He remarked that this is 4 pixels in map_heights.tga - I agreed.
However, he then asked where the 1 pixel offset came from. After some thinking (first I thought that each tile has 4 height info pixels, but that didn't explain the offset) I came up with the following idea:
Each tile has in fact nine corresponding pixels in map_regions.tga, however most of them are shared between neighbouring tiles. To explain this, look at the following image of a 3*3 region map overlaid with a 7*7 heights grid:
https://img213.imageshack.us/img213/2110/mapheightsexamplelz6.png
From this pic, it's actually easy to understand the "offset": You have half a pixel extra on each side of the map, this means the map has to be 1px wider and 1px higher. In formula terms, you can easily deduce the total area and prove that this method yields the right size (w = map_regions width, h = map_regions height; W = map_heights width, H = map_heights height; A = area):
We know that A = W*H = (2w+1)*(2h+1) = 4wh+2w+2h+1, because W = 2w+1 and H = 2h+1
With the above method, in the interior part of the map, each tile has 4*0.5 for the edges, 4*0.25 for the corners and 1*1 for the center pixel - that is, 4 per tile.
For each tile on an edge of the map, we have to add 0.5 + 2*0.25=1 (all in all 5) to this, and for the corner tiles we have to add 2*0.25+2*0.5+0.75=2.25 (all in all 6.25)
This results in an area of:
4*(w-2)*(h-2) + 5*(2*(w-2) + 2*(h-2)) + 6.25*4 = 4wh - 8w - 8h + 16 + 10w-20 + 10h-20 + 25 = 4wh + 2w + 2h + 1
We're currently researching how this translates exactly to unreachable settlements to save time when mapping (i.e. how steep a slope can be at the max to still allow settlements to be reached). Help with that would be greatly appreciated :)
What I answered was that it's the smallest entity a game object can stand on, that is, it corresponds to one pixel in map_regions.tga
He remarked that this is 4 pixels in map_heights.tga - I agreed.
However, he then asked where the 1 pixel offset came from. After some thinking (first I thought that each tile has 4 height info pixels, but that didn't explain the offset) I came up with the following idea:
Each tile has in fact nine corresponding pixels in map_regions.tga, however most of them are shared between neighbouring tiles. To explain this, look at the following image of a 3*3 region map overlaid with a 7*7 heights grid:
https://img213.imageshack.us/img213/2110/mapheightsexamplelz6.png
From this pic, it's actually easy to understand the "offset": You have half a pixel extra on each side of the map, this means the map has to be 1px wider and 1px higher. In formula terms, you can easily deduce the total area and prove that this method yields the right size (w = map_regions width, h = map_regions height; W = map_heights width, H = map_heights height; A = area):
We know that A = W*H = (2w+1)*(2h+1) = 4wh+2w+2h+1, because W = 2w+1 and H = 2h+1
With the above method, in the interior part of the map, each tile has 4*0.5 for the edges, 4*0.25 for the corners and 1*1 for the center pixel - that is, 4 per tile.
For each tile on an edge of the map, we have to add 0.5 + 2*0.25=1 (all in all 5) to this, and for the corner tiles we have to add 2*0.25+2*0.5+0.75=2.25 (all in all 6.25)
This results in an area of:
4*(w-2)*(h-2) + 5*(2*(w-2) + 2*(h-2)) + 6.25*4 = 4wh - 8w - 8h + 16 + 10w-20 + 10h-20 + 25 = 4wh + 2w + 2h + 1
We're currently researching how this translates exactly to unreachable settlements to save time when mapping (i.e. how steep a slope can be at the max to still allow settlements to be reached). Help with that would be greatly appreciated :)