<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Leif Node</title>
	<atom:link href="https://leifnode.com/category/programming/xna/feed/" rel="self" type="application/rss+xml" />
	<link>https://leifnode.com</link>
	<description>Leif Erkenbrach&#039;s programming blog</description>
	<lastBuildDate>Wed, 22 Jul 2015 23:00:42 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.9.40</generator>
	<item>
		<title>Networked Map Viewer</title>
		<link>https://leifnode.com/2014/03/networked-map-viewer/</link>
		<comments>https://leifnode.com/2014/03/networked-map-viewer/#comments</comments>
		<pubDate>Sat, 15 Mar 2014 12:59:30 +0000</pubDate>
		<dc:creator><![CDATA[Leif Erkenbrach]]></dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://leifnode.com/?p=150</guid>
		<description><![CDATA[This application was made using XNA embedded in a Winforms project. The original tutorial for embedding XNA in Windows Forms can be found here. I needed to make some modifications to the ContentBuilder.cs included with the demo project to allow it to compile shaders and load fonts. I retrieved the map textures from the Google maps API. The height values …<p> <a class="continue-reading-link" href="https://leifnode.com/2014/03/networked-map-viewer/">Continue reading<i class="icon-right-dir"></i></a></p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://leifnode.com/wp-content/uploads/2014/03/mapViewer.jpg"><img class="alignnone size-large wp-image-151" src="http://leifnode.com/wp-content/uploads/2014/03/mapViewer-1024x560.jpg" alt="Map Viewer" width="920" height="503" /></a></p>
<p>This application was made using XNA embedded in a Winforms project. The original tutorial for embedding XNA in Windows Forms can be found <a href="http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_1">here</a>. I needed to make some modifications to the ContentBuilder.cs included with the demo project to allow it to compile shaders and load fonts.</p>
<p>I retrieved the map textures from the Google maps API. The height values were retrieved from the Bing maps API since the limit for maximum number of height queries per day on Bing maps is much higher than Google or many other alternatives. In addition to the benefit of a high limit on queries, the Bing maps API allows me to query height values in a grid by defining the four corners of a patch with latitude and longitude instead of the alternative of querying based on a large list that contains each vertex&#8217;s lat/lon.</p>
<p>The main concern when building a mapping application like this was getting the height values retrieved from Bing maps to line up with the textures from Google maps. Google maps receives image requests by taking a single latitude, longitude, and zoom level. The zoom level exponentially shrinks the area of coverage of a map. so if a zoom level 1 covers a 1000x1000km square then zoom level 2 will cover a 500x500km square and the next will cover 250x250km. Bing maps differs in that it takes in a list of four latitudes and longitudes along with two integers specifying the dimensions of the grid to query. Unfortunately it is not quite as easy as querying the center point + half the coverage size of the Google maps tile. This is because we must account for the curvature of the Earth as illustrated in the figure below. This is done by projecting the latitude and longitude from cylindrical space to spherical space using the Mercator projection. This is explained in further detail at <a href="http://mathworld.wolfram.com/CylindricalProjection.html">Wolfram</a>.</p>
<p>Once I have the latitudes and longitudes of the points that I need to query I create an HttpWebRequest and append the latitude and longitude to the REST API url. I then send off this request in a separate thread so that rendering does not hang while tiles are loading.</p>
<p>Here&#8217;s a demo of the application<br />
<iframe src="//www.youtube.com/embed/RxGg0oAS2ps?rel=0" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<p>I have attached the project files below. The included binaries work correctly, however I have omitted my Bing maps API key from the source so if you wish to compile the project and retrieve the height data  you will need to sign up for a key. There are instructions for doing so <a href="http://msdn.microsoft.com/en-us/library/ff428642.aspx">here</a>.</p>
<p><a href="http://leifnode.com/wp-content/uploads/2014/03/NetworkREST.zip">REST Map Viewer.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>https://leifnode.com/2014/03/networked-map-viewer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Networked Spacewar Clone</title>
		<link>https://leifnode.com/2014/03/networked-spacewar-clone/</link>
		<comments>https://leifnode.com/2014/03/networked-spacewar-clone/#comments</comments>
		<pubDate>Sat, 15 Mar 2014 10:36:03 +0000</pubDate>
		<dc:creator><![CDATA[Leif Erkenbrach]]></dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[XNA 4.0]]></category>

		<guid isPermaLink="false">http://leifnode.com/?p=146</guid>
		<description><![CDATA[For my game networking class last semester I made a networked version of the 1962 game Spacewar. I made this using XNA 4.0 and set the game up on a client-server model where the host is the designated authoritative server that has the final say in health calculations. In the last segment of the video the game has a planet …<p> <a class="continue-reading-link" href="https://leifnode.com/2014/03/networked-spacewar-clone/">Continue reading<i class="icon-right-dir"></i></a></p>]]></description>
				<content:encoded><![CDATA[<p>For my game networking class last semester I made a networked version of the 1962 game <a href="http://en.wikipedia.org/wiki/Spacewar_%28video_game%29">Spacewar</a>. I made this using XNA 4.0 and set the game up on a client-server model where the host is the designated authoritative server that has the final say in health calculations. In the last segment of the video the game has a planet in the center of the screen which attracts all players and will kill them on contact.</p>
<p>In order to reduce the number of packets that I needed to send each packet was split into sections of data that contained a header field and a data field. The header contained a byte to signify the packet type and an unsigned integer to describe the size of the section.</p>
<p><iframe src="//www.youtube.com/embed/PJTnwuhWHN0?rel=0" height="315" width="560" allowfullscreen="" frameborder="0"></iframe></p>
<p>Over the course of the few weeks after I made this I built upon it by adding prediction and smoothing of the player and projectile positions so that the movement of players appeared smooth and accurate to every player when there was a large amount of latency between them and the server.</p>
]]></content:encoded>
			<wfw:commentRss>https://leifnode.com/2014/03/networked-spacewar-clone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
