<?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"
	>

<channel>
	<title>MPQNav Public Blog</title>
	<atom:link href="http://www.mpqnav.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mpqnav.com</link>
	<description>WOW Navigation from MPQ Files</description>
	<pubDate>Sun, 28 Dec 2008 05:27:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>The state of things.</title>
		<link>http://www.mpqnav.com/2008/12/28/the-state-of-things/</link>
		<comments>http://www.mpqnav.com/2008/12/28/the-state-of-things/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 05:27:19 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/?p=178</guid>
		<description><![CDATA[Most of you that are in IRC already know this, for those that don&#8217;t I figured a new post is long overdue.
Currently I&#8217;m not doing any work on this project due to the uncertain future of ISXWarden / Glider. The point of this project was to create a navigation system that could be used by [...]]]></description>
			<content:encoded><![CDATA[<p>Most of you that are in IRC already know this, for those that don&#8217;t I figured a new post is long overdue.</p>
<p>Currently I&#8217;m not doing any work on this project due to the uncertain future of ISXWarden / Glider. The point of this project was to create a navigation system that could be used by the public(ish) botting platforms out there. With both of the big ones on the edge of *poof* I have put everything on hold.</p>
<p>For anybody that wishes to pick up the project let me know and I&#8217;ll offer you any and all help that I can (knowledge wise, not much time for coding these days). Please understand also that <strong>some file formats</strong> have changed with the release of WOTLK and as such this project needs to be updated to work in it&#8217;s current form. The changes aren&#8217;t that major and should be simple enough to fix up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/12/28/the-state-of-things/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Project is still alive, real life getting in the way lately.</title>
		<link>http://www.mpqnav.com/2008/08/23/project-is-still-alive-real-life-getting-in-the-way-lately/</link>
		<comments>http://www.mpqnav.com/2008/08/23/project-is-still-alive-real-life-getting-in-the-way-lately/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 04:31:24 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/2008/08/23/project-is-still-alive-real-life-getting-in-the-way-lately/</guid>
		<description><![CDATA[I am writing this message of my own free will. I hereby declare I have not be threatened with a titanium poison tipped spork of epic proportions&#8230;
 Joking aside the project is still alive and well, but real life has gotten in the way and bills must be paid (or so they keep telling me). [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/08/spork2.jpg"  rel="lightbox[177]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="240" alt="spork2" src="http://www.mpqnav.com/wp-content/uploads/2008/08/spork2-thumb.jpg" width="129" align="left" border="0"></a>I am writing this message of my own free will. I hereby declare I have not be threatened with a titanium poison tipped spork of epic proportions&#8230;</p>
<p> Joking aside the project is still alive and well, but real life has gotten in the way and bills must be paid (or so they keep telling me). With a few projects dragging on that should have been done and paid a while ago it means I get to work overtime yet again to make up for people being lazy. The good news is they eventually pay and then it&#8217;s almost like a bit of time off with pay.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/08/23/project-is-still-alive-real-life-getting-in-the-way-lately/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Latest</title>
		<link>http://www.mpqnav.com/2008/08/09/the-latest/</link>
		<comments>http://www.mpqnav.com/2008/08/09/the-latest/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 11:50:00 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/2008/08/09/the-latest/</guid>
		<description><![CDATA[Many people have been curious when an update will be coming and the truth of the matter is I can&#8217;t really give a date. Working as hard as I can to get an update out there for everybody but it certainly won&#8217;t be this weekend (anniversary, wedding, then birthday). I&#8217;d really like to get one [...]]]></description>
			<content:encoded><![CDATA[<p>Many people have been curious when an update will be coming and the truth of the matter is I can&#8217;t really give a date. Working as hard as I can to get an update out there for everybody but it certainly won&#8217;t be this weekend (anniversary, wedding, then birthday). I&#8217;d really like to get one out there sometime this coming week or possibly next weekend.</p>
<p>Sorry for the delays!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/08/09/the-latest/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting quadtrees up and running!</title>
		<link>http://www.mpqnav.com/2008/07/28/getting-quadtrees-up-and-running/</link>
		<comments>http://www.mpqnav.com/2008/07/28/getting-quadtrees-up-and-running/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 09:14:20 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/?p=166</guid>
		<description><![CDATA[Well it&#8217;s been a while since there was a quality update, hopefully this will really be it. Quadtrees have been my main focus these days and we&#8217;re going to get them running come hell or high water. The first step in getting our quadtrees running is to figure out just how many we are going [...]]]></description>
			<content:encoded><![CDATA[<p>Well it&#8217;s been a while since there was a quality update, hopefully this will really be it. Quadtrees have been my main focus these days and we&#8217;re going to get them running come hell or high water. The first step in getting our quadtrees running is to figure out just how many we are going to need. This is actually a bit easier then it seems (at least in my opinion). At first I was trying to think of a proper algorithm to subdivide the space down to the most efficient level, after my brain started to hurt I decided to go the easier route (pick a number and hope it works).</p>
<p>I went with splitting the terrain all the way down to a 16 x 16 grid for some reason to start. I think a lot of it had to do with the fact that <a href="http://wowdev.org/wiki/index.php/ADT#MCNK_chunks" onclick="javascript:pageTracker._trackPageview('/outbound/article/wowdev.org');" target="_blank">MCNKs</a> happen to be in a 16 x 16 fashion and I thought for some reason that the placement information for models was on a <a href="http://wowdev.org/wiki/index.php/ADT#MCNK_chunks" onclick="javascript:pageTracker._trackPageview('/outbound/article/wowdev.org');" target="_blank">MCNK</a> by <a href="http://wowdev.org/wiki/index.php/ADT#MCNK_chunks" onclick="javascript:pageTracker._trackPageview('/outbound/article/wowdev.org');" target="_blank">MCNK</a> basis (it isn&#8217;t if you forgot).</p>
<p><span id="more-166"></span></p>
<p>Now just how will the quad trees work? Well we start out with the entire ADT being the top of the tree. Now let&#8217;s look at Redridge for an example (my favorite zone to test in):</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/07/redridgequad.jpg"  rel="lightbox[166]"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="680" alt="redridgequad" src="http://www.mpqnav.com/wp-content/uploads/2008/07/redridgequad-thumb.jpg" width="340" align="left" border="0"></a> Now I covered quadtrees in a previous entry, but hopefully this will help enlighten things a bit. The top picture will be our first set of quadtrees that effectively divides the ADT into 4 chunks. Previously if we wanted to check if our character would hit anything we would test it against every single triangle in the scene. This was a complete waste of processing power which normally I wouldn&#8217;t care too much about, but it was so bad it would make your mother&#8217;s accountant cry (and we both know how much he sucks with a computer).</p>
<p>Using quadtrees the thought process goes like this:</p>
<p>First determine which quad we are in. This is extremely easy as it&#8217;s simply finding a point within a rectangle. Now let&#8217;s assume we&#8217;re in Quad 1 for example. Because we know we are in Quad 1 it&#8217;s safe to assume that we do not need to test against any data in Quad&#8217;s 2, 3, or 4. We can just ignore them.</p>
<p>After we determine the large quad we are in, we then go ahead and look at the children of that quad (it will have 4) and we see which of those four we are in. We again know that we can ignore the other three.</p>
<p>We repeat this until we hit a quad without children, and then we only test against geometry that is also present in that quadtree.</p>
<p>Now if we are to assume that all of our geometry was equally distributed across the scene (that is to say that there was an equal amount of triangles in every little 1/265th quad) we could also safely assume test would take 1/256th of the time. That means if it took an hour before, it would now just take roughly 15 seconds! Of course that is not exact, but should give you an idea of the benefit of quadtrees (which will later be octrees I think but I&#8217;m not there yet).</p>
<p>Now the basic idea is pretty simple, and here&#8217;s how we&#8217;re going to do it (pseudocode for now, still writing the actual code but I wanted to get a quality update out ASAP).</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/07/quadpoints.jpg"  rel="lightbox[166]"><a href="http://www.mpqnav.com/wp-content/uploads/2008/07/children.jpg" rel="lightbox[166]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="180" alt="children" src="http://www.mpqnav.com/wp-content/uploads/2008/07/children-thumb.jpg" width="180" align="right" border="0"></a><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="180" alt="quadpoints" src="http://www.mpqnav.com/wp-content/uploads/2008/07/quadpoints-thumb.jpg" width="180" align="left" border="0"></a>First is the quadtree class. This is going to be a rather simple class, containing two vectors that represent the tree. The picture on the left shows this with the yellow and blue dot. This class will also happen to contain an array of 4 other quad trees that will be the children (picture on the right).&nbsp; </p>
<p>That pretty much takes care of the entire structure needed to define the actual quadtree, but we still need to link our data to an each tree. To do this we are going to define the starter tree in the ADT class. It&#8217;s a simple enough task to get the minimum and maximum vectors for the quadtree when we create our ADT as we always know the X,Y position of it in the 64 x 64 grid as well as it&#8217;s width and height (both are constant).</p>
<p>Now subdividing is simple enough, we are just going to divide down until we&#8217;re at 16&#215;16. I.e.</p>
<p>1 -&gt; 4 -&gt; 16 -&gt; 64 -&gt; 256</p>
<p align="left"><a href="http://www.mpqnav.com/wp-content/uploads/2008/07/quadfollow.jpg"  rel="lightbox[166]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="230" alt="quadfollow" src="http://www.mpqnav.com/wp-content/uploads/2008/07/quadfollow-thumb.jpg" width="370" border="0"></a> </p>
<p>Now the next thing we need is a link to each M2 and WMO within our quad. So the quadtree class is going to have a list that contains a reference to each M2 and WMO that is used by that quad.</p>
<p>The final thing that is needed is the terrain data used by that quad. Doing a 16 x 16 setup makes this easy enough as when we process a MCNK we will simply put that data over into the proper quadtree and call it a day.</p>
<p>Well I hope this was at least semi-helpful to those struggling with quadtrees and if nothing else it should serve as a good post that progress is being made (just slowly these days).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/07/28/getting-quadtrees-up-and-running/feed/</wfw:commentRss>
		</item>
		<item>
		<title>What&#8217;s happenin&#8217; cappin&#8217;?</title>
		<link>http://www.mpqnav.com/2008/07/24/whats-happenin-cappin/</link>
		<comments>http://www.mpqnav.com/2008/07/24/whats-happenin-cappin/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 19:19:06 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/2008/07/24/whats-happenin-cappin/</guid>
		<description><![CDATA[Well just a quick mini-update here. I&#8217;ve been working on both implementing the automatic MPQ streaming that was posted on the forums into the trunk (and spending a good amount of time reading up about the GPL to ensure I stay within the license of mpqtool) and more importantly I&#8217;ve been working on quadtrees. Right [...]]]></description>
			<content:encoded><![CDATA[<p>Well just a quick mini-update here. I&#8217;ve been working on both implementing the automatic MPQ streaming that was posted on the forums into the trunk (and spending a good amount of time reading up about the GPL to ensure I stay within the license of mpqtool) and more importantly I&#8217;ve been working on quadtrees. Right now I&#8217;d say I&#8217;m roughly 50% done with the quadtree setup and about 50% done with the mpqtool integration as well. The quadtrees are being done in a manner that ensures moving to an octree later on won&#8217;t be too difficult at all as I&#8217;m sure I&#8217;ll want to do it at some point. I&#8217;ve also been playing with the console a bit and integrating a &#8220;render OBB&#8221; type of command (for other items as well) which should make things a bit of fun.</p>
<p>Not much of an update but better then nothing!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/07/24/whats-happenin-cappin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Long awaited cleanup has arrived!</title>
		<link>http://www.mpqnav.com/2008/07/19/long-awaited-cleanup-has-arrived/</link>
		<comments>http://www.mpqnav.com/2008/07/19/long-awaited-cleanup-has-arrived/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 05:18:05 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[ADT]]></category>

		<category><![CDATA[Extraction]]></category>

		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/?p=162</guid>
		<description><![CDATA[Well to those that keep an eye on IRC I posted a few updates to the SVN already that show the code cleanup (be aware it&#8217;s more or less a complete rewrite). The two biggest additions to this new code bank is the console (provided by arkwiw from IRC) and a new config file (named [...]]]></description>
			<content:encoded><![CDATA[<p>Well to those that keep an eye on IRC I posted a few updates to the SVN already that show the code cleanup (be aware it&#8217;s more or less a complete rewrite). The two biggest additions to this new code bank is the console (provided by arkwiw from IRC) and a new config file (named app.config) that is used to list where your maps are extracted to. Here&#8217;s a quick Youtube video showing the dynamic loading of maps:</p>
<p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:b35e53bc-cbbf-482b-8228-0291c975e8d0" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="ae01ebd5-d883-4c97-bf14-c93bc1c1bbd1" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=csbNV1Ou-Hw" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.youtube.com');" target="_new"><img src="http://www.mpqnav.com/wp-content/uploads/2008/07/video754495eb5a5b.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('ae01ebd5-d883-4c97-bf14-c93bc1c1bbd1'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/csbNV1Ou-Hw\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/csbNV1Ou-Hw\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p><span id="more-162"></span></p>
<p>It may not look as if things have moved along too much, but truthfully they really have. The code is much easier to follow now and with all the XML comments I&#8217;ll be putting up a HTML documentation for the entire project in the next few days. In addition if you&#8217;ve looked in the <a href="http://www.mpqnav.com/forums/"  target="_blank">forums</a> you may have noticed that beserk85 has integrated MPQNav with <a href="http://code.google.com/p/mpqtool/" onclick="javascript:pageTracker._trackPageview('/outbound/article/code.google.com');" target="_blank">mpqtool</a> which streams the ADT/WMO/etc&#8230; files straight from the MPQ archive. I&#8217;m going to be moving it into the trunk (and trying to contact a dev from mpqtool just to ensure they don&#8217;t mind me using it in this project) over the weekend and I hope to have a post on that soon.</p>
<p>There is at least one new feature though&#8230;</p>
<h1>The Console!</h1>
<p>Setup by arkwiw I have moved it into the source. To access the console hit the <strong>esc</strong> key (it&#8217;s on the HUD now as well just in case you forget). From there you will be able to execute commands. The only current on is the load command:</p>
<blockquote><p>Load X Y</p>
</blockquote>
<p>This loads up the ADT at (X,Y) for the continent that you have loaded.</p>
<h2>app.config</h2>
<p>There is now also a configuration file. Currently it has a field for where the MPQ files are extracted to as well as the X and Y of the default map you want to load(and the continent).</p>
<p>Keep in mind that I will be using my app.config on the SVN so it will overwrite yours if you forget and just do an update. I think you can exclude the app.config from the updates if you want but I am no SVN guru.</p>
<h2></h2>
<h2>What no zip?</h2>
<p>Right now I just wanted to let people know the code cleanup is finished and ready to play with on the SVN; however, there are a few other changes I want to make before releasing another zip file completely. I am shooting to get those done over the weekend with more of a writeup on just why the code is cleaner to go with it. Until then play with the SVN!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/07/19/long-awaited-cleanup-has-arrived/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How about a programming structure you can follow?</title>
		<link>http://www.mpqnav.com/2008/07/10/how-about-a-programming-structure-you-can-follow/</link>
		<comments>http://www.mpqnav.com/2008/07/10/how-about-a-programming-structure-you-can-follow/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 05:55:27 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[ADT]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[theory]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/2008/07/10/how-about-a-programming-structure-you-can-follow/</guid>
		<description><![CDATA[I have mentioned many times over the last handful of posts that the code is being refactored because it has turned into a spaghetti monster (not the flying one in the sky, the one that lives inside of all of us and we must defend against when writing anything useful). Well as I&#8217;ve been working [...]]]></description>
			<content:encoded><![CDATA[<p>I have mentioned many times over the last handful of posts that the code is being refactored because it has turned into a spaghetti monster (not the flying one in the sky, the one that lives inside of all of us and we must defend against when writing anything useful). Well as I&#8217;ve been working out the kinks here or there and been playing with the code I thought a mini-preview might be of some value. So first I present to you what I call my world famous Photoshop skills on quickly drawing what I&#8217;m doing:</p>
<p>&nbsp;</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/07/adtmanager1.gif"  rel="lightbox[157]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="210" alt="adtmanager" src="http://www.mpqnav.com/wp-content/uploads/2008/07/adtmanager-thumb.gif" width="500" border="0"></a> </p>
<p><span id="more-157"></span></p>
<p>Now if you can&#8217;t tell from the picture above there is a single ADT manager (technically a single ADT Manager per continent but that&#8217;s beside the point) which manages the&#8230; ADTs for that continent. These are all of course loaded on demand. Within each ADT is a WMO and M2 manager that handles their respective files (loaded when the ADT is loaded). If you remember previously our setup more or less looked like this:</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="210" alt="adtamangerbad" src="http://www.mpqnav.com/wp-content/uploads/2008/07/adtamangerbad.gif" width="500" border="0"> </p>
<p>I know this is obviously a mini-post but I hope it instill some hope!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/07/10/how-about-a-programming-structure-you-can-follow/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Silence for too long can make a grown man cry!</title>
		<link>http://www.mpqnav.com/2008/07/09/silence-for-too-long-can-make-a-grown-man-cry/</link>
		<comments>http://www.mpqnav.com/2008/07/09/silence-for-too-long-can-make-a-grown-man-cry/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 17:20:04 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/2008/07/09/silence-for-too-long-can-make-a-grown-man-cry/</guid>
		<description><![CDATA[
Too long without a post is never a good thing for a blog, so I decided to devote as little time as possible to this post as I have a long &#8220;To-do&#8221; list and not nearly enough time to do it today. Let&#8217;s see where we are:

I see a lot of people in IRC and [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Too long without a post is never a good thing for a blog, so I decided to devote as little time as possible to this post as I have a long &#8220;To-do&#8221; list and not nearly enough time to do it today. Let&#8217;s see where we are:</p>
<ol>
<li>I see a lot of people in IRC and I appreciate you all stopping by and/or idling <img src='http://www.mpqnav.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Thanks to everybody that&#8217;s said a kind word about the project at hand, you freaking rock!</li>
<li>arkwiw has finished an XNAConsole wrapper for the project. Not only has he finished it, he documented how it&#8217;s setup, gave the source code, and it looks great. This will be the feature of the next blog post ASAP so all praise be to arkwiw!</li>
<li>Most all of the code is refactored now (I&#8217;d say 90%) I just have some commenting that needs finishing and to re-write a few other bits and pieces properly instead of 1000 line methods. </li>
</ol>
<p>I know this update sucks, and it&#8217;s not even much of an update, but at least it&#8217;s a post!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/07/09/silence-for-too-long-can-make-a-grown-man-cry/feed/</wfw:commentRss>
		</item>
		<item>
		<title>So redsector want&#8217;s to know the next chapter&#8230;</title>
		<link>http://www.mpqnav.com/2008/07/03/so-redsector-wants-to-know-the-next-chapter/</link>
		<comments>http://www.mpqnav.com/2008/07/03/so-redsector-wants-to-know-the-next-chapter/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 12:04:20 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/2008/07/03/so-redsector-wants-to-know-the-next-chapter/</guid>
		<description><![CDATA[&#60;redsector&#62; its just like getting into a book
&#60;redsector&#62; but the book is not finished yet
&#60;redsector&#62; i enjoy your writing style
The problem is&#8230; this is about all I have:


Refactoring all the code was a big job and a needed one, I still have roughly 25% to go which is where a lot of the holdup is [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>&lt;redsector&gt; its just like getting into a book<br />
&lt;redsector&gt; but the book is not finished yet<br />
&lt;redsector&gt; i enjoy your writing style</p></blockquote>
<p>The problem is&#8230; this is about all I have:</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/07/nextstep.gif"  rel="lightbox[151]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.mpqnav.com/wp-content/uploads/2008/07/nextstep-thumb.gif" border="0" alt="nextstep" width="500" height="125" /></a></p>
<p><span id="more-151"></span></p>
<p>Refactoring all the code was a big job and a needed one, I still have roughly 25% to go which is where a lot of the holdup is at the moment. To give an idea here&#8217;s an excerpt from the new WMOManager (instead of lumping everything into the damned ADTManager like I was):</p>
<div id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:5b9b1659-5599-4b28-9154-0e666ae313d7" class="wlWriterSmartContent" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('1512');">[<span id="1512_symbol">-</span>]</a></span><span class="codebox_left"><span id="l151code2"><a href="javascript:;" onclick="javascript:showCodeTxt('151code2'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="1512"><td class="code" id="151code2"><pre class="csharp">        <span style="color: #008080; font-style: italic;">/// </span>
        <span style="color: #008080; font-style: italic;">/// Adds a WMO to the manager</span>
        <span style="color: #008080; font-style: italic;">/// </span>
        <span style="color: #008080; font-style: italic;">///</span>
Filename of the WMO from the Adt <span style="color: #008000;">-</span> i.<span style="color: #0000FF;">e</span>. <span style="color: #0000FF;">world</span>\wmo\azeroth\buildings\redridge_stable\redridge_stable.<span style="color: #0000FF;">wmo</span>
        <span style="color: #008080; font-style: italic;">///</span>
<span style="color: #0600FF;">Base</span> path to where the MPQ <span style="color: #008000;">is</span> extract <span style="color: #008000;">-</span> i.<span style="color: #0000FF;">e</span>. <span style="color: #0000FF;">c</span><span style="color: #008000;">:</span>\mpq\
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> addWMO<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span> fileName, <span style="color: #FF0000;">String</span> filePath<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>File.<span style="color: #0000FF;">Exists</span><span style="color: #000000;">&#40;</span>filePath <span style="color: #008000;">+</span> fileName<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">addName</span><span style="color: #000000;">&#40;</span>fileName<span style="color: #000000;">&#41;</span>;
                BinaryReader br <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> BinaryReader<span style="color: #000000;">&#40;</span>File.<span style="color: #0000FF;">OpenRead</span><span style="color: #000000;">&#40;</span>filePath <span style="color: #008000;">+</span> fileName<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
                WMO currentWMO <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WMO<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                currentWMO.<span style="color: #0000FF;">name</span> <span style="color: #008000;">=</span> fileName;
                br.<span style="color: #0000FF;">ReadBytes</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">20</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// Skip the header</span>
                UInt32 nTextures    <span style="color: #008000;">=</span> br.<span style="color: #0000FF;">ReadUInt32</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                UInt32 nGroups      <span style="color: #008000;">=</span> br.<span style="color: #0000FF;">ReadUInt32</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// This is the number of &quot;sub-wmos&quot; or group files that we need to read</span>
                UInt32 nPortals     <span style="color: #008000;">=</span> br.<span style="color: #0000FF;">ReadUInt32</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                UInt32 nLights      <span style="color: #008000;">=</span> br.<span style="color: #0000FF;">ReadUInt32</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                UInt32 nModels      <span style="color: #008000;">=</span> br.<span style="color: #0000FF;">ReadUInt32</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                UInt32 nDoodads     <span style="color: #008000;">=</span> br.<span style="color: #0000FF;">ReadUInt32</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                UInt32 nSets        <span style="color: #008000;">=</span> br.<span style="color: #0000FF;">ReadUInt32</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                UInt32 ambientColor <span style="color: #008000;">=</span> br.<span style="color: #0000FF;">ReadUInt32</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
                UInt32 WMOID <span style="color: #008000;">=</span> br.<span style="color: #0000FF;">ReadUInt32</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// Column 2 in the WMOAreaTable.dbc</span>
&nbsp;
                <span style="color: #FF0000;">float</span> bb1_x <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#40;</span>br.<span style="color: #0000FF;">ReadSingle</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">*</span> <span style="color: #FF0000;">-1</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #FF0000;">float</span> bb1_z <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span><span style="color: #000000;">&#41;</span>br.<span style="color: #0000FF;">ReadSingle</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #FF0000;">float</span> bb1_y <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span><span style="color: #000000;">&#41;</span>br.<span style="color: #0000FF;">ReadSingle</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #FF0000;">float</span> bb2_x <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#40;</span>br.<span style="color: #0000FF;">ReadSingle</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">*</span> <span style="color: #FF0000;">-1</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #FF0000;">float</span> bb2_z <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span><span style="color: #000000;">&#41;</span>br.<span style="color: #0000FF;">ReadSingle</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #FF0000;">float</span> bb2_y <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span><span style="color: #000000;">&#41;</span>br.<span style="color: #0000FF;">ReadSingle</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
                currentWMO.<span style="color: #0000FF;">createAABB</span><span style="color: #000000;">&#40;</span>Vector3<span style="color: #000000;">&#40;</span>bb1_x, bb1_y, bb1_z<span style="color: #000000;">&#41;</span>, Vector3<span style="color: #000000;">&#40;</span>bb2_x, bb2_y, bb2_z<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
                currentWMO.<span style="color: #0000FF;">total_groups</span> <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span><span style="color: #000000;">&#41;</span>nGroups;
                <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> wmoGroup <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>; wmoGroup <span style="color: #008000;">&amp;</span>lt; nGroups; wmoGroup<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #FF0000;">String</span> currentFileName <span style="color: #008000;">=</span> currentWMO.<span style="color: #0000FF;">name</span>.<span style="color: #0000FF;">Substring</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, currentWMO.<span style="color: #0000FF;">name</span>.<span style="color: #0000FF;">Length</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;_&quot;</span> <span style="color: #008000;">+</span> wmoGroup.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">PadLeft</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span>, <span style="color: #808080;">&quot;0&quot;</span>.<span style="color: #0000FF;">ToCharArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;.wmo&quot;</span>;
                    currentWMO.<span style="color: #0000FF;">addWMO_Sub</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">processWMOSub</span><span style="color: #000000;">&#40;</span>currentFileName, filePath, wmoGroup<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">else</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> Exception<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;File does not exist: &quot;</span> <span style="color: #008000;">+</span> fileName <span style="color: #008000;">+</span> filePath<span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

</div>
<p>Do you see what I see? Comments, not doing everything in one little huge method, error checking, proper variable usage&#8230; OH HOW SWEET IT IS!</p>
<p>Now imagine doing that to all the code and changing the entire control flow, that&#8217;s what I&#8217;ve been doing. When I&#8217;m not doing that but still find freetime somewhere somehow I have also been reviewing a few other nifty little options for the program that are on my list of implementation.</p>
<p>Over at codeplex is a great little setup for a console in XNA: <a title="http://www.codeplex.com/XnaConsole" href="http://www.codeplex.com/XnaConsole" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.codeplex.com');">http://www.codeplex.com/XnaConsole</a></p>
<p>Google code has a C# implementation of MPQ extraction: <a title="http://code.google.com/p/mpqtool/" href="http://code.google.com/p/mpqtool/" onclick="javascript:pageTracker._trackPageview('/outbound/article/code.google.com');">http://code.google.com/p/mpqtool/</a></p>
<p>Both are going to make their way into the source at one time or another (with due credit of course) and both should really make things a lot more fun. Instead of having to hardcode which maps to load, it will become a console command. Where you extracted MPQ files are located will be an external setting. The MPQExtractor will look to see if the files exist in said location, and if they don&#8217;t it will automatically extract them.</p>
<p>This will also allow me to run incremental collision tests (say a small area at a time) without have to constantly start and stop the program (of course it will let you do it as well).</p>
<p>Another big addition I&#8217;d love to put in for fun/ease of use is mouse control for the camera. I&#8217;ve been digging and it shouldn&#8217;t be too difficult at all (that&#8217;s at the very end of the list though).</p>
<p>Well this wasn&#8217;t much of an update but I should get brownie points for the Photoshop mastery at least!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/07/03/so-redsector-wants-to-know-the-next-chapter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Quadtrees&#8230; You&#8217;re doing it wrong!</title>
		<link>http://www.mpqnav.com/2008/06/30/quadtrees-youre-doing-it-wrong/</link>
		<comments>http://www.mpqnav.com/2008/06/30/quadtrees-youre-doing-it-wrong/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 09:17:48 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[collision]]></category>

		<category><![CDATA[quadtree]]></category>

		<guid isPermaLink="false">http://www.mpqnav.com/2008/06/30/quadtrees-youre-doing-it-wrong/</guid>
		<description><![CDATA[In the previous post a member made a great comment suggesting the use of an existing structure for subdivision of space (also covered slightly in the previous post). The suggestion was the use of either a quadtree or an octree which are both very similar. I am the first to admit my knowledge of both [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.mpqnav.com/2008/06/29/whats-that-im-eating-looks-like-a-foot/"  target="_blank">previous post</a> a member made a great comment suggesting the use of an existing structure for subdivision of space (also covered slightly in the previous post). The suggestion was the use of either a quadtree or an octree which are both very similar. I am the first to admit my knowledge of both is actually quite limited (or rather it was) which is why I went ahead and started reading up before I got too far into my own methods of subdividing the space. Upon further review I think a quadtree will truly work best for what I am trying to do.</p>
<p>Most of the following information is from <a href="http://www.gamedev.net/reference/programming/features/quadtrees/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.gamedev.net');" target="_blank">GameDev.net</a> which has tons of amazing articles / how-to&#8217;s / etc&#8230; on everything gaming related. Here&#8217;s the quick and dirty on what a quadtree is an how it&#8217;s going to help speed things up. First let&#8217;s look at my laughable 1 minute drawing of RedRidge in Photoshop:</p>
<p>&nbsp;</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/06/lolredridge1.gif"  rel="lightbox[148]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="240" alt="lolredridge1" src="http://www.mpqnav.com/wp-content/uploads/2008/06/lolredridge1-thumb.gif" width="240" border="0"></a> </p>
<p><span id="more-148"></span>
<p>&nbsp;</p>
<p>It&#8217;s not perfect but you get the idea. Green = land, blue = water, yellow = WMO, and red = M2. Make sense? I hope so, because it doesn&#8217;t get any easier from here.</p>
<p>Now a quick count shows that we have 16 M2&#8217;s in our scene and 3 WMO&#8217;s for a total of 19 objects (actual number in game is roughly 300 total for this map tile). So let&#8217;s say we wanted to see if our character hit anything at a certain spot in the scene:</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/06/lolredridge2.gif"  rel="lightbox[148]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="240" alt="lolredridge2" src="http://www.mpqnav.com/wp-content/uploads/2008/06/lolredridge2-thumb.gif" width="240" border="0"></a> </p>
<p>The white dot is our player (isn&#8217;t she pretty). Now currently what would happen is we&#8217;d test to see if that box (the player) intersected with any of the other objects in the scene. After it ran through we&#8217;d get the answer that it didn&#8217;t. That works just fine, but we can speed it up! Let&#8217;s take this map tile and divide it into 4 sections:</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/06/lolredridge3.gif"  rel="lightbox[148]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="240" alt="lolredridge3" src="http://www.mpqnav.com/wp-content/uploads/2008/06/lolredridge3-thumb.gif" width="240" border="0"></a> </p>
<p>Now what we would do is first find out what quadrant our toon is in, and then test the toon against only the obstacles that exist within that quadrant. In this case the toon is in the top-left quadrant and there&#8217;s 6 items (3 WMOs and 3 M2s) that we would test against.</p>
<p>6 instead of 19 means our test should run 69% faster assuming that all tests cost the same amount of time (which should be true in an OBB OBB intersection test). What if we were to take this further though?</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/06/lolredridge4.gif"  rel="lightbox[148]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="240" alt="lolredridge4" src="http://www.mpqnav.com/wp-content/uploads/2008/06/lolredridge4-thumb.gif" width="240" border="0"></a> </p>
<p>Now the thought process goes like this:</p>
<ol>
<li>Find the quadrant (of the 4 large ones) the character is in -&gt; Top Left</li>
<li>Do not test in any remaining quadrants</li>
<li>If that quadrant has children (sub-quadrants) find out which one of those the toon is in -&gt; Bottom Left Sub-Quadrant</li>
<li>Do not test any of the other quadrants</li>
<li>Repeat until we have no more sub-quadrants.</li>
</ol>
<p>In this case we would only test against 2 WMOs instead of the 19 total objects, which should take 1/10th of the time or so.</p>
<p>You can subdivide as small as you want without giving up too much speed due to the way a Quad-Tree is stored. Here&#8217;s my pretty Photoshop representation:</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/06/quad1.gif"  rel="lightbox[148]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="440" alt="quad1" src="http://www.mpqnav.com/wp-content/uploads/2008/06/quad1-thumb.gif" width="500" border="0"></a> </p>
<p>So say our toon was in 1.4 :</p>
<p><a href="http://www.mpqnav.com/wp-content/uploads/2008/06/quad2.gif"  rel="lightbox[148]"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="440" alt="quad2" src="http://www.mpqnav.com/wp-content/uploads/2008/06/quad2-thumb.gif" width="500" border="0"></a> </p>
<p>See how much data we can ignore? See how that would speed things up quite a bit?</p>
<p>Well I hope this has helped some!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mpqnav.com/2008/06/30/quadtrees-youre-doing-it-wrong/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
