<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>jet.ro</title>
	
	<link>http://jet.ro</link>
	<description>designer/programmer tidbits</description>
	<lastBuildDate>Fri, 16 Dec 2011 21:42:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/jetro" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="jetro" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Scanline</title>
		<link>http://jet.ro/2011/12/16/scanline/</link>
		<comments>http://jet.ro/2011/12/16/scanline/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 20:24:42 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Visuals]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=1058</guid>
		<description><![CDATA[Scanline - 1D demo for AltParty 2011.]]></description>
			<content:encoded><![CDATA[<p>Back in October, we wanted to attend the forthcoming <a href="http://www.altparty.org/2011/" title="AltParty2011" target="_blank">Alternative Party</a> event. I think one could say it is a <a href="http://en.wikipedia.org/wiki/Demoscene" target="_blank">demoscene</a> event, but with a broader or different scope or goals &#8211; for example, encouraging or embracing artistic expression with niche platforms (either niche by being rare, or niche by being so old).</p>
<p>So, we thought about taking part in the alternative demo competition. The platform is mostly free choice there, but the compo name itself directs you to think about something different. I thought that maybe it could be interesting to make a demo which would consist of only a single static line with changing colors, and try to take most of that limitation. That is, to make a &#8220;1-Dimensional Demo&#8221; (at least by my definition).<br />
<span id="more-1058"></span></p>
<p>Early on I decided there is no need to try showing technical mastery with such a hard limitation, and decided that it is enough to just make a vertically big image and small amount code which shows that image one line at a time, until the image ends. I made a few effect prototypes with Photoshop, synced to music by checking music positions in milliseconds and converting those to Y-pixel coordinates in the image, after deciding on a frame rate.</p>
<p>It became clear that there should be a good piece of music to go with the effects, because good audio can add so much more to the experience. I asked my friend <a href="http://iki.fi/cube/" title="!Cube" target="_blank">!Cube</a> if he could make up a composition starting with some piano playing, since I thought it could make a nice start to show just white bars on black background, flashing with colors synced to the piano.</p>
<p>To get beyond my tests (still accompanied by my own music), I asked <a href="http://iki.fi/ase/" title="stRana" target="_blank">stRana</a> to help me with the actual production and design. That and just a few days later, most of the pieces started coming together, and we ended up finishing it nicely in time, a day or two before the event started.</p>
<p>For the tech part, I actually just expanded on my first proto tests a bit more. The production is built with <a href="http://processing.org" title="Processing" target="_blank">Processing</a>. It was mostly fine for the task, except that using the accompanying &#8220;minim&#8221; library for audio playing didn&#8217;t seem to be a perfect choice. I&#8217;m not sure of the contributing factors, but it seems the audio latency varies by computer and maybe even some times on the same computer. It didn&#8217;t seem to help much to ask for playing position from the audio system, since that seemed to be a too granular value not really telling where the actual audio play &#8220;head&#8221; is going. But, I didn&#8217;t want to rewrite the whole production just to fix this thing since it worked fine otherwise.</p>
<p>In the end we did really fine; <em>Scanline</em> by Rustbloom ended up winning the Alternative Demo competition. The weird thing is that the prizes in Alternative Party are usually strange obsolete leftover stuff donated by companies; we got two huge rack-mountable servers which were probably really good in their heyday, back in 2003. :) But we also got a bit of actual money on top of that (yay!).</p>
<p>You can download the executable version here: (.zip)<br />
<a href="http://jet.ro/files/Scanline_Demo1D.zip"><b>Download for Windows &amp; Mac OS X</b></a> (hint: source code is also there if you look for a source/ folder)</p>
<p>Or just watch it from the YouTube right here:<br />
<iframe width="640" height="360" src="http://www.youtube.com/embed/1TTxO-WEnak" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2011/12/16/scanline/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Join Google+</title>
		<link>http://jet.ro/2011/12/12/join-google/</link>
		<comments>http://jet.ro/2011/12/12/join-google/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 19:41:32 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Misc.]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=1051</guid>
		<description><![CDATA[Follow me in Google+ for more frequent updates: http://google.com/profiles/jlauha]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always thought that updating stuff to my homepage/blog feels a bit too much hassle, so I don&#8217;t want to do that very often. Strangely, even switching away from home-made kludges to WordPress didn&#8217;t help the feeling in a dramatic way, although it surely helped a little bit.</p>
<p>That&#8217;s why this page has always been subject to relatively long pauses without updates, even if I have felt like I&#8217;d like to share something. Thinking about alternative solutions, the social media websites, I&#8217;ve had a Facebook and <a href="http://twitter.com/jlauha" title="@jlauha" target="_blank">Twitter</a> account for quite a while now. I have always felt that Facebook suits best for personal friends and not for public stuff. Twitter is ok for public stuff, but the 140 char limit means that you&#8217;ll share only some tiny things, like a little anecdote or just a link to somewhere.</p>
<p>When <a href="http://plus.google.com" title="Google+" target="_blank">Google+</a> came around, I started using it as well. By nature it is like a combination of good things from both Facebook and Twitter, and seems to fit my usage patterns quite well. It allows really easily to select per-post who I&#8217;m sharing it with. It doesn&#8217;t limit me to short posts when I want to say a little more. Each post is automatically a discussion thread, and since it isn&#8217;t hosted by me, I have less to worry about approving posts / preventing spam entries.</p>
<p>So I realized I tend to write there a bit more often &#8211; the smaller things, findings and even some more light-hearted observations go there. So, if you want to follow smaller updates from me, join Google+ if you aren&#8217;t yet there and <a href="http://google.com/profiles/jlauha" title="+Jetro Lauha" target="_blank">add me to your circles</a>. Today, I was originally going to write about my latest findings regarding prototyping with Processing (again), but decided I probably do that in my Google+ stream later and write this endorsement post here instead! ;-D</p>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2011/12/12/join-google/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Assembly and Evoke 2011</title>
		<link>http://jet.ro/2011/10/04/assembly-and-evoke-2011/</link>
		<comments>http://jet.ro/2011/10/04/assembly-and-evoke-2011/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 15:56:42 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Visuals]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=1028</guid>
		<description><![CDATA[Demo and two 4 KB intros for demoscene events held in August 2011.]]></description>
			<content:encoded><![CDATA[<p>Writing a bit late about this, but in August I attended the <a href="http://www.assembly.org/summer11/" target="_new">Assembly 2011</a> event, as well as had the chance to visit <a href="http://www.evoke.eu/2011/" target="_new">Evoke 2011</a> in Cologne soon after that. I was actually going to GDC Europe and Gamescom events, but the Evoke luckily happened to be held just on the previous weekend in the same city.</p>
<p>As usual, I spent a little bit of time to make some entries to the event competitions. Read on for videos and a bit of info.<br />
<span id="more-1028"></span></p>
<p>&#8211;<br />
Together with <a href="http://iki.fi/ase/" target="_new">stRana</a> we created <em>Grandma</em> by Rustbloom, for the Assembly 2011 event&#8217;s demo competition. It is an experiment of using Autodesk <a href="http://labs.autodesk.com/utilities/photo_scene_editor/" target="_new">Photo Scene Editor</a> to author content for real-time use, with only a minimal amount of tech to get the thing up and running. I made a simple custom editor which made it possible to move and orient the objects, and create &#038; synchronize camera tracks to put together the demo. For music we used an antique phonograph recording from 1910&#8242;s, now in public domain, featuring Adele Rowland singing about Granny.<br />
Grandma even ended up taking the 5th place in the demo competition, which was a very nice surprise. I guess it had unique enough style to stand out from the other entries.<br />
<a href="http://jet.ro/files/Grandma.zip">Click here to download</a> the executable version for Windows, or watch the video below.<br />
<iframe width="560" height="315" src="http://www.youtube.com/embed/s6CRKKdLP94" frameborder="0" allowfullscreen></iframe></p>
<p>&#8211;<br />
I also helped out <a href="http://xmunkki.org" target="_new">XMunkki</a> to create a little humorous entry for the Assembly event&#8217;s 4 KB intro competition, <em>Nelej&auml;n Kilon Nakki</em> by XZM &amp; tAAt. Technology-wise it interestingly the 2D effects in the production are actually running inside a complex pixel shader written by XMunkki. I mostly tweaked some of the visuals/movements and created the audio track using <a href="http://4klang.untergrund.net/" target="_new">4klang</a>.<br />
<a href="http://jet.ro/files/4kNakki.zip">Click here to download</a> the executable version for Windows, or watch the video below.<br />
<iframe width="560" height="315" src="http://www.youtube.com/embed/z9fyaic_alY" frameborder="0" allowfullscreen></iframe></p>
<p>&#8211;<br />
For the Evoke 2011 event I also took part in the 4 KB intro compo, with <em>Excess Geometry &#8211; Ylij&auml;&auml;m&auml;geometria</em> by <a href="http://tAAt.fi" target="_new">tAAt</a> 2011. This production was an experiment which started with the thought &#8220;what if I precalculate a big static bunch of vertex positions, and make a production which only shows a sliding window of those vertices&#8221;. That is, the effect code basically boils down to: <tt>glDrawArrays(GL_POINTS, array_pos_in_time, 50000);</tt>. Since the demo features a planar ground as a context to show other objects, it actually has to be &#8220;refreshed&#8221; all the time by re-inserting more vertices to the plane. So, the silly design choices largely dictate what kind of things are featured.<br />
<a href="http://jet.ro/files/excessgeometry.zip">Click here to download</a> the executable version for Windows, or watch the video below.<br />
<iframe width="560" height="315" src="http://www.youtube.com/embed/Y-qvx0Ru_Gc" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2011/10/04/assembly-and-evoke-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stair Dismount™ for Android™</title>
		<link>http://jet.ro/2011/06/09/stair-dismount-for-android/</link>
		<comments>http://jet.ro/2011/06/09/stair-dismount-for-android/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 20:19:04 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=1018</guid>
		<description><![CDATA[Stair Dismount for Android]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://secretexit.com" target="_new">Secret Exit</a> we just released the recreation of <em>Stair Dismount</em>&trade; for Android&trade; phones. As you can see from the video below, we&#8217;ve been pretty busy by releasing updates for it every few weeks, adding extra ragdolls and levels to play with. The game itself is free, and part of the extra content is offered against a modest payment.</p>
<p><span id="more-1018"></span></p>
<p>Here&#8217;s the 2011 promotional trailer for the game:<br />
<iframe width="425" height="349" src="http://www.youtube.com/embed/lSVaWn_L6V8" frameborder="0" allowfullscreen></iframe></p>
<p>The game is free, with option to purchase extra levels and ragdolls. Go get it from the <a href="http://bit.ly/Jh-SD-Android" target="_new"><b>Android Market</b></a> now! And tell your friends. :)</p>
<p>Or check out more info about the game from <a href="http://www.stairdismount.com" target="_new">www.StairDismount.com</a>. (Just in case you have missed it before, it&#8217;s also available for iPhone, iPod touch and iPad.)</p>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2011/06/09/stair-dismount-for-android/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Better looking anti-aliased lines with simple trick</title>
		<link>http://jet.ro/2011/06/04/better-looking-anti-aliased-lines-with-simple-trick/</link>
		<comments>http://jet.ro/2011/06/04/better-looking-anti-aliased-lines-with-simple-trick/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 11:00:45 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Visuals]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=999</guid>
		<description><![CDATA[Low-tech and simple solution for rendering hardware accelerated gamma-correct anti-aliased lines.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s some notes about anti-aliased lines.<br />
For these tests of rendering anti-aliased lines my goals were roughly as follows:</p>
<ul>
<li>relatively high-quality anti-aliased lines (better than subsampling or postprocessing)</li>
<li>simple low-tech solution extendable to wide range of platforms (e.g. not relying on availability  of shaders)</li>
<li>visually better consistency than what you get if you just ask graphics API to anti-alias lines for you, and you might not even get any if the hardware is lacking</li>
<li>try to solve issue of anti-aliased lines showing a &#8220;roping&#8221; effect</li>
<li>concentrate on case of single lines without yet going to additional complexities such as line caps or joins between multiple lines</li>
</ul>
<p><span id="more-999"></span><br />
I set to test out stuff with <a href="http://www.processing.org" target="_new">Processing</a>, and decided first to do a comparison of what anti-aliased lines look by default in it. Here&#8217;s an animation showing my simple test pattern with P2D, P3D and JAVA2D renderers:<br />
<img src="http://jet.ro/wp-content/uploads/2011/06/AA_comparison_anim.gif" alt="" title="AA comparison anim, defaults from Processing" width="220" height="130" class="alignnone size-full wp-image-1003" /><br />
As you can see, the results vary a bit, which is no surprise since those different renderers surely have differing precision/performance goals or just a different way to render the lines. For lines close to perfectly horizontal/vertical lines they&#8217;re pretty similar, showing clearly the &#8220;roping&#8221; effect I mentioned above. For lines close to 45 degree angles the JAVA2D renderer seems to look a bit better.</p>
<p>So, to move forward, here&#8217;s a magnified illustration of the technique how I&#8217;m drawing lines using two quads having a gradient going from 100% in center to 0% towards edge. In actual rendering that gradient ramp is done in alpha channel, but for these example images I&#8217;m using green background and a ramp from white to black to show more clearly what&#8217;s being done.<br />
<img src="http://jet.ro/wp-content/uploads/2011/06/quads_illustration_1pix_fins.png" alt="" title="quads_illustration_1pix_fins" width="340" height="170" class="alignnone size-full wp-image-1001" /><br />
I&#8217;m basically just building on top of somebody else&#8217;s basic idea about how to render hardware accelerated lines by constructing polygons with gradient fins yourself instead of using a call to draw line primitives. I don&#8217;t know whose idea this is originally, having heard this a few times from different sources, but to fully research this subject you&#8217;d need to go back 30 years or so (check the short list of related links at end of this post).</p>
<p>When you use this technique to draw a line with &#8220;1 pix&#8221; thickness (although the fins cover total of 2 pixels), it yields pretty identical result with what you see in the above examples from Processing&#8217;s P2D/P3D/JAVA2D renderers. Well, not quite &#8211; for some reason, it actually depends a bit on the hardware. On low-end Intel GMA950 that statement of looking the same holds true. When I try that on my desktop PC with nVidia video card, the lines actually look much better (slightly fatter but without the roping). I found this out only later though, since I did all of my initial tests about this on a mini laptop which has the GMA950. :)</p>
<p>When the roping issue of anti-aliased lines is discussed, I have noticed that often somebody knowledgeable enough says it&#8217;s actually a gamma issue. The problem here being of course the fact that there are many ways to tackle the gamma thing, where none of them are a silver bullet solution which wouldn&#8217;t bring a host of other problems with it.</p>
<p>I got the idea that I could modify the above technique to draw two 0.5 unit wide fins per side, and apply gamma correction at the halfway. This would be still very simple and low-tech way to draw gamma corrected lines.</p>
<p>So here&#8217;s an illustration of what&#8217;s modified compared to the previous example:<br />
<img src="http://jet.ro/wp-content/uploads/2011/06/quads_illustration_halfpix_gamma.png" alt="" title="AA lines with half-way gamma corrected gradient fins" width="340" height="170" class="alignnone size-full wp-image-1005" /></p>
<p>The magic value of 0.72974 comes from 0.5^(1/2.2), assuming that your display gamma is 2.2. I also tried 0.707107 which comes from 0.5^(1/2), which is equal to sqrt(0.5), i.e. a good approximation which is &#8220;close enough&#8221; if you want to simplify the equation. Here is an animation showing the differences with no gamma correction, and then gamma correction with values of 2 and 2.2:<br />
<img src="http://jet.ro/wp-content/uploads/2011/06/AA_comparison_custom_lines_anim.gif" alt="" title="AA gamma comparison anim, half-way gamma corrected fins" width="220" height="130" class="alignnone size-full wp-image-1007" /></p>
<p>As I said above, the &#8220;no gamma&#8221; case looks very close to the gamma corrected one on different hardware, but the gamma 2.2 corrected case looks identical on the few machines I tried this on. I&#8217;m not sure what&#8217;s going on with that, hopefully somebody can explain it to me. I don&#8217;t have any explicitly enabled &#8220;gamma correction&#8221; features from drivers.</p>
<p>A few observations from the images. With the above technique even the perfectly horizontal and vertical lines get a small halo to nearby pixels. What&#8217;s good though is that the perceived brightness stays same very well regardless of line angle.</p>
<p>Perhaps one of the most annoying side effects of this technique is the fact that now the lines look fatter than normal 1 pix wide lines. I have done a few tests of reducing the fin width and/or decreasing the brightness. You can&#8217;t reduce the fin width much without the result quickly getting ugly, but decreasing just the brightness doesn&#8217;t really make the line look much thinner, it looks just darker. I don&#8217;t know what would be the optimal way, but I think maybe it involves a combination of both to some extent. Here&#8217;s one test image where I have reduced the fin width slightly as well as the brightness:<br />
<img src="http://jet.ro/wp-content/uploads/2011/06/ogl_custom_aa_lines_CUSTOM_GAMMA22_darker.png" alt="" title="example of trying to reduce line width with the gamma correction" width="220" height="130" class="alignnone size-full wp-image-1008" /><br />
I think a bit of the roping effect has crawled back in, but the perceived brightness between angles is pretty much ok.</p>
<p><a href="http://jet.ro/files/ogl_custom_aa_lines.pde">Here&#8217;s test code</a>, runnable inside <a href="http://www.processing.org" target="_new">Processing</a>. What&#8217;s additionally not visible in the example images above is the fact that the default renderers clamp coordinates to integers, while this method allows you to draw lines with perfect sub-pixel precision. The test code is modified to offset the lines by time slowly so you can see that in action. If you want to try the regular lines reference test case, replace the renderer in initial size() call to P2D/P3D/JAVA2D, and replace the call to testAALines(&#8230;) in draw() with the commented call to testLines(&#8230;).</p>
<p>Related links:</p>
<ul>
<li><a href="http://portal.acm.org/citation.cfm?id=357309" target="_new">Anti-Aliasing Through the Use of Coordinate Transformations</a> (K. Turkowski, 1982).
<li><a href="http://www.hpl.hp.com/techreports/Compaq-DEC/WRL-98-2.pdf" target="_new">Prefiltered Antialiased Lines Using Half-Plane Distance Functions</a>
<li><a href="http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter22.html">GPU Gems 2 chapter 22: Fast Prefiltered Lines</a></li>
<li><a href="http://homepage.mac.com/arekkusu/bugs/invariance/TexAA.html" target="_new">OpenGL Invariance: Texture AA</a> (with glAArg library)</li>
</ul>
<p>Additional credits/thanks: I think I learned first time about using simple gradient instead of other tricks (like textures) from <a href="http://digestingduck.blogspot.com" target="_new">Mikko Mononen</a>. <a href="http://www.harveycartel.org/raigan/" target="_new">Raigan Burns</a> noted that the line being a bit fat and &#8220;bleeding&#8221; into adjacent pixels is actually a feature, since that way the lines actually look a lot better in motion. Alex May told me that most of <a href="http://www.eufloria-game.com" target="_new">Eufloria</a> game&#8217;s drawing works like this, except for using texture for drawing the lines and having a bunch of textures with different gradients to get different visuals. The gradients are circular and lines are drawn using a cross section of the texture, with rest of the texture used to make caps for round-ended lines.</p>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2011/06/04/better-looking-anti-aliased-lines-with-simple-trick/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LD20: Guinea Pig Warrior</title>
		<link>http://jet.ro/2011/06/01/ld20-guinea-pig-warrior/</link>
		<comments>http://jet.ro/2011/06/01/ld20-guinea-pig-warrior/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 18:56:50 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=994</guid>
		<description><![CDATA[20th Ludum Dare contest was held a few weeks ago. The given theme was &#8220;It’s Dangerous to go Alone! Take this!&#8221;. I created a little platformer where the player character has a temporal projection sidekick. Check out Guinea Pig Warrior.]]></description>
			<content:encoded><![CDATA[<p><img src="http://jet.ro/wp-content/uploads/2011/06/guineapigwarrior-thumb.png" alt="" title="Mini preview image" width="260" height="152" class="alignright size-full wp-image-991" /></p>
<p>20th <a href="http://www.ludumdare.com/" target="_new">Ludum Dare</a> contest was held a few weeks ago. The given theme was &#8220;It’s Dangerous to go Alone! Take this!&#8221;. I created a little platformer where the player character has a temporal projection sidekick. Check out <a href="http://jet.ro/games/prototypes/guinea-pig-warrior/" target="_top">Guinea Pig Warrior</a>.</p>
<div class="cb"></div>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2011/06/01/ld20-guinea-pig-warrior/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LD19: Drill Warrior</title>
		<link>http://jet.ro/2011/03/05/ld19-drill-warrior/</link>
		<comments>http://jet.ro/2011/03/05/ld19-drill-warrior/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 20:33:25 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=982</guid>
		<description><![CDATA[19th Ludum Dare contest was held already back in December. Since I managed to make an entry this time, I figured out I could post about it before the next one is held, which will be probably next month. The theme was &#8220;Discovery&#8221;. Description, downloadable Windows build and source code of my game Drill Warrior [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://jet.ro/wp-content/uploads/2011/03/drillwarrior-thumb.jpg" alt="" title="drillwarrior-thumb" width="260" height="152" class="alignright size-full wp-image-979" /></p>
<p>19th <a href="http://www.ludumdare.com/" target="_new">Ludum Dare</a> contest was held already back in December. Since I managed to make an entry this time, I figured out I could post about it before the next one is held, which will be probably next month.</p>
<p>The theme was &#8220;Discovery&#8221;. Description, downloadable Windows build and source code of my game <em>Drill Warrior</em> can be downloaded from the <a href="/games/prototypes/drill-warrior/">separate page about the game</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2011/03/05/ld19-drill-warrior/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Assembly 2010</title>
		<link>http://jet.ro/2010/08/10/assembly-2010/</link>
		<comments>http://jet.ro/2010/08/10/assembly-2010/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 15:00:52 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Visuals]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=936</guid>
		<description><![CDATA[Highlights from Assembly 2010 event]]></description>
			<content:encoded><![CDATA[<p><img src="http://jet.ro/wp-content/uploads/2010/08/afrika4k_pms.png" alt="" title="Afrika" width="160" height="90" class="alignright size-full wp-image-937" /><br />
The Assembly 2010 summer event was held last weekend. Once again I did something to contribute in the various competitions held at the event. At right you can see thumbnail from <a href="/visuals/4k-intros/afrika/"><em>Afrika</em></a> by Rustbloom &#038; XZM. It&#8217;s our try at making a 4 KB intro with semi-abstract/stylized 2D vector graphics and bit of a story. Yes, the executable is only 4089 bytes long (0.004 megabytes). Check it out from <a href="http://www.youtube.com/watch?v=9-MUyEXKq0w" target="_new">Youtube</a>, or download the original <a href="/files/Afrika4k.zip">executable version</a> (only for Windows). The intro ended up at 5th place of 16 entries, which isn&#8217;t bad at all.</p>
<div class="cb"></div>
<p><img src="http://jet.ro/wp-content/uploads/2010/08/haypole-title-pms.png" alt="" title="Organic hay pole peg throwing" width="160" height="90" class="alignright size-full wp-image-938" /><br />
Some time before the event I also spent a moment to wade through Box2D physics engine documentation, and made a little <a href="/games/prototypes/">prototype game</a> called <a href="/games/prototypes/luomuheinaseipaantapinheitto/"><em>Luomuheinäseipääntapinheitto</em></a> (a.k.a. <em>Organic hay pole peg throwing</em>), entering it also to the gamedev contest (placed 8/19). Background music is Test Drive by <a href="http://ccmixter.org/people/Zapac" target="_new">Zapac</a>. Check out a video from <a href="http://www.youtube.com/watch?v=FsCbeaTLfJg">Youtube</a>, or <a href="/files/haypole_v101.zip">download and try it</a> (only for Windows). </p>
<div class="cb"></div>
<p>Here&#8217;s links (mostly Youtube) to some other highlights from the event: <a href="http://xmunkki.org/wiki/doku.php?id=projects:rayaracer" target="_new">XMunkki&#8217;s gamedev entry Raya Racer for N900</a>, <a href="http://www.simppa.fi/asm10/spiralout/" target="_new">Evoflash&#8217;s winner Flash demo</a> from wild compo, <a href="http://www.youtube.com/user/AssemblyTV#p/search/0/rl2KHwhIMTk" target="_new">Archee&#8217;s 4k intro</a> with physics and AI, <a href="http://www.youtube.com/user/AssemblyTV#p/search/0/5Ns8qg9GlLw" target="_new">winner 4k</a>, <a href="http://www.youtube.com/user/AssemblyTV#p/search/0/rUZYCQNg3BY" target="_new">Pier</a> 64k from Hedelmae, <a href="http://www.youtube.com/user/AssemblyTV#p/search/0/4mHZMPSeKQA" target="_new">Tricky truck</a> &#8211; Archee&#8217;s winner entry from gamedev, 64k intro compo <a href="http://www.youtube.com/watch?v=21qJJbspo_s" target="_new">1st</a> and <a href="http://www.youtube.com/watch?v=-9nDsK6SLs4" target="_new">2nd</a>, <a href="http://capped.tv/cncd_fairlight-ceasefire_all_falls_down" target="_new">Fairlight&#8217;s demo</a> (2nd in compo), and finally <a href="http://www.youtube.com/watch?v=SQngoCBvq3Q" target="_new">ASD&#8217;s winning demo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2010/08/10/assembly-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Various ways to backup</title>
		<link>http://jet.ro/2010/07/04/various-ways-to-backup/</link>
		<comments>http://jet.ro/2010/07/04/various-ways-to-backup/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 12:57:54 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Misc.]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=917</guid>
		<description><![CDATA[Over the years I have been using several kinds of solutions to backup stuff. Here&#8217;s a description of the ones I can remember. Many of them focus on being low-cost, simple and straightforward, but are far from a perfect solution in many other ways. A common technique for me has been to just make zip [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years I have been using several kinds of solutions to backup stuff. Here&#8217;s a description of the ones I can remember. Many of them focus on being low-cost, simple and straightforward, but are far from a perfect solution in many other ways.</p>
<p><span id="more-917"></span></p>
<p>A common technique for me has been to just make zip files of whatever I want to backup. Simple snapshots of a project, so I end up with bunch of &#8220;projectname-YYYYMMDD.zip&#8221; files. Or altenatively a common zip of certain folder which gets updated over time. For example, before I moved to using cvs or svn for source code version control, I used a batch file like this to backup all my little coding projects:</p>
<blockquote><p><strong>backup.bat</strong><code><br />
@zip -u -r d:\backup\prog_c * -x *.ilk *.pdb *.idb *.ncb *.opt *.plg *.bsc *.sbr *.pch *.obj *.zip *.dll<br />
</code></p></blockquote>
<p>As you can see, this just updates an existing zip and excludes bunch of unnecessary files which I didn&#8217;t want to keep bloating up the backup zip. A worthy note is that I have usually made sure I have two separate hard disks in a computer and put the backups on the other one from the original data. At some point I also tried to switch to using <a href="http://dar.linux.free.fr/" target="_top">dar</a> instead of the zip files, since it would have had some advantages over the zip files. I didn&#8217;t end up using that for long though.</p>
<p>Like I hinted above, nowadays I&#8217;m using version control for source code, so I don&#8217;t make such zips that frequently anymore. Instead I have made sure that the version control repository gets backed up somehow.</p>
<p>My first solution was to make nightly snapshots of the repository using a script on the server, and then occasionally copy a snapshot file back to my main computer. I used this solution for many years. Below is copy of the backup script I used, which creates a .tar.gz backup file with given prefix from a specified file mask, adding YYYY-MM-DD timestamp to the backup file name, and also keeps only given number of snapshots around cleaning up any older ones.</p>
<blockquote><p><strong>dobackup.sh</strong><code><br />
#!/bin/sh</p>
<p>if [[ ! $1 || ! $2 || ! $3 || ! $4 || ! $5 ]]<br />
then<br />
    echo $0 destdir name execdir mask backups<br />
    echo $'\t'destdir = directory to put backups in<br />
    echo $'\t'name = file prefix name of this backup<br />
    echo $'\t'execdir = directory to run the backup tar command in<br />
    echo $'\t'mask = filemask to give for tar<br />
    echo $'\t'backups = number of backups of name to keep in destdir<br />
    exit<br />
fi</p>
<p>DESTDIR=$1<br />
NAME=$2<br />
EXECDIR=$3<br />
MASK=$4<br />
BACKUPS=$5</p>
<p>DESTFILE=$DESTDIR/$NAME-`date +%F`.tar.gz</p>
<p>cd $EXECDIR<br />
tar zcf $DESTFILE $MASK</p>
<p>EXTRAFILES=$((`ls $DESTDIR/$NAME-* | wc -l` - $BACKUPS))</p>
<p>if [[ $EXTRAFILES > 0 ]]<br />
then<br />
    rm -f `ls -t $DESTDIR/$NAME-* | tail -$EXTRAFILES`<br />
fi<br />
</code></p></blockquote>
<p>I had then another script which called the above one to create backup files from a few places in the system, and was put in a cron job to be run once per night. The backup script looked something like this:</p>
<blockquote><p><strong>allbackups.sh</strong><code><br />
#!/bin/sh<br />
# All automatic nightly backups<br />
cd /home/user/bin<br />
BACKUPDIR=/var/backups/user<br />
umask 007<br />
# /home/share (includes version control repository)<br />
./dobackup.sh $BACKUPDIR share /home share 7<br />
# misc stuff<br />
./dobackup.sh $BACKUPDIR misc /home/user "bin bookmarks.html code" 7<br />
</code>
</p></blockquote>
<p>More recently I have also moved to mirroring stuff over to another computer using rsync. This was something I needed to do to create an off-site remote backup for my workplace&#8217;s version control repository. To do this, I have simply put ssh-keys in place to allow automatic remote ssh login from a certain machine to run rsync over it, and then I have a cron job line like this to update the mirror every night:</p>
<blockquote><p><strong>nightly rsync mirror for cron job file:</strong><code><br />
30 5 * * * /usr/bin/rsync -avz -e ssh user@server:/path/* /backup/mirror/ > /backup/log/last_cron_mirror.txt 2>&#038;1<br />
</code></p></blockquote>
<p>Additionally I&#8217;m also backing up some paths of this web server every now and then using simple tar commands in a script, and the following command to back up a dump of the mysql database:</p>
<blockquote><p><strong>compressed mysql dump, must be run as root:</strong><code><br />
 /usr/bin/mysqldump --defaults-file=/etc/mysql/debian.cnf -A -Q --opt | /bin/bzip2 > ~/db-mysql-`date +%Y%m%d`.sql.bz2<br />
</code></p></blockquote>
<p>Finally, since there are multiple computers in our household, we have also been simply copying manually some files over to a share in another computer to have at least a single duplicate. These days I have also set Windows 7 backup software to maintain a backup of certain folders and system state to a share in my home Linux server. In the past I also sometimes made manually a backup of my Windows XP computer&#8217;s system state using the OS backup tool. Also recently when a brand new hard disk failed for me, I bought another one and after getting the warranty replacement I put the two into a mirrored RAID disk.</p>
<p>I have experienced so many hard disk crashes over time so I have learned to pay at least some attention to backing up the most important stuff, even if I really still tend to be a little bit lazy about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2010/07/04/various-ways-to-backup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Unwrapping Values – nearest next angle from a previous angle</title>
		<link>http://jet.ro/2010/06/29/unwrapping-values-nearest-next-angle-from-a-previous-angle/</link>
		<comments>http://jet.ro/2010/06/29/unwrapping-values-nearest-next-angle-from-a-previous-angle/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 16:30:14 +0000</pubDate>
		<dc:creator>jetro</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://jet.ro/?p=908</guid>
		<description><![CDATA[How to unwrap angle values to find a shortest transition from one angle to another.]]></description>
			<content:encoded><![CDATA[<p>So, assuming you have angles <em>previousAngle</em> and <em>nextAngle</em>, and you want to transition from the first to the second smoothly. If it&#8217;s like from 358 to 2, a simple linear interpolation will awfully go through almost a full circle down from 358 to 2, when a simple four degree transition forward would have been enough, i.e. you should have been going to 362 degrees instead. So, how to figure out what&#8217;s the shortest transition?</p>
<p>I remember hitting against this problem numerous times, always remembering that I have solved it previously but always seem unable to find the previous solution. And I still can&#8217;t just write it out by heart.</p>
<p>Once again I had to solve this, so this time I tried to Google for it (&#8220;angle wrap delta&#8221;), and found out that somebody named Jason S had posted a <a href="http://stackoverflow.com/questions/2500430/calculating-rotation-in-360-deg-situations" target="_new">nice generalization</a> to a related question in <a href="http://stackoverflow.com" target="_new">Stackoverflow.com</a>.</p>
<p>For your convenience, I&#8217;m posting a modified C version of the code here.<br />
<span id="more-908"></span><br />
<code><br />
// Fancy generalization for wrapping below (e.g. for angles).<br />
// Original code found from:<br />
// http://stackoverflow.com/questions/2500430/calculating-rotation-in-360-deg-situations</p>
<p>// symmetric modulo:<br />
// y = smod(x,m) = x+k*m where k is an integer,<br />
// and y is always in the range [-0.5,0.5)*m<br />
static float smod(float x, float m)<br />
{<br />
&nbsp;&nbsp;return x - ((floorf(x / m + 0.5f)) * m);<br />
}</p>
<p>// Unwraps a value, used for e.g. angles.<br />
// Caveat: Doesn't handle negative input values correctly.<br />
// Workaround: Wrap original value prev to [0..range) before applying this.<br />
// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.g.: prev = fmodf(fmodf(prev, range) + range, range);<br />
static float unwrap(float prev, float next, float range)<br />
{<br />
&nbsp;&nbsp;return prev + smod(next - prev, range);<br />
}<br />
</code></p>
<p>There&#8217;s one <strong>caveat</strong>: it doesn&#8217;t seem to work correctly for negative angles. Just now I don&#8217;t have the time now to figure that out. But an easy workaround is to wrap the original angle first with angle=fmodf(fmodf(angle,2*pi)+2*pi,2*pi) and then transition from that angle to the destination. If somebody posts a better version I&#8217;ll update the post. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://jet.ro/2010/06/29/unwrapping-values-nearest-next-angle-from-a-previous-angle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 0.394 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-02-03 20:45:19 --><!-- Compression = gzip -->

