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

<channel>
	<title>peter nitsch.net</title>
	<atom:link href="http://www.peternitsch.net/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.peternitsch.net/blog</link>
	<description></description>
	<lastBuildDate>Mon, 16 Aug 2010 21:14:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Javascript demo competitions</title>
		<link>http://www.peternitsch.net/blog/?p=796</link>
		<comments>http://www.peternitsch.net/blog/?p=796#comments</comments>
		<pubDate>Mon, 16 Aug 2010 15:03:59 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JS1k]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=796</guid>
		<description><![CDATA[I&#8217;ll admit to being one of those people that, until recently, considered Javascript to be substandard and barely a &#8220;real&#8221; programming language. My opinion began to shift with the rapid advancement of JS engines like V8 and introduction of powerful HTML5 API&#8217;s like Canvas and WebGL. I find myself playing more and more in JS [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://js1k.com/demo/369"><img alt="" src="http://www.peternitsch.net/images/js1k.jpg" title="JS1k entry" class="alignnone" /></a></p>
<p>I&#8217;ll admit to being one of those people that, until recently, considered Javascript to be substandard and barely a &#8220;real&#8221; programming language. My opinion began to shift with the rapid advancement of JS engines like <a href="http://code.google.com/p/v8/">V8</a> and introduction of powerful HTML5 API&#8217;s like Canvas and WebGL. I find myself playing more and more in JS and utilizing my Java/AS knowledge to build experiments. Recently, there has been quite a bit of buzz surrounding Javascript size competitions like <a href="http://js1k.com/home">JS1k</a> and <a href="http://10k.aneventapart.com/">10K Apart</a>. JS1k alone has <a href="http://js1k.com/demos">hundreds of quality entries</a>. Of course the cynical Flash developer in me wants play down the excitement of these competitions. After all, very similar results have been produced in even stricter Flash contests for years (look at what @piXelero <a href="http://gskinner.com/playpen/tweetcoding_0/tc_1244453541.swf">did in just 140 characters</a>). But we&#8217;re talking about <em>frickin</em> Javascript here, and the new plugin-less API&#8217;s really are something to get excited about, so count me in.</p>
<p>JS1k only allows one entry, so I had to omit earlier attempts. The first was a <a href="http://www.peternitsch.net/demo/js1k/rogue.html">Roguelike game</a> that I couldn&#8217;t compress enough (best result was 1.35k). The second attempt was a <a href="http://www.peternitsch.net/demo/js1k/lorenz.html">3D Lorenz attractor</a> which evolved into my actual submission, a <a href="http://js1k.com/demo/369">3D twisty Sierpinski Gasket</a>. I used several hacks to fit the entry under 1k, but most of the compression was done in Google&#8217;s <a href="http://closure-compiler.appspot.com/home">Closure Compiler</a>.</p>
<p><strong>Update:</strong> I&#8217;ve <a href="http://www.peternitsch.net/demo/gasket/">implemented the gasket in WebGL</a> as an experiment. The result is amazing, with a cloud of over 1 million points (10 iterations) and a much better FPS. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=796</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Exploring a Mandelbox with WebGL</title>
		<link>http://www.peternitsch.net/blog/?p=769</link>
		<comments>http://www.peternitsch.net/blog/?p=769#comments</comments>
		<pubDate>Mon, 26 Jul 2010 15:10:09 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[WebGL]]></category>
		<category><![CDATA[fractals]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=769</guid>
		<description><![CDATA[WebGL Mandelbox Explorer Note: This demo requires a WebGL capable browser. Installation instructions can be found at Learning WebGL or the WebGL Wiki. This weekend I put the finishing touches on a WebGL Mandelbox explorer I&#8217;ve been tinkering with for the past week or so. If you&#8217;re interested in the mathematics, Tom Lowes who wrote [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.peternitsch.net/demo/mandelbox/" target="_blank"><img src="http://www.peternitsch.net/images/box_1.jpg" /></a></p>
<p><a href="http://www.peternitsch.net/demo/mandelbox/" target="_blank">WebGL Mandelbox Explorer</a></p>
<p><em><strong>Note:</strong> This demo requires a WebGL capable browser. Installation instructions can be found at <a href="http://learningwebgl.com/blog/?p=11">Learning WebGL</a> or the <a href="http://www.khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL Wiki</a>.</em></p>
<p>This weekend I put the finishing touches on a WebGL Mandelbox explorer I&#8217;ve been tinkering with for the past week or so. If you&#8217;re interested in the mathematics, Tom Lowes who wrote the <a href="http://en.wikipedia.org/wiki/Mandelbox">Mandelbox formula</a> does a good job explaining it in detail on his <a href="http://sites.google.com/site/mandelbox/what-is-a-mandelbox">site</a>. I&#8217;ve been captivated with the pattern ever since watching Krzysztof Marczak&#8217;s amazing <a href="http://www.youtube.com/watch?v=bO9ugnn8DbE">Mandelbox trip</a> on YouTube (a must-see).  </p>
<p><span id="more-769"></span><img src="http://www.peternitsch.net/images/box_2.jpg" /></p>
<p>Traversing a 3D Mandelbox in real-time is intensive on any platform, but WebGL does a fairly good job thanks to the GPU. I still need to lower the fractal iterations upon interaction, but that was expected. Rrrola was nice enough to <a href="http://www.fractalforums.com/3d-fractal-generation/where-are-the-realtime-gpu-mandelboxeds/">post some source</a> for his <a href="http://www.ms.mff.cuni.cz/~kadlj3am/big/boxplorer/">real-time explorer</a>, which I ported to this version. I&#8217;ll add my own refinements over time as I get more comfortable with the formula. </p>
<p><img src="http://www.peternitsch.net/images/box_3.jpg" /></p>
<p>There is plenty of room for refinement, but basic mouse and keyboard movement controls make exploration fairly simple. Things like camera viewing angles will be patched in over time. </p>
<p><img src="http://www.peternitsch.net/images/box_4.jpg" /></p>
<p>This will be an evolving project. If you stumble upon any bugs or have suggestions, I&#8217;d love to hear them.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=769</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Passing webcam data into WebGL via Flash</title>
		<link>http://www.peternitsch.net/blog/?p=741</link>
		<comments>http://www.peternitsch.net/blog/?p=741#comments</comments>
		<pubDate>Fri, 16 Jul 2010 20:46:30 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=741</guid>
		<description><![CDATA[Note: To view the demos, you will need to have a WebGL capable browser plus the latest Flash Player (with webcam enabled in your Flash settings). I advise people to download Firefox 4.0 beta, enter "about:config" in the address bar, and change "webgl.enabled_for_all_sites" to true. I tend to stay away from the HTML5 vs Flash [...]]]></description>
			<content:encoded><![CDATA[<p><em>Note: To view the demos, you will need to have a WebGL capable browser plus the latest <a href="http://get.adobe.com/flashplayer/">Flash Player</a> (with webcam enabled in your <a href="http://www.macromedia.com/support/documentation/en/flashplayer/help/help04.html">Flash settings</a>). I advise people to download <a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4.0 beta</a>, enter "about:config" in the address bar, and change "webgl.enabled_for_all_sites" to <strong>true</strong>.</em></p>
<p>I tend to stay away from the HTML5 vs Flash "debate", principally because I think it's inane. Both platforms offer certain advantages over the other and some interesting results can be achieved by utilizing their strengths. Case in point, Flash's built-in webcam support and WebGL's hardware-accelerated 3D graphics are features that only exist in their respective platforms (<a href="http://devworks.thinkdigit.com/Internet/Native-webcam-support-to-come-with-HTML5_3834.html">for now</a>). Bridging the technologies produces something unattainable by only using one, as the following quick examples illustrate. </p>
<p><a href="http://www.peternitsch.net/demo/webgl_webcam/index.html" target="_blank"><img src="http://www.peternitsch.net/images/webglcam2.jpg" alt="WebGLcam" /><br />
Simple interactive cube.</a></p>
<p><span id="more-741"></span><a href="http://www.peternitsch.net/demo/webgl_webcam/kaleido.html" target="_blank"><img src="http://www.peternitsch.net/images/webglcam3.jpg" alt="WebGLcam" /><br />
Plane deformation</a> (Kaleidoscope shader by iq ported from <a href="http://www.iquilezles.org/apps/shadertoy/">Shader Toy</a>).</p>
<p><a href="http://www.peternitsch.net/demo/webgl_webcam/raytracer.html" target="_blank"><img src="http://www.peternitsch.net/images/webglcam1.jpg" alt="WebGLcam" /><br />
Raytracing</a> (Kinderpainter by iq ported from <a href="http://www.iquilezles.org/apps/shadertoy/">Shader Toy</a>).</p>
<p><!--more-->Passing webcam data to Javascript involves a few steps. The BitmapData drawn from the Video object needs to be compressed to JPEG and encoded to Base64 for the <a href="http://en.wikipedia.org/wiki/Data_URI_scheme">data URI</a> to read it. This can be a very taxing process in native ActionScript, but is nearly negligible when done in <a href="http://haxe.org/">haXe</a> or <a href="http://labs.adobe.com/technologies/alchemy/">Alchemy</a>. In this case, I'm using both. The JPEG compression is performed by <a href="http://www.websector.de/blog/2009/06/21/speed-up-jpeg-encoding-using-alchemy/">metalbot's Alchemy JPEG encoder</a>, while the Base64 encoding is handled by <a href="http://www.blooddy.by/en/">Bloodhound's haXe crypto library</a>. ExternalInferface passes the resulting string to the WebGL's texture Image source with the following method:</p>
<div class="igBar"><span id="lcode-2"><a href="#" onclick="javascript:showPlainTxt('code-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-2">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">function fromFlash<span style="color:#006600; font-weight:bold;">&#40;</span>event, value<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; texture.<span style="">image</span>.<span style="">src</span> = <span style="color:#CC0000;">"data:image/jpg;base64,"</span>+value;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Not only is it possible for HTML5 and Flash to peacefully coexist, but they can also help each other achieve a result not possible on their own. Kumbaya. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=741</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML5 canvas pixel manipulation</title>
		<link>http://www.peternitsch.net/blog/?p=720</link>
		<comments>http://www.peternitsch.net/blog/?p=720#comments</comments>
		<pubDate>Fri, 14 May 2010 20:47:08 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=720</guid>
		<description><![CDATA[Check it out! view source In an effort to explore some of the emerging interactive development environments, I decided to look at the canvas element at a deeper level. When the tag first debuted, I mucked about with some basic bitmap operations to get a feel for it, but nothing significant. Recently, the modern browsers [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.teehanlax.com/labs/projects/liquidhtml5/" target="_blank"><img src="http://www.peternitsch.net/images/liquidjava.jpg" alt="liquid-javascript" /></a></p>
<p><a href="http://www.teehanlax.com/labs/projects/liquidhtml5/" target="_blank">Check it out!</a><br />
<a href="http://www.teehanlax.com/labs/projects/liquidhtml5/liquid.js" target="_blank">view source</a></p>
<p>In an effort to explore some of the emerging interactive development environments, I decided to look at the <a href="http://dev.w3.org/html5/spec/Overview.html#the-canvas-element">canvas</a> element at a deeper level. When the tag first debuted, I mucked about with some basic bitmap operations to get a feel for it, but nothing significant. Recently, the <a href="http://chrome.blogspot.com/2010/05/pedal-to-chrome-metal-our-fastest-beta.html">modern browsers have begun to demonstrate much faster JS engines</a>, and this warranted a closer look. I'm fortunate enough to know Christopher Emirzian, whom allowed me to port his fantastic <a href="http://rydia.net/udder/art/lp/flock.html" target="_blank">liquidjava</a> experiment. We both thought it'd perform significantly worse than the result. Of course there are still several bugs, but Javascript is proving to be much faster than expected. Perhaps <a href="http://mrdoob.com/blog">Mr.doob</a> is actually onto something!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=720</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Speaking at Notacon 7</title>
		<link>http://www.peternitsch.net/blog/?p=710</link>
		<comments>http://www.peternitsch.net/blog/?p=710#comments</comments>
		<pubDate>Wed, 07 Apr 2010 14:22:06 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[blockparty]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[notacon]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=710</guid>
		<description><![CDATA[If you're in or around Cleveland next weekend stop by Notacon, an annual hacker conference with a creative twist. In their words, it "explores and showcases technologies, philosophy and creativity often overlooked at many hacker cons". I'll be giving a talk about my experimental work in Flash with a focus on Alchemy. Notacon is also [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.peternitsch.net/demo/blockparty/99/" target"_blank"><img src="http://www.peternitsch.net/images/blockparty.jpg" alt="Blockparty Invitation" /></a></p>
<p>If you're in or around Cleveland next weekend stop by <a href="http://www.notacon.org/" target"_blank">Notacon</a>, an annual hacker conference with a creative twist. In their words, it "explores and showcases technologies, philosophy and creativity often overlooked at many hacker cons". I'll be giving a talk about my experimental work in Flash with a focus on <a href="http://labs.adobe.com/technologies/alchemy/" target"_blank">Alchemy</a>. Notacon is also the venue for <a href="http://www.demoparty.us/" target"_blank">Blockparty</a>, a North American demo party organized by <a href="http://ascii.textfiles.com/" target"_blank">Jason Scott</a> and <a href="http://en.wikipedia.org/wiki/RaD Man" target"_blank">Christian Wirth (RaD-Man)</a>. I worked with <a href="http://www.simppa.fi/blog/" target"_blank">Jac</a> from <a href="http://evo.bombsquad.org/" target"_blank">Evoflash</a> and musician <a href="http://coda.s3m.us/" target"_blank">Coda</a> to build this years invitation for the party. Should be a great time!</p>
<p><a href="http://www.peternitsch.net/demo/blockparty/99/" target"_blank">Check out the invitation.</a><br />
<em>Note: All effects are real-time, so this is best viewed using the latest build of <a href="http://labs.adobe.com/technologies/flashplayer10/" target"_blank">Flash Player 10.1</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=710</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASCIImeo, Videos in Text</title>
		<link>http://www.peternitsch.net/blog/?p=675</link>
		<comments>http://www.peternitsch.net/blog/?p=675#comments</comments>
		<pubDate>Mon, 18 Jan 2010 16:57:50 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[asciimeo]]></category>
		<category><![CDATA[textfx7]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=675</guid>
		<description><![CDATA[Today I finally launched ASCIImeo (asciimeo.com), a personal project I've been working on irregularly for the past few months. In a nutshell, it renders Vimeo videos in different textmode's. I hope everyone enjoy's the site; it's simple and generally useless, but a ton of fun to explore. I'd love to hear your feedback, rants, and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.asciimeo.com/"><img src="http://www.peternitsch.net/images/asciimeo_1.jpg" alt="ASCIImeo" /></a></p>
<p>Today I finally launched <a href="http://www.asciimeo.com/">ASCIImeo (asciimeo.com)</a>, a personal project I've been working on irregularly for the past few months. In a nutshell, it renders <a href="http://www.vimeo.com/">Vimeo</a> videos in different textmode's. I hope everyone enjoy's the site; it's simple and generally useless, but a ton of fun to explore. I'd love to hear your feedback, rants, and bug reports (I was after all the only person working on this).</p>
<p><span id="more-675"></span>Here are some of my favorite videos in ASCII:<br />
<a href="http://asciimeo.com/1747316">Metamorphosis by Glenn Marshall</a><br />
<a href="http://asciimeo.com/7936431">MOTOR / AMBIENT REEL by KU-SCHNEIDER</a><br />
<a href="http://asciimeo.com/615344">Magnetic Ink by flight404</a><br />
<a href="http://asciimeo.com/4601855">Still Run by DANTE NOU</a><br />
<a href="http://asciimeo.com/8455331">Look At Me by Patrick Lawler</a></p>
<p><img src="http://www.peternitsch.net/images/asciimeo_2.jpg" alt="Different modes" /></p>
<p>The player is an evolution of earlier video experiments I was doing in Alchemy. Still using Jari Komppa's <a href="http://sol.gfxile.net/textfx/index.html">TextFX7</a> engine for the glyph conversion and <a href="http://code.google.com/p/as3ansi/">AS3ANSI</a> for the rendering, this version features improved speeds and a control UI including fullscreen mode.</p>
<p>When this project was first conceived, I had considered using the Youtube API, but after reading through their <a href="http://code.google.com/apis/youtube/terms.html">TOS</a> that idea quickly vanished (obstructing the video is a violation). Vimeo didn't pose the same problem, and in retrospect, it was a wiser choice considering the greater quality and style of most of their videos. Tying it to Vimeo was straightforward given the ease of their API and liberal cross-domain permissions (truly there is no better online video community). The only real challenge was brushing up on my rusty CSS skills to get the site displaying correctly cross-browser.  </p>
<p><img src="http://www.peternitsch.net/images/asciimeo_3.jpg" alt="Fail!" /></p>
<p>Speaking of challenges, there are still a number of unresolved issues that I hope will be ironed out in the future. The worst one occurs when the player encounters a redirected cross-domain policy file on one of the video servers (specifically vimeo.o4.bitgravity.com). <a href="http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_07.html">Adobe states</a>: "since version 9,0,115,0, however, Flash Player has treated redirected policy files as though they had originated from the final, post-redirect URL". This means there's no way to invoke the BitmapData.draw method for content on the pre-redirect URL without being thrown the dreaded #2122 error (sandbox violation). There's no current workaround. Regardless, this only happens to a small percentage of videos and occasionally their location is shuffled around.</p>
<p>ASCII video players aren't new, they've been developed on countless platforms including Flash (VLC Media Player had an ASCII filter, and even Apple released an <a href="http://developer.apple.com/mac/library/samplecode/ASCIIMoviePlayerSample/index.html">ASCII Quicktime player</a>). With ASCIImeo I really wanted to take advantage of the environment Flash can live in: online, interactive, and social. In the end, I think I've created something new from an old idea. You can be sure I'll be rambling about this at <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=101&#038;presentation_id=1034">FITC</a>. </p>
<p><strong>UPDATE:</strong> Thank you to the many individuals that reported the flakey search results. I've tightened up the calls to the Vimeo API and everything seems to be working well now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=675</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Raytracing Wada basins in Flash</title>
		<link>http://www.peternitsch.net/blog/?p=639</link>
		<comments>http://www.peternitsch.net/blog/?p=639#comments</comments>
		<pubDate>Tue, 22 Dec 2009 15:39:20 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[fractal]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=639</guid>
		<description><![CDATA[Check it out! Source code Getting into the Christmas spirit, I thought I'd play around with raytracing reflective spheres to produce the fractal known as Wada basins. It's an old technique that can be easily reproduced physically by using four mirrored Christmas ornaments stacked in a pyramid. To be honest, the idea came from seeing [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.peternitsch.net/images/wada_1.jpg" alt="Wada basins" /><br />
<a href="http://www.peternitsch.net/demo/wada-basin-raytracer/as3.html" target="_blank">Check it out!</a><br />
<a href="http://www.peternitsch.net/demo/wada-basin-raytracer/as3_raytracer.zip">Source code</a></p>
<p>Getting into the Christmas spirit, I thought I'd play around with raytracing reflective spheres to produce the fractal known as <a href="http://en.wikipedia.org/wiki/Lakes_of_Wada" target="_blank">Wada basins</a>. It's an old technique that can be easily reproduced physically by using four mirrored Christmas ornaments stacked in a pyramid. To be honest, the idea came from seeing the <a href="http://www.flickr.com/photos/unitzeroone/4102372725/" target="blank">mirrorball Ralph picked up</a> to use as a lightmap for <a href="http://www.unitzeroone.com/labs/Triangle3DOld/Alt.html" target="_blank">Triangle3D</a>.</p>
<p><span id="more-639"></span>I bought a set of mirrored ornaments for our tree and set them up in a pyramid:<br />
<img src="http://www.peternitsch.net/images/wada_6.jpg" alt="Ornament pyramid" /></p>
<p>The fractal appears through the center:<br />
<img src="http://www.peternitsch.net/images/wada_7.jpg" alt="Fractal" /></p>
<p>I've been wanting to write a simple raytracer (the <a href="http://www.peternitsch.net/blog/?p=182">Alchemy version</a> I posted a while back was a port of <a href="http://www.superjer.com/pixelmachine/" target="_blank">PixelMachine</a>) in pure AS3 for some time. This experiment marks the first steps towards that goal. You can check out the source code. It'll grow over time as I clean up the structure and add optimizations.</p>
<p>The first AS3 test draws the image line by line to avoid some serious stack overflows. Camera positions, lighting, reflectivity, and other values can easily be changed within <a href="http://www.peternitsch.net/demo/wada-basin-raytracer/as3_raytracer.zip">the source</a>. I'll draft an API over time. The result is a 4K swf:<br />
<a href="http://www.peternitsch.net/demo/wada-basin-raytracer/as3.html" target="_blank"><img src="http://www.peternitsch.net/images/wada_2.jpg" alt="AS3 version" /></a></p>
<p>An Alchemy version of the same logic achieved much faster render speeds (minus the line drawing), but the resultant swf was well over 100k:<br />
<a href="http://www.peternitsch.net/demo/wada-basin-raytracer/alc/" target="_blank"><img src="http://www.peternitsch.net/images/wada_3.jpg" alt="Alchemy version" /></a></p>
<p>An attempt at simple interaction with the Alchemy version:<br />
<a href="http://www.peternitsch.net/demo/wada-basin-raytracer/" target="_blank"><img src="http://www.peternitsch.net/images/wada_5.jpg" alt="Interactive" /></a></p>
<p>1000x1000 pixel render:<br />
<a href="http://www.peternitsch.net/demo/wada-basin-raytracer/1000x1000.png" target="_blank"><img src="http://www.peternitsch.net/images/wada_4.jpg" alt="1000x1000" /></a></p>
<p>The next step will be to write a WebGL version and compare it to the Flash speeds. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=639</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ANSI lives! Viewtronics, Flash Player 10 textmode viewer</title>
		<link>http://www.peternitsch.net/blog/?p=618</link>
		<comments>http://www.peternitsch.net/blog/?p=618#comments</comments>
		<pubDate>Wed, 04 Nov 2009 15:44:37 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[AS3 ANSI]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[ansi art]]></category>
		<category><![CDATA[as3ansi]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[FlashTerm]]></category>
		<category><![CDATA[textmode]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=618</guid>
		<description><![CDATA[Check out Viewtronics! The best things in life are often silly, and in this case gloriously retro. Blocktronics, a collective of the best textmode artists around the world, have released their second art pack entitled "Codename Chris Wirth" in homage to the legendary ANSI artist RaD Man. No, it's not 1995, and yes, this kind [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blocktronics.net/packs/codename-chris-wirth/" target="_blank"><img src="http://www.peternitsch.net/images/vt_1.jpg" alt="Viewtronics" /></a></p>
<p><a href="http://blocktronics.net/packs/codename-chris-wirth/" target="_blank">Check out Viewtronics!</a></p>
<p>The best things in life are often silly, and in this case gloriously retro. <a href="http://blocktronics.net/" target="_blank">Blocktronics</a>, a collective of the best textmode artists around the world, have released their second art pack entitled <a href="http://blocktronics.net/packs/codename-chris-wirth/" target="_blank">"Codename Chris Wirth"</a> in homage to the legendary ANSI artist <a href="http://en.wikipedia.org/wiki/RaD_Man" target="_blank">RaD Man</a>. No, it's not 1995, and yes, this kind of art is still being produced in stunning fashion. </p>
<p>Along with the pack, this marks the debut of a textmode viewer I've been working on for some time called <a href="http://blocktronics.net/packs/codename-chris-wirth/" target="_blank">Viewtronics</a>. The project is a refinement of my <a href="http://code.google.com/p/as3ansi/" target="_blank">AS3ANSI</a> engine which powers <a href="http://www.flashterm.com/" target="_blank">Flashterm</a>, and includes features such as multiple fonts, zooming, and image generation.</p>
<p><span id="more-618"></span>Great job B7! Make sure to check out a special <a href="http://www.fitc.ca/" target="_blank">FITC</a> piece by <a href="http://blocktronics.net/artists/enzo/" target="_blank">enz0</a>:</p>
<p><a href="http://blocktronics.net/packs/codename-chris-wirth/#/zO-FITC.ans" target="_blank"><img src="http://www.peternitsch.net/images/vt_2.jpg" alt="FITC ANSI" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=618</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Exploring texturing and lighting with WebGL</title>
		<link>http://www.peternitsch.net/blog/?p=574</link>
		<comments>http://www.peternitsch.net/blog/?p=574#comments</comments>
		<pubDate>Mon, 12 Oct 2009 13:57:41 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[WebGL]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=574</guid>
		<description><![CDATA[Check it out! NOTE: You'll need to use a Mozilla trunk nightly build (switch webgl.enabled_for_all_sites to true in about:config) or Chrome developer preview version (use "--enable-webgl" and "--no-sandbox" command-line switches). A video is included in this post if you're having trouble installing. After learning the basics of fragment and vertex shaders in my last example [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.peternitsch.net/demo/webgl/ccube.html" target="_blank"><img src="http://www.peternitsch.net/images/webgl_2.jpg" alt="WebGL" /></a></p>
<p><a href="http://www.peternitsch.net/demo/webgl/ccube.html" target="_blank">Check it out!</a></p>
<p><em>NOTE: You'll need to use a <a href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/" target="_blank">Mozilla trunk nightly build</a> (switch <strong>webgl.enabled_for_all_sites</strong> to <strong>true</strong> in <strong>about:config</strong>) or Chrome developer preview version (use "--enable-webgl" and "--no-sandbox" command-line switches). A video is included in this post if you're having trouble installing.</em></p>
<p>After learning the basics of fragment and vertex shaders in my last example and using the <a href="http://people.mozilla.com/~vladimir/webgl/spore/sporeview.html" target="_blank">Spore creature viewer</a> as reference, it was fairly straightforward to implement texturing and lighting. Take a look at the source to see how it was done, and how the positioning matrix has evolved. </p>
<p><span id="more-574"></span>Having limited OpenGL knowledge, the learning experience with WebGL has been very good since it requires JavaScript to supply all the shader parameters. I have some concern with JS being able to handle a more intensive implementation, but further experimentation will expose that. Regardless, I'm loving the current performance results, especially when compared to Flash alternatives. </p>
<p>&nbsp;<br />
<object width='500' height='300'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=7003957&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=7003957&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='500' height='300'></embed></object><br /><a href='http://vimeo.com/7003957'>View on Vimeo</a>.</p>
<p><em>UPDATE: Perspective added to the example. Thank you, Giles.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=574</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Experimenting with WebGL</title>
		<link>http://www.peternitsch.net/blog/?p=500</link>
		<comments>http://www.peternitsch.net/blog/?p=500#comments</comments>
		<pubDate>Fri, 02 Oct 2009 14:57:38 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[WebGL]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=500</guid>
		<description><![CDATA[Check it out! NOTE: To view WebGL, you'll need to use a Mozilla trunk nightly build (starting September 18th). Once installed, switch webgl.enabled_for_all_sites to true in about:config. Your OpenGL drivers will also need to be up-to-date. A video of the experiment is included in this post if you're having trouble installing. A couple weeks ago, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.peternitsch.net/demo/webgl/index.html" target="_blank"><img src="http://www.peternitsch.net/images/webgl_1.jpg" border="0" /></a></p>
<p><a href="http://www.peternitsch.net/demo/webgl/index.html" target="_blank">Check it out!</a></p>
<p><em>NOTE: To view WebGL, you'll need to use a <a href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/" target="_blank">Mozilla trunk nightly build</a> (starting September 18th). Once installed, switch <strong>webgl.enabled_for_all_sites</strong> to <strong>true</strong> in <strong>about:config</strong>. Your OpenGL drivers will also need to be up-to-date. A video of the experiment is included in this post if you're having trouble installing.</em></p>
<p>A couple weeks ago, <a href="http://blog.vlad1.com/2009/09/18/webgl-in-firefox-nightly-builds/" target="_blank">Vladimir Vukicevic</a> posted the <a href="http://people.mozilla.com/~vladimir/webgl/spore/sporeview.html" target="_blank">first working sample</a> of WebGL, which gives us a glimpse of how JavaScript will access OpenGL ES 2.0. Since then, we've seen a number of <a href="http://hacks.mozilla.org/2009/09/three-more-webgl-demos/" target="_blank">impressive demos</a>, and it seems GPU accelerated 3D in the browser is finally becoming a reality.  This technology deserves attention.</p>
<p><span id="more-500"></span>Of course with WebGL in its infancy (even though they've been working on it for years), and the spec still in flux, no documentation exists. Learning the API involves scouring sample source and the <a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl" target="_blank">nsICanvasRenderingContextWebGL</a> interface reference. My OpenGL programming knowledge being limited, I had to use iPhone OpenGL ES 2.0 guides to get me up to speed with the spec. Jeff LaMarche has a <a href="http://iphonedevelopment.blogspot.com/2009/04/opengl-es-from-ground-up-part-1-basic.html" target="_blank">fantastic series</a> on the subject, and I decided to use his icosahedron example as a starting point.</p>
<object width='500' height='300'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=6860043&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=6860043&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='500' height='300'></embed></object><br /><a href='http://vimeo.com/6860043'>View on Vimeo</a>.
<p>It's a simple low poly test, but I'm rather impressed with the result. And really, who can complain about finally having access to the GPU? Hopefully there aren't too many roadblocks (ahem, Microsoft/DirectX) in the way before this spec becomes official. Next step for me will be texturing. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=500</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Serious bug with Alchemy strings</title>
		<link>http://www.peternitsch.net/blog/?p=470</link>
		<comments>http://www.peternitsch.net/blog/?p=470#comments</comments>
		<pubDate>Tue, 08 Sep 2009 19:59:50 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=470</guid>
		<description><![CDATA[Amid the discussion caused by my memory allocation problem on the Adobe Alchemy forum (which I summarized in a previous post), it was confirmed by Cod3 Monk3y, Inc. that std::string is broken in Alchemy. Specifically, the copy constructor does not seem to be functioning properly resulting in very unusual behaviour and rendering the class unusable. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.peternitsch.net/images/stringbug_1.jpg" alt="broken string" /></p>
<p>Amid the <a href="http://forums.adobe.com/thread/473560?tstart=0" target="_blank">discussion</a> caused by my memory allocation problem on the Adobe Alchemy forum (which I summarized in a <a href="http://www.peternitsch.net/blog/?p=445">previous post</a>), it was <a href="http://forums.adobe.com/message/2227018#2227018" target="_blank">confirmed by Cod3 Monk3y</a>, Inc. that <a href="http://www.cplusplus.com/reference/string/string/" target="_blank">std::string</a> is <strong>broken</strong> in Alchemy. Specifically, the <a href="http://en.wikipedia.org/wiki/Copy_constructor" target="_blank">copy constructor</a> does not seem to be functioning properly resulting in very unusual behaviour and rendering the class unusable. This is very bad news for developers like myself who have plans on porting C++ libraries over to Flash, and certainly throws a wrench in my hopes of seeing an online version of <a href="http://cymonsgames.com/too-much-of-anything/" target="_blank">ASCIIpOrtal</a>. </p>
<p><span id="more-470"></span>For those unfamiliar with copy constructors, they're a special constructor used in C++ used to create a new object as a copy of an existing object. They are essential in heavy operations with the class since they are called when an object is created from another object of the same type, when an object is passed by value as a parameter to a function, and when an object is returned from a function. In the case of std::string, its copy constructor definition can be found in <em>/avm2-libc/include/c++/3.4/bits/basic_string.h</em> as follows:</p>
<div class="igBar"><span id="lcode-5"><a href="#" onclick="javascript:showPlainTxt('code-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-5">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">basic_string<span style="color:#006600; font-weight:bold;">&#40;</span>const basic_string&amp; __str<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Cod3 Monk3y, Inc. wrote and excellent example, which works in standard g++ but fails in Alchemy, that illustrates the bug (below). Following the bug confirmation, he wrote his own string class which forced copies, but uncovered another <a href="http://forums.adobe.com/thread/487570?tstart=0" target="_blank">nasty bug with std::ifstream</a>.  </p>
<div class="igBar"><span id="lcode-6"><a href="#" onclick="javascript:showPlainTxt('code-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-6">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">string s1;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">string s2;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">s1 = <span style="color:#CC0000;">"a"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">s2 = s1; <span style="color:#FF9933; font-style:italic;">// copy constructor</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">s1 = <span style="color:#CC0000;">"b"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// use your favorite TRACE function here</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">TRACE<span style="color:#006600; font-weight:bold;">&#40;</span>s1<span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// expected: &quot;b&quot;, actual: &quot;b&quot;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">TRACE<span style="color:#006600; font-weight:bold;">&#40;</span>s2<span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// expected: &quot;a&quot;, actual: &quot;b&quot;, ERROR </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It's not exactly shocking that an unsupported <strong>alpha</strong> research project like Alchemy has bugs. Hell, we all expected them. What I'm concerned about now, is how silent Adobe has fallen. We're nearly a year into the Alchemy announcement, and there is still no public bugbase or patches. Though I doubt Adobe would abandon such a promising and well received project, I'm worried about the speed at which it's progressing. Hopefully I'm just being too pessimistic and need to be more patient. With <a href="http://max.adobe.com/" target="_blank">MAX</a> right around the corner, we could be in for an update shortly (fingers crossed). </p>
<p>Further reading:<br />
<a href="http://forums.adobe.com/thread/487570?tstart=0" target="_blank">BUG: std::string serious problems</a><br />
<a href="http://forums.adobe.com/thread/487828?tstart=0" target="_blank">BUG: std::ifstream serious problems</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=470</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Memory allocation issues with C++ and Alchemy</title>
		<link>http://www.peternitsch.net/blog/?p=445</link>
		<comments>http://www.peternitsch.net/blog/?p=445#comments</comments>
		<pubDate>Fri, 14 Aug 2009 15:38:24 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=445</guid>
		<description><![CDATA[Not being a seasoned C++ programmer by any stretch of the imagination, I've run into several problems compiling Alchemy projects since it first debuted. Most of the issues were related to my poor understanding of the language, but some point to problems with the compiler. In particular, there seems to be an issue with memory [...]]]></description>
			<content:encoded><![CDATA[<p>Not being a seasoned C++ programmer by any stretch of the imagination, I've run into several problems compiling Alchemy projects since it first debuted. Most of the issues were related to my poor understanding of the language, but some point to problems with the compiler. In particular, there seems to be an issue with memory allocation of non-pointer data types, such as the std::vector. I've run into this problem again while trying to port <a href="http://cymonsgames.com/too-much-of-anything/" target="_blank">ASCIIpOrtal</a>, and it's causing frequent hair pulling. Hopefully someone much smarter than me can point to a solution.</p>
<p>Here's a simplified example of what I'm trying to do:</p>
<div class="igBar"><span id="lcode-12"><a href="#" onclick="javascript:showPlainTxt('code-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-12">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stringstream mapfile<span style="color:#006600; font-weight:bold;">&#40;</span>sfile<span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">//sfile is a std::string</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">vector&lt;vector&lt;string&gt;&gt; rawmaps;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">vector&lt;string&gt; map;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">while <span style="color:#006600; font-weight:bold;">&#40;</span>! mapfile.<span style="">eof</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;string line;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;getline <span style="color:#006600; font-weight:bold;">&#40;</span>mapfile, line, <span style="color:#CC0000;">'<span style="color:#000099; font-weight:bold;">\n</span>'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;map.<span style="">push_back</span><span style="color:#006600; font-weight:bold;">&#40;</span>line<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">rawmaps.<span style="">push_back</span><span style="color:#006600; font-weight:bold;">&#40;</span>map<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><span id="more-445"></span>This should give me a multidimensional vector (in this case rawmaps[0][0] gives me the first line of the first map), but the values are getting overwritten in 'memory'. That calls for memory allocation, which I assume means using the reserve method or defining the blocks to reserve in the constructor. For example:</p>
<div class="igBar"><span id="lcode-13"><a href="#" onclick="javascript:showPlainTxt('code-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-13">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">rawmaps.<span style="">reserve</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">map.<span style="">reserve</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">24</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showPlainTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">vector&lt;vector&lt;string&gt;&gt; rawmaps<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">vector&lt;string&gt; map<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">24</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>But it doesn't work. The methods fire correctly and are stored correctly directly after their assignment operation, but over time the earliest values are being overwritten as if memory is not being reserved. </p>
<p>I had the same problem with my <a href="http://www.teehanlax.com/labs/projects/metaballs/index.html" target="_blank">metaball experiment</a> where I was using the following structure for vertex information:</p>
<div class="igBar"><span id="lcode-15"><a href="#" onclick="javascript:showPlainTxt('code-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-15">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">struct SVertex</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;float v<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>; <span style="color:#FF9933; font-style:italic;">//verts</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;float n<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>; <span style="color:#FF9933; font-style:italic;">//norms</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;float t<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>; <span style="color:#FF9933; font-style:italic;">//uvts</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">SVertex *m_pVertices; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Over time the earliest values were getting overwritten. Here is a <a href="http://www.peternitsch.net/demo/metaball2/index.html" target="_blank">link</a> to a very early build where the problem can be seen in action (it's super slow because I had papervision drawing the triangle mesh and still had not written any optimizations).  In this case, I solved the problem by restructuring the data back to pointer types:</p>
<div class="igBar"><span id="lcode-16"><a href="#" onclick="javascript:showPlainTxt('code-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-16">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">float *verts;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">float *norms;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">float *uvts;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">verts = new float<span style="color:#006600; font-weight:bold;">&#91;</span>MAX_VERTICES*<span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">norms = new float<span style="color:#006600; font-weight:bold;">&#91;</span>MAX_VERTICES*<span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">uvts = new float<span style="color:#006600; font-weight:bold;">&#91;</span>MAX_VERTICES*<span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This method works, but there still seems to be major issue with the memory allocation of std::vector, and possibly other data types. I've put together a simplified example of the string vectors I'm working on in an effort to demonstrate the problem. You can download it <a href="http://www.peternitsch.net/dump/vectortest.zip">here</a>. The example loads a text file into Alchemy, and reads/stores the length of each line in a vector, and then stores that vector inside another. You can see the values getting modified in the trace log. </p>
<p>If anyone has insight into this problem, I'd love to hear your feedback. I'm <strong>hoping</strong> it's just a case of my noobish C++ understanding, but likely it's not, and we'll need to make the Alchemy team aware.</p>
<p><strong>UPDATE</strong>: An <a href="http://forums.adobe.com/message/2227018#2227018" target="_blank">excellent post on the Adobe Forums</a> confirming a major bug with std::string in Alchemy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=445</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Textmode view for Alchemy (SDL/PDcurses)</title>
		<link>http://www.peternitsch.net/blog/?p=363</link>
		<comments>http://www.peternitsch.net/blog/?p=363#comments</comments>
		<pubDate>Fri, 31 Jul 2009 16:23:46 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[AS3 ANSI]]></category>
		<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[curses]]></category>
		<category><![CDATA[pdcurses]]></category>
		<category><![CDATA[sdl]]></category>
		<category><![CDATA[textmode]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=363</guid>
		<description><![CDATA[Roguelike demo Space Invaders demo I've been talking about adding a textmode view to Alchemy for quite a while. In fact, it was the single reason I started playing with the technology in the first place. After seeing Flashterm, Scott Petersen (the lead engineer behind Alchemy) challenged me to port the classic NetHack, a roguelike [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.peternitsch.net/demo/pdcurses1/index.html" target="_blank"><img src="http://www.peternitsch.net/images/curses_2.jpg" alt="Alchemy Textmode" /></a><br />
<a href="http://www.peternitsch.net/demo/pdcurses2/index.html" target="_blank"><img src="http://www.peternitsch.net/images/curses_3.jpg" alt="Alchemy Textmode" /></a><br />
<a href="http://www.peternitsch.net/demo/pdcurses1/index.html" target="_blank">Roguelike demo</a><br />
<a href="http://www.peternitsch.net/demo/pdcurses2/index.html" target="_blank">Space Invaders demo</a></p>
<p>I've been talking about adding a textmode view to Alchemy for quite a while. In fact, it was the single reason I started playing with the technology in the first place. After seeing Flashterm, Scott Petersen (the lead engineer behind Alchemy) challenged me to port the classic <a href="http://www.nethack.org/" target="_blank">NetHack</a>, a roguelike text game. Since that time, I've played with text convertors, particles systems, and 3D graphics, but never managed to get a reasonable result for textmode - until now, that is.</p>
<p><span id="more-363"></span>The project has always been at the back of my mind, but it wasn't until I saw Joseph Larson's <a href="http://www.offworld.com/2009/07/day-made-mind-blown-its-portal.html" target="_blank">ASCIIpOrtal video</a>, that I resolved to take another stab at it. Incidently, Joe runs a <a href="http://cymonsgames.com/" target="_blank">great site</a> that has a collection of C/C++ text games that I could test against. </p>
<p>Adding a textmode view to Alchemy means interpreting curses, the terminal control C library for Unix-like systems, with its typical header being <em>curses.h</em>. There are textmode libraries for DOS and other operating systems, but curses and its cousins (ncurses, pcurses, PDcurses, etc) are the most popular. This was my starting point. </p>
<p>Of course porting curses is not straight forward since visually displaying text glyphs is machine specific. Fortunately I wrote <a href="http://code.google.com/p/as3ansi/" target="_blank">AS3ANSI</a>, an AS3 textmode interpreter which was used for <a href="http://www.flashterm.com/" target="_blank">Flashterm</a>. So naturally my first approach was to write proxy C functions that send commands (e.g move cursor left 3) back to AS3ANSI to visually display. I used a simple game by Ido Yehieli called <a href="http://cymonsgames.com/cryptrover/" target="_blank">Crypt Rove</a> for testing and here's the result:</p>
<p><a href="http://www.peternitsch.net/demo/curses/index.html" target="_blank"><img src="http://www.peternitsch.net/images/curses_1.jpg" alt="Alchemy Textmode" /></a><br />
<a href="http://www.peternitsch.net/demo/curses/index.html" target="_blank">Check out Crypt Rover</a></p>
<p>It worked, but the game only used the most basic curses commands and establishing a standard would involve flushing out many more curses functions, some of which are very challenging. This approach also has a major problem with speed since every function is marshaled to AS3, but we're dealing with textmode so it was only slightly noticeable. </p>
<p>After seeing this demo, Joe made a great comment, "Why reinvent the wheel? Just use PDcurses." I was still realitively unfamiliar with <a href="http://pdcurses.sourceforge.net/" target="_blank">PDcurses</a> (short for Public Domain Curses), but did know that it had a <a href="http://www.libsdl.org/" target="_blank">SDL</a> extension. Luckily, Ed McManus had already coded a basic port of <a href="http://github.com/emcmanus/flashsdl/tree/master" target="_blank">SDL to Alchemy</a>, so using his code as the visualizer, it just took a bit of work to attach PDcurses and I got my first <a href="http://www.peternitsch.net/demo/pdcurses/index.html" target="_blank">'Hello world'</a>. I used Jakub Wasilewskis' roguelike game <a href="http://cymonsgames.com/ajth/" target="_blank">AJTH</a> for a proper demo:</p>
<p><a href="http://www.peternitsch.net/demo/pdcurses1/index.html" target="_blank"><img src="http://www.peternitsch.net/images/curses_2.jpg" alt="Alchemy Textmode" /></a><br />
<a href="http://www.peternitsch.net/demo/pdcurses1/index.html" target="_blank">Check out AJTH</a></p>
<p>Awesome! With this working demo, I knew I had finally achieved a solution that requires minimal modification of native textmode programs. I wanted to try a more complicated game, so I decided to try <a href="http://www.ip9.org/munro/invaders/" target="_blank">Ascii Invaders</a> by Thomas Munro. I love the result:</p>
<p><a href="http://www.peternitsch.net/demo/pdcurses2/index.html" target="_blank"><img src="http://www.peternitsch.net/images/curses_3.jpg" alt="Alchemy Textmode" /></a><br />
<a href="http://www.peternitsch.net/demo/pdcurses2/index.html" target="_blank">Check out Ascii Invaders</a></p>
<p>This is just the beginning. NetHack still hasn't been ported and I have my eyes fixed on OpenCP, but with the foundation laid, I expect to have them working soon. The source will be released once I figure out how I want it organized. It may come as a fork to Ed's SDL work.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=363</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Alchemy 3D metaball early preview</title>
		<link>http://www.peternitsch.net/blog/?p=331</link>
		<comments>http://www.peternitsch.net/blog/?p=331#comments</comments>
		<pubDate>Thu, 09 Jul 2009 18:06:33 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[labs]]></category>
		<category><![CDATA[metaballs]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=331</guid>
		<description><![CDATA[Check it out! (note: requires FP 10.0.22) I thought I'd give an early demo of a 3D metaball system that I've been working on in the lab for the last week. As fate has it, Frank Reitberger also posted a fantastic metaball experiment today with great results. Where our systems differ, is that I've written [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.teehanlax.com/labs/projects/metaballs/index.html" target="_blank"><img src="http://www.peternitsch.net/images/metaball1.jpg" alt="Metaballs" /></a></p>
<p><a href="http://www.teehanlax.com/labs/projects/metaballs/index.html" target="_blank">Check it out!</a> (note: requires FP 10.0.22)</p>
<p>I thought I'd give an early demo of a 3D metaball system that I've been working on in the <a href="http://www.teehanlax.com/labs/" target="_blank">lab</a> for the last week. As fate has it, Frank Reitberger also <a href="http://www.dasprinzip.com/prinzipiell/2009/07/09/metaball1/" target="_blank">posted a fantastic metaball experimen</a>t today with great results. Where our systems differ, is that I've written mine entirely in C++ through Alchemy with the intention of eventually tying it directly to my <a href="http://www.peternitsch.net/demo/emitter2/index.html" target="_blank">particle emitter</a>, ensuring the least amount of data marshaling possible.</p>
<p><span id="more-331"></span>Keep in mind, this is an early preview and some glitches still exists, namely some forward facing triangles are being rendered in the incorrect order. I plan on sorting the indices in C++ once I find a suitable technique.  </p>
<p><img src="http://www.peternitsch.net/images/metaball2.jpg" alt="Web cam!" /></p>
<p>Of course, what would a blob simulator be without the necessary webcam support?</p>
<p>For the Alchemy coders, I thought I'd mention an important lesson that was learned with this experiment. Originally I had the vertices, normals, and uvts stored in a value object that looked like this:</p>
<div class="igBar"><span id="lcode-19"><a href="#" onclick="javascript:showPlainTxt('code-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-19">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">struct VertexVO</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; float v<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; float n<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; float t<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The problem is that that blocks of the Alchemy RAM ByteArray are overwritten unless explicitly allocated, and therefore the start of the vertices data was getting written over by indices. The solution is simple and obvious, allocate memory:</p>
<div class="igBar"><span id="lcode-20"><a href="#" onclick="javascript:showPlainTxt('code-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-20">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">verts &nbsp; = new float<span style="color:#006600; font-weight:bold;">&#91;</span>MAX_VERTICES*<span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">norms&nbsp; &nbsp;= new float<span style="color:#006600; font-weight:bold;">&#91;</span>MAX_VERTICES*<span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">uvts&nbsp; &nbsp; = new float<span style="color:#006600; font-weight:bold;">&#91;</span>MAX_VERTICES*<span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p><em>UPDATE: Added reflection and <a href="http://www.dasprinzip.com/prinzipiell/2008/06/06/fisheye/" target="_blank">Frank's Pixel Bender Fisheye filter</a> to the webcam view.</em><br />
&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=331</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>AA-Lib ported to Flash via Alchemy</title>
		<link>http://www.peternitsch.net/blog/?p=285</link>
		<comments>http://www.peternitsch.net/blog/?p=285#comments</comments>
		<pubDate>Thu, 18 Jun 2009 14:26:01 +0000</pubDate>
		<dc:creator>Peter Nitsch</dc:creator>
				<category><![CDATA[AS3 ANSI]]></category>
		<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[aa-lib]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3ansi]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[textmode]]></category>

		<guid isPermaLink="false">http://www.peternitsch.net/blog/?p=285</guid>
		<description><![CDATA[One of the main reasons I started playing around with Alchemy a while back was to experiment with some of my favorite textmode libraries, specifically AA-Lib, which is the most commonly used image-to-ascii-art library of the bunch (has been used with Quake, VLC Player, and many other desktop programs) . It's a frequently requested port [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.peternitsch.net/demo/aa-lib/index.html" target="_blank"><img src="http://www.peternitsch.net/images/aalib1.jpg" alt="AA-Lib demo" /></a></p>
<p>One of the main reasons I started playing around with Alchemy a while back was to experiment with some of my favorite textmode libraries, specifically <a href="http://aa-project.sourceforge.net/aalib/" target="_blank">AA-Lib</a>, which is the most commonly used image-to-ascii-art library of the bunch (has been used with <a href="http://www.jfedor.org/aaquake2/" target="_blank">Quake</a>, VLC Player, and many other desktop programs) . It's a frequently requested port among ascii art fans, and I'm glad to finally release it for everybody to use. </p>
<p><span id="more-285"></span><a href="http://www.peternitsch.net/demo/aa-lib/index.html" target="_blank">Check out the demo!</a></p>
<p><a href="http://www.peternitsch.net/demo/aa-lib/alcaalib-src.zip">Download source code</a></p>
<p>AA-Lib is a low level gfx library written in C. Its API is designed to be similar to other graphics libraries, but its renderer outputs ascii-art. I'm not going to go into any coding detail with this post, as the source is <a href="http://www.peternitsch.net/demo/aa-lib/alcaalib-src.zip">available for download</a>. Programmers with even limited C experience should find the routines fairly straight forward (Alchemy routines can be found in /alc-src/main.c). </p>
<p>The important thing to note, is that AA-Lib will pass back a text buffer ByteArray, and a text-attribute (Bold, Dim, Normal) ByteArray. A flash developer can do whatever he wants with those. For the <a href="http://www.peternitsch.net/demo/aa-lib/index.html" target="_blank">demo</a>, I've used my own <a href="http://code.google.com/p/as3ansi/" target="_blank">AS3ANSI</a> library to interpret those buffers. I've also included a <em>"Save to Text File"</em> option that allows you to download the raw text buffer to a file.</p>
<p><img src="http://www.peternitsch.net/images/aalib3.jpg" alt="Text output" /></p>
<p>AA-Lib has many cool features, including the ability to control brightness, contrast, and gamma. Sometimes an image needs to be tweaked in order to achieve the desired output. Play around with the sliders I've hooked up. You can get some pretty crazy results.</p>
<p><img src="http://www.peternitsch.net/images/aalib4.jpg" alt="Image controls" /></p>
<p>There's also an option to invert the image, incase you're dealing with something on a white background or want a negative ascii. </p>
<p><img src="http://www.peternitsch.net/images/aalib2.jpg" alt="Inversion" /></p>
<p>I'll probably evolve this demo into a more substantial app, but for now all the requested features have been added, including uploading, saving to JPG, saving to text, and size parameters. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peternitsch.net/blog/?feed=rss2&amp;p=285</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
