<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE page SYSTEM "gen/gandraxa.dtd">
<?xml-stylesheet type="text/xsl" href="gen/gandraxa.xsl"?>
<!--
	To see this page properly, install a browser capable of
	interpreting XML/XSL, for example a recent version of:
	- Mozilla Firefox, see http://www.mozilla.com/
	- Google Chrome, see www.google.com/
	- Internet Explorer, see http://www.microsoft.com/
-->
<page>
	<head>
		<title>Isometric Tiling</title>
		<url>http://www.gandraxa.com/isometric_tiling.xml</url>
		<menuimg>
			<img>
				<url>img/imt_menu.jpg</url>
				<alt>Isometric tiling</alt>
			</img>
		</menuimg>
		
		<context>
			<path>
				<home>
					<link loc="int">
						<url>home.xml</url>
						<text>Home</text>
					</link>
				</home>
				<dir>
					<link loc="int">
						<url>articles.xml</url>
						<text>Articles</text>
					</link>
				</dir>
				<dir>
					<link loc="int">
						<url>digital_terrain_analysis.xml</url>
						<text>Digital Terrain Analysis</text>
					</link>
				</dir>
				<doc>Isometric Tiling</doc>
			</path>

			<chain>
				<prev>
					<link loc="left">
						<url>isometric_projection.xml</url>
						<text>Isometric Projection</text>
					</link>
				</prev>
			</chain>
		</context>
		
		<author>
			<mail>
				<recipient>hg</recipient>
				<server>gandraxa.com</server>
				<name>Herbert Glarner</name>
			</mail>
		</author>
		
		<publ>
			<event>
				<eventdate><y>2007</y><m>Nov</m><d>7</d></eventdate>
				<eventtext>
Original HTML version</eventtext>
			</event>
			<event>
				<eventdate><y>2011</y><m>Jan</m><d>25</d></eventdate>
				<eventtext>
					Recoded in XLM
				</eventtext>
			</event>
		</publ>
		
		<furtherreading>
			<readitem>
				<link loc="wiki">
					<url>http://en.wikipedia.org/wiki/Isometric_projection</url>
					<text>Isometric Projection</text>
				</link> on Wikipedia
			</readitem>
		</furtherreading>
	</head>

	<toc>
		<toc1 ref="A">Tiling Concept</toc1>
			<toc2 ref="A1">Flat tiles</toc2>
			<toc2 ref="A2">Elevated Tiles</toc2>
			<toc2 ref="A3">Ramps between Levels</toc2>
			<toc2 ref="A4">All Tiles Combined</toc2>
			<toc2 ref="A5">Texturing</toc2>
		<toc1 ref="B">Geometry of the Tiles</toc1>
			<toc2 ref="B1">Initial Remarks</toc2>
			<toc2 ref="B2">The Tiles</toc2>
	</toc>

	<abstract>
		<p><ptitle>Abstract</ptitle>
			In this article the implementation of an underground consisting of isometric tiles will be studied. 
			The developed tiles allow for completely flat terrains as well as for terrain gradients with 
			a constant slope. The presented model easily can be expanded to comprise also steeper slopes, 
			although the concept of pre-designed tiles only allows to overcome altitudes in pre-determined 
			discrete steps.</p>
	</abstract>



	<part>
		<heading id="A">Tiling Concept</heading>
		<chapter>
			<heading id="A1">Flat Tiles</heading>
			<body>
				<img float="left" width="145">
					<url>/img/imt_fig01.jpg</url>
					<alt>A level underground</alt>
					<caption>Fig. 1: A level underground</caption></img>
				<p>Let's examine what we mean when talking about tiling our isometric tiles 
					to form a completely level underground (fig. 1).</p>
				<p>For practical purposes, the tiles within this article will have the same size 
					as the ones defined for the article series 
					<link loc="int">
						<url>designing_isometric_avatars.xml</url>
						<text>Designing Isometric Avatars</text>
					</link>: they are 46 pixels wide and 24 pixels high. 
					For the reason of this seemingly disturbing odd ration of not exactly 2:1, 
					see the foundations layed out in article 
					<link loc="int">
						<url>isometric_projection.xml</url>
						<text>Isometric Projection</text>
					</link>: it is shown there, how individual tiles need to be connected to each other 
					in order to form a plane.</p>
				<p>As per the rules also lined out in said document, we address the start point 
					of another flat tile to the right of any given tile by proceeding 
					to the right by 24 pixels (not 46 and not 48), and then downward by 12 pixels:</p>
				<p>To address the tile to the right (apparant Southeastern tile, as per outline), one would use:</p>
				<p><formula>X := X + 24</formula></p>
				<p><formula>Y := Y + 12</formula></p>
			</body>
		</chapter>
		<chapter>
			<heading id="A2">Elevated Tiles</heading>
			<body>
				<img float="left" width="145">
					<url>/img/imt_fig02.jpg</url>
					<alt>A raised tile</alt>
					<caption>Fig. 2: A raised tile</caption></img>
				<p>Now let's examine how the centre tile would fit into the environment, 
					if we elevated it to a certain height. Somewhat arbitrarily, 
					we decide that this upper altitude shall be 12 pixels above the ground level 
					of the other tiles (fig. 2).</p>
				<p>Let's assume, that the (cyan) centre tile is elevated as shown, 
					and that the tiles surrounding our displayed area of 3 x 3 tiles are on the same altitude 
					as the 8 (yellow) tiles immediately adjacent to the elevated tile.</p>
				<p>To address the start point of a raised tile to the right of any given tile, 
					we proceed to the right by 24 pixels, as before with a complete level terrain, 
					but the vertical movement needs some correction now. Initially, 
					we still want the 12 pixels downward, where we would expect the tile start 
					if the tile was on the same altitude. But because it is "a level higher" now 
					(a level being defined to have 12 pixels in our example), we need to take 
					the higher altitude into account and <em>subtract</em> 12 pixels 
					<note ref="1">
						<p>We need to subtract and not to add the elevation, because it is assumed,
							that the coordinates' origin is in the left upper corner of the screen.</p>
					</note>
					per such differing level <formula>L</formula>. Hence, to address the tile to the right:</p>
				<p><formula>X := X + 24</formula></p>
				<p><formula>Y := Y + 12 - L * 12</formula></p>
			</body>
		</chapter>
		<chapter>
			<heading id="A3">Ramps between Levels</heading>
			<body>
				<multiimg orientation="vertical" float="right" width="142">
					<img>
						<url>/img/imt_fig03.jpg</url>
						<alt>Straight ramps</alt>
						<caption>Fig. 3: Straight ramps</caption></img>
					<img>
						<url>/img/imt_fig04.jpg</url>
						<alt>One type of corners</alt>
						<caption>Fig. 4: One type of corners</caption></img>
					<img>
						<url>/img/imt_fig05.jpg</url>
						<alt>The other type</alt>
						<caption>Fig. 5: The other type</caption></img>
				</multiimg>
				<p>Now, whereas it is possible that terrains as shown in fig. 2 indeed are wanted 
					(in which case we would graphically provide for some absolutely vertical walls to close the gaps), 
					this is not the case in most implementations of natural terrain.</p>
				<p>What we usually want instead, are transitions as smooth as possible between one level 
					and the next one.</p>
				<p>Notice, that we will have 2 conceptionally different types of transition tiles here. 
					In one type we have 2 out of the 4 corners on a lower elevation, 
						while the other 2 corners are on an upper level (fig. 3).</p>
				<p>In the other type we have 3 out of the 4 points on the lower elevation and 
					the only remaining corner is in the upper elevation (fig. 4).</p>
				<p>In different terrains it is also possible, that the locations of the 3+1 corners are reversed, 
					i.e. that 3 of the corners are in the upper level, and just 1 corner is in the lower (fig. 5).</p>
				<p>If our terrain does never differ by more than one level 
					(which in this article was set to be 12 pixels), then the presented 13 tiles 
					is all what is needed:</p>
				<list>
					<li>1 flat tile</li>
					<li>4 straight ramps</li>
					<li>2×4 corner ramps</li>
				</list>
				<p>This small number makes it very well worthwhile to prefabricate the tiles for your terrain, 
					because such tiles only need to be copied to the correct positions, 
					without any overhead of possibly cumbersome calculations.</p>
				<p>This restriction does not mean now, that your terrain can only consist of 2 levels: 
					you can of course involve several ramps to add up to any desired altitude. 
					However, the gradient within your terrain is fixed: either it is flat or it has 
					predetermined slopes.</p>
			</body>
		</chapter>
		<chapter>
			<heading id="A4">All Tiles Combined</heading>
			<body>
				<img float="left" width="190">
					<url>/img/imt_fig06.jpg</url>
					<alt>All tile types combined</alt>
					<caption>Fig. 6: All tile types combined</caption></img>
				<p>Fig. 6 shows a small 3×5 landscape involving all 13 tile types 
					(there are 3 flat tiles, and 1 tile each of the other types).</p>
				<p>Maybe you were wondering, why I designed the corners with a round base or top, resp. 
					There are two reasons for this:</p>
				<p>The first is, that this grants that the landscape has the same slope everywhere; 
					this might be important when your application involves mechanisms to deal with such elevations, 
					as it takes out the need for additional calculations.</p>
				<p>The second is an esthetical reason. 
					As soon as you begin to assign qualities to different levels 
					(say, water at a certain level and below), then such can be represented conveniently 
					by treating the two parts of such corner tiles differently, as shown in fig. 7.</p>
			</body>
		</chapter>
		<chapter>
			<heading id="A5">Texturing</heading>
			<body>
				<img float="right" width="316">
					<url>/img/imt_fig07.jpg</url>
					<alt>Effect of tile regions</alt>
					<caption>Fig. 7: Effect of tile regions</caption></img>
				<p>What's left is to apply some more realistically looking colors instead of plain colors. 
					This can simply be done by pre-coloring your pre-fabricated tiles 
					(in which case you would need one set for each possible plain underground type, 
					like e.g. sand, rock etc.) and quite many transition tiles 
					(sand can interfer with water, but also with rock, etc.)</p>
				<p>You also might want to take care for some shading. 
					If your terrain is supposed to expose always the same orientation at the same time of day 
					(e.g. you always want to look at the terrain from, say, the South, at noon), 
					then you can pre-color your tiles accordingly.</p>
				<p>Note, however, that the composition of such tile sets is a very time-consuming task. 
					Once pre-facricated, though, you enjoy the benefits of the very fast copy-and-paste method: 
					there is nothing left to calculate anymore.</p>
				<p>If you decide to remain somewhat more flexible with respect of viewing direction 
					and/or time of day and its influence on shade, then it might be a better idea 
					to texture your tiles as they would look like at noon, without any shading. 
					Those effects (if required at all) would then be needed to be inserted 
					by your application as per the actual circumstances, for example by dimming the brightness etc. 
					Brightening and darkening operations can be done almost on the fly in between copy and paste.</p>
				<img float="left" width="190">
					<url>/img/imt_fig08.jpg</url>
					<alt>Texture applied</alt>
					<caption>Fig. 8: Texture applied</caption></img>
				<p>As an example, fig. 8 shows an oasis within sandy environment.</p>
				<p>Note, that the border between the two underground types is not just a straight line, 
					but appears to be somewhat fuzzy, while still connecting nicely with the neighboring tiles: 
					this can be achieved by defining, that the boundary for each tile shall lie exactly 
					in the middle of an edge, and then drawing the thought curve connecting the two middle points 
					at the edges individually.</p>
				<p>Also note, that it is not just a hard curve, separating two regions, 
					but a fuzzy border strip, at either end exposing more of the appropriate underground type, 
					gradually fading out towards the other end.</p>
			</body>
		</chapter>
	</part>

	<part>
		<heading id="B">Geometry of the Tiles</heading>
		<chapter>
			<heading id="B1">Initial Remarks</heading>
			<body>
				<p>The following images show all the tiles you need to model your own terrains 
					as described in this article.</p>
				<p>The red lines in the images are not actually part of a tile: 
					they are just used as an orientation help and indicate, where a tile of type 0 would be drawn.</p>
				<p>The green lines form the equidistant curve from the single isolated corner. 
					They are given purely as a help for your convenience: 
					knowing this line facilitates such tasks as e.g. finding appropriate textures.</p>
				<p>The black lines denote the outermost boundaries of a tile. 
					However, if you are going to texture your tiles, 
					then black lines have to be treated the same as the interior pixels, which are shown in yellow.</p>
				<p>The two offset columns to the right of the images refer 
					to the starting point of a imaginary box surrounding the tile, 
					relative to where you would draw the tile when it would be of type 0. 
					For example does tile 3 state for the Y offset: minus 12, 
					and from the image it can be seen, 
					that the surrounding box starts 12 pixel rows above the topmost red corner.</p>
				<p>Width and height describe the dimensions of that imaginary box surrounding the tile.</p>
			</body>
		</chapter>
		<chapter>
			<heading id="B2">The Tiles</heading>
			<body>
				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0900.jpg</url>
						<alt>Tile type 0</alt>
						<caption>Tile type 0</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>24</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>0</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0901.jpg</url>
						<alt>Tile type 1</alt>
						<caption>Tile type 1</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>12</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>0</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0902.jpg</url>
						<alt>Tile type 2</alt>
						<caption>Tile type 2</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>12</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>0</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0903.jpg</url>
						<alt>Tile type 3</alt>
						<caption>Tile type 3</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>36</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>-12</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0904.jpg</url>
						<alt>Tile type 4</alt>
						<caption>Tile type 4</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>36</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>-12</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0905.jpg</url>
						<alt>Tile type 5</alt>
						<caption>Tile type 5</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>12</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>0</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0906.jpg</url>
						<alt>Tile type 6</alt>
						<caption>Tile type 6</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>24</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>0</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0907.jpg</url>
						<alt>Tile type 7</alt>
						<caption>Tile type 7</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>36</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>-12</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0908.jpg</url>
						<alt>Tile type 8</alt>
						<caption>Tile type 8</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>24</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>0</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0909.jpg</url>
						<alt>Tile type 9</alt>
						<caption>Tile type 9</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>12</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>0</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0910.jpg</url>
						<alt>Tile type 10</alt>
						<caption>Tile type 10</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>36</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>-12</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0911.jpg</url>
						<alt>Tile type 11</alt>
						<caption>Tile type 11</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>36</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>-12</col></row>
				</table>
				<floatclear/>

				<p>
					<img float="left" width="185">
						<url>/img/imt_fig0912.jpg</url>
						<alt>Tile type 12</alt>
						<caption>Tile type 12</caption></img>
				</p>
				<table align="top">
					<row><col>Width:</col>   <col>46</col></row>
					<row><col>Height:</col>  <col>36</col></row>
					<row><col>Offset X:</col><col>0</col></row>
					<row><col>Offset Y:</col><col>-12</col></row>
				</table>
				<floatclear/>
			</body>
		</chapter>
	</part>

</page>

