{"id":202,"date":"2006-02-25T11:39:55","date_gmt":"2006-02-25T16:39:55","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=202"},"modified":"2011-04-10T05:44:55","modified_gmt":"2011-04-10T10:44:55","slug":"terrain-source-code","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=202","title":{"rendered":"Terrain: Source Code"},"content":{"rendered":"<table align=right>\n<tr>\n<td><img decoding=\"async\" src=\"http:\/\/www.shamusyoung.com\/twentysidedtale\/images\/terrain31.jpg\"\/><\/td>\n<\/tr>\n<\/table>\n<p>For those of you who expressed interest in the source for the terrain project, I am making it available for download.  Some people suggested I release it under the GPL, but I&#8217;m not going to do anything that formal.  I&#8217;m releasing it under the &#8220;as is&#8221; system, where you take it, study it, use it, and see what you can do with it.  I do request that if you make use of it you give credit.  It&#8217;s your conscience, though.  <\/p>\n<p><a href=\"http:\/\/www.shamusyoung.com\/files\/terrain_source.zip\">Download Terrain Project (4.3mb)<\/a><\/p>\n<p>The project is a Microsoft Visual Studio 6.0 project.  I tried to keep the windows-centric code all in one place to make it easier to port to other platforms, although I&#8217;ve never tried to port anything so I don&#8217;t make any claim as to how easy it would be.  <\/p>\n<p>I know at the very beginning I said this was all new code from scratch, but there are actually a number of helper modules I wrote some time ago that I need to mention.  The gl* files (glVector.cpp, glMatrix, glBbox, etc) has code that I use in ALL my OpenGL projects.  It has stuff for calculating dot products, reflection vectors, manipulating rgba color values, adding vectors together, interpolating values, and a bunch of other stuff that you just <strong>need<\/strong> when working with OpenGL.  I&#8217;m pretty fond of this code.  In a lot of ways I think these are worth a lot more than the terrain engine itself.  This stuff is just key, and every programmer should have these tools on his or her bat-belt.  I could have taken all of these and moved them into a seperate static library, I suppose. That might be a good move if you plan on working with the code for any length of time.  <\/p>\n<p>In regards to the rest of the code, I&#8217;ve tried to add comments and explain things as well as I could.  If you have questions please post them in the comments on this post so I can avoid answering the same questions multiple times. <\/p>\n<p>Also, I&#8217;ve included all of the textures I used in the project, but I should warn you that I got the textures via Google Image Search, so I don&#8217;t know who owns them.  I didn&#8217;t even look.  You ought to replace them if you plan to release the results of your work for the world to see.<\/p>\n<p>For further reading, here are several <a href=\"http:\/\/www.llnl.gov\/CASC\/people\/lindstrom\/lindstrom_pubs.html\">Publications<\/a> by <a href=\"http:\/\/www.llnl.gov\/CASC\/people\/lindstrom\/\">Peter Lindstrom<\/a>, who (as far as I can tell) is the one who came up with the triangulation technique I allude to in <a href=\"?p=142\">Terrain  Part 2 <\/a>.  The one I read is the third from the top, &#8220;Terrain Simplification Simplified&#8221;.  If you read the article (beware, it can be a bit heavy) you&#8217;ll see a lot of it focuses on terrain which is optimized every frame.  This is different from my system, where I spend many frames on a single set of terrain polygons.  Both systems have their merits.  Mine is easier on the CPU, but is less than ideal if you plan to jump from one area of the terrain to another very quickly.  Also, here is <a href=\"http:\/\/nehe.gamedev.net\/\">NeHe OpenGL<\/a>, which is a great site that teaches OpenGL by example, with lots of tutorials and miles of source code.    <\/p>\n<p>And just to show that lots of people are into this sort of thing, here are some other more ambitious terrain projects: <\/p>\n<p><a href=\"http:\/\/tulrich.com\/geekstuff\/chunklod.html\">Chunked LOD<\/a><br \/>\n<a href=\"http:\/\/www.vterrain.org\/\">Virtual Terrain Project<\/a><\/p>\n<p>(Hat tip: <a href=\"http:\/\/www.metafilter.com\/mefi\/49459\">This MeFi thread<\/a>)  <\/p>\n<p>Good luck.  I hope it&#8217;s useful to you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For those of you who expressed interest in the source for the terrain project, I am making it available for download. Some people suggested I release it under the GPL, but I&#8217;m not going to do anything that formal. I&#8217;m releasing it under the &#8220;as is&#8221; system, where you take it, study it, use it, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-202","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=202"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/202\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}