Unforgotten

Posted in OSX, gaming on February 15th, 2010 by Chaos Engineer

I almost forgot I started a blog!

About six months ago I got a MacBook Pro, so I spent a long while just updating my applications to run on OSX, and also exploring Core Foundation. I've made some neat stuff that I'll share with you guys, as soon as I get out this NDS WiFi programming project that I've been promising for nearly a year. =P

Around the same time I got my new Mac, I also found Dragon Age: Origins. Installing this game created a time anomaly centered around my computer. I played enough DA:O that the heat generated by my video card has likely contributed greatly to global warming, and melted a few iceburgs. The deaths of many penguins was worth the glory of turning back a blight.

After DA:O (like 6 characters and playthroughs later), I got wrapped up in the whole Bioware strategic RPG thing. I played through the entire Baldur's Gate series with all expansions, then the Neverwinter Nights series with all expansions, and I just finished Mass Effect. SOO... needless to say, I've been distracted.

I haven't forgotten about you however, and I will soon piece together the final bits of the NDS WiFi project, and make a post to bring it all together, I promise. =)

Tags:

A History of Hatred

Posted in Linux, SVG, Windows, gaming on May 21st, 2009 by Chaos Engineer

Over the past couple years I have completely migrated out of Microsoft Windows except for those circumstances where I am forced to use it (read: 'work'). I have thus been spending my time discovering the amazing power of Linux and of the opensource community. OpenGL has proved to be quite a good friend. I am constantly enheartened by it's prowess. VBOs, PBOs, FBOs... OpenGL is far from a substandard graphics API (as I used to believe) and can push polygons with the best of them. SDL has also been by my side, cutting a path through the uglier bits of interfacing with X11, providing clean input methods, and making my projects easily run on both Windows and Linux.

I used to be a Microsoft fan boy. I loved DirectX, and spent nearly every waking hour using it while crafting a game engine. I can remember working with Direct3D 6 and tearing my hair out trying to decide between immediate and retained mode. What an ugly API it was too, but I still used it over OpenGL because I had the feeling it was more powerful. DirectX 8 came out and all of a sudden everything was sleek and seemed to fit into place so well, and boy, was I ever excited over DirectX 9.

Tux Plotting

Tux Plotting

So what happened? At what point did I decide that Microsoft was evil and didn't deserve my time? The feeling culminated slowly. Microsoft pulled one stunt after another, betraying the trust consumers had placed in them. They were constantly using their market share and financial prowess to inhibit innovation and force the consumer's hand to benefit only themselves. It soon became apparent to me that they knew almost no bounds. They would commit horrible atrocities and get away with it because they are Microsoft.

I had been following the development of Bungee's Halo eagerly for some time. This was going to best PC game ever. One day, the Halo website just disappeared. Nobody knew what happened. Microsoft had recently announced they were entering the console market. It soon became obvious what was going on. Halo was to be a launch title for Microsoft's Xbox. They had acquired Bungee. I held my breath and patiently waited for the PC release of Halo. Bungee wouldn't turn it's back on the PC market, would they?

When it finally came, the PC port of Halo was substandard. I played the demo and never got the full version, maybe because Blood Gulch was enough for me, or maybe it was the flaws I saw. The networking code was seemingly never designed to operate with the high latencies found on the WAN. It was possible to accomplish... Unreal Tournament's cubic interpolation allowed the server to accurately render players and detect hits based on their projected locations. When playing the PC port of Halo, I found myself having to perform this interpolation myself, aiming ahead of players a certain distance based on the amount of latency I had with the server. Don't get me wrong, I got damn good at this and could still drop mofos from the far side of Blood Gulch with a pistol while both at full tilt, but I still felt betrayed and forgotten by Bungee with their new guiding hand. And man, oh man, when Halo 2 was released on the PC under Microsoft's new "Games for Windows" (AKA: Games that _only_ run on MS's craptacular new Vista OS) platform, there aren't words to describe how furious I was. Bungee's output was again used to push Microsoft's own agenda, this time trying to wrangle people into buying the new Vista OS, which was almost universally hated. Halo and Bungee aside, there are plenty of other reasons to despise Microsoft...

I had always been a tables layout HTML kind of guy. Who wasn't? When CSS starting making its way into the mainstream and new standards for positioning web page elements were devised, I resisted change for quite some time. Tables were so handy. I didn't need these new fancy DIVs and all this new positioning mojumbo. I could do all that with nested tables using colspan, rowspan, and the ever-useful CENTER tag. Needless to say, the CSS revolution didn't move me. I was still happily making webpages without a single style attribute. I tell you this just so you know I'm not a standards whore who expounds upon and proudly touts every little tidbit thrown out by the W3C.

One day while meandering about on the interwebs and mourning the fact VRML never caught on, I stumbled across a new standard that made me salivate. Scalable Vector Graphics had become a web standard. The W3 Consortium said so! This was blasted glorious! It was only a matter of time before webpages based on SVG would become standard, and we could present content on interactive SMIL animated geometry! SVG had presented epic new parameters to the web.

I quickly downloaded Opera with it's high level of SVG and SMIL compliance, and set to work creating an exemplary SVG based webpage. Previous experience with geometry and transformation pipelines from game engine design lent itself well here. I learned all sorts of new things with Javascript, stuff I had never before even thought of doing. I was dynamically modifying SVG transform attributes, adding and removing JS event handlers, and generally having a ball. I made a tasty little SVG "module" that would allow you to specify an array of images and it would create a task bar much akin to the Mac OS X dock. As your mouse cursor approached one of the "tasks" the image associated with it would grow larger( transform="scale(4.3*glory, 5.2*splendor)" ), nudging it's neighboring task icons to either side. You could even grab the dock itself and drag it to some other location on the screen without changing it's functionality. Obviously the possibilities for content interaction and presentation were limitless. Web design had never been so fun or rewarding.

So after the initial reveling was over, it was time to realize the benefits of the SVG standard, and deploy some content. Internet Explorer 7 was about to be released, I thought for sure it would come with some support for SVG, considering Firefox was already providing some support, and Opera was rocking near full compliance. Well, IE 7 came out without a lick of SVG support. Surely they would wise up, get with the program and provide support in a service pack? Wrong. Hell, IE 8 *just* came out and Microsoft is still pretending like SVG doesn't exist. Not even a hint of support for SVG. Why you ask? Why would Microsoft totally ignore such a great standard that offers so much promise for the web? Two words. Silver. Light. Yes, Silverlight and XAML. Microsoft basically rips off the SVG standard to define XAML, then turns it's back and pretends like SVG doesn't exist, again in order to promote it's own agenda. For some reason as I write this, I am reminded of Death of a Salesman: "You cannot eat the orange and throw the peel away. A web standard is not a piece of fruit!". Microsoft ate the fruit of W3C's labors, threw the rind away, and walked off.

This transgression by Microsoft is magnitudes more serious than the Bungee / Halo fiasco. This makes that seem completely insignificant. This is Microsoft using it's market share to try and KILL a standard. With the majority of end users using Microsoft's browser, they can pretend that SVG doesn't exist, and thus make the majority of the world not realize it exists. No one will push forward with SVG, because the world's most popular browser... Microsoft Internet Explorer stubbornly refuses to support it. The world is being denied an open web standard that can provide interactive and dynamic content on level with Adobe's Flash, but is natively supported in browsers. Can you imagine the community driven image gallery projects like Gallery, CopperMine and 4Images but based on SVG that would exist if Microsoft had supported SVG six years ago when they should have? I don't think you can. Hell, I'll make a prototype just to hint at what you are missing (as long as you aren't using IE).

At first it was denial... I continued to search the web for news that Microsoft wasn't being that obstinate, and actually had plans to support SVG in IE at some point. I hunted through the forums waiting for some Microsoft engineer to say in a forum somewhere that yes, of course SVG support was on the IE development roadmap. Time dragged on, and eventually I couldn't deny the facts anymore... Microsoft was doing this... HOW COULD THEY?!? AAARRGGHHH!!! The anger was the worst because I had little outlet for it. My friends didn't seem to understand the fury that drove my diatribes about how evil Microsoft was. I hoped that maybe... maybe if they didn't feel threatened by SVG they would relent and offer support for it. I cried a little. Tears fell from my ocular devices, shed for all the potential glory of SVG that would never be realized. I became sullen and discarded web development for years. My webpage lied in repose. It was during this time of depression that I rediscovered Linux.

Frankenstein Milkcrate Machine

Frankenstein Milkcrate Machine

I had used Linux before, but never considered it's real potential. I always used it when telnetting to shells, and back in 1996 I built a Frankenstein computer assembled from the corpses of other machines. I installed RedHat Linux (v2 I think) and used it to make a CGI application for the ISP I worked for. It was pretty neat, and I liked the feeling of being totally lost in a new operating system, but at that time I still had much to learn about windows, and only considered Linux as a second-rate OS. Back on the real timeline, I got myself a copy of Gentoo and again installed it in a Frankenstein computer, this time one that was assembled in a milk crate (real classy, eh?). For some reason this time around, my feelings for Linux were much different.

This change in feeling can be likely attributed to two things. One, I felt I had pretty much learned everything that wasn't hyper esoteric about Windows. I knew XP inside and out, I knew Windows server, all about Active Directory, Group Policy Objects, terminal services, etc. I had also used a crap ton of C/C++ Microsoft APIs most people had never heard of like the TS API and the GP API. Two, I had started to hate Microsoft and finding out that from within Linux I could emulate the fast majority of Windows applications uisng WINE and even emulate DOS using DOSBox gave me a great feeling of control and satisfaction. Furthermore, Linux was aimed at people like me.

People who wanted the freedom to customize EVERYTHING if they wanted. People who wanted the source code for all the applications they use just in case they wanted to modify how they operated slightly. People who wanted to work using formats that were standardized and open. People who didn't like being told how to use their computers. People who saw new computer technology and standards not as either a threat or a chance to capitalize, but as a road to innovation where they could potentially improve the quality of digital life for computer users. It is these people who embrace Linux and opensource, and feel oppressed when working with Microsoft Windows.

After this recent excursion into Linux, I approached the operating system as a replacement for Windows, not just a diversion from. This meant I needed to be able to do everything I typically did within Windows without inconvenience. After years of using nothing but Gentoo, Debian and of course Ubuntu, I can honestly say that I have found absolutely nothing I cannot accomplish in Linux with similar or improved efficiency, except perhaps playing TES: Oblivion.

I can take the lack of support for new PC games. Oblivion was a time vortex anyway... I stopped playing it on Windows before I really got into it. I knew otherwise I would sink countless hours into the void. It seemed a game that you could continue playing forever. My father actually proved this wrong though... he played Oblivion into the ground. He only stopped after he got 100% chameleon so nobody could see or hurt him. At that point he resorted to just hanging out on the front porch of his house in Anvil watching the people go by. Apparently this lost its appeal pretty soon.

Back to the point though, I try not to spend too much time playing games anymore. I started playing text MUDs back in like 1996. I hardly ever left the house anymore. My friends were pissed because I wouldn't join in the D&D campaigns we constantly ran. My parents were pissed because the phone line was CONSTANTLY in use and nobody could call without getting a busy signal. I was only pissed when Creeping Death, Age of Legends or Carrion Fields went down. Diku/Merc/ROM was the stuff dreams were made of. I would often have dreams about being on the text mud. My dreams actually consisted of text on a screen. It was absurd.

When the first graphical MUDs started appearing, I was ALL over that. I was playing the first real graphical MUD, Meridian59 back when it was only the town of Tos. A single large room. I beta tested and played the hell out of pretty much every significant (and some insignificant) MMORPG that came out. Beta tested for Meridian59, Ultima Online, Asheron's Call, Star Wars Galaxies, and finally Ever Quest. For some reason after Ever Quest, I abandoned MMORPGs. I haven't touched one since the EQ beta. I just decided to not sink my time into games like I used to. MMORPGs were becoming the ultimate distraction... to the point of absurdity. People were living richer lives in virtual worlds than they granted themselves IRL. I digress. Perhaps I'll pontificate about it at a later time.

For all my haughty talk, I still like a good distraction once in a while just as much as the next guy. Fortunately there are a scad of options for digital entertainment in Linux. Many of the best games for Linux are found under emulators. I play PSone games using ePSXe, n64 games using Mupen64Plus, SNES games with zSNES, GBA games with VisualBoy Advance, DOS games with DOSBox, and Windows games with WINE. There are plenty of options for gaming input devices in Linux. Any device that is HID compliant will likely run without problems. There are devices that will let you plug PS/PS2, NES, SNES, and n64 controllers right into your computer and use them with your emulators. There aren't any good n64 adapters on the market since the Adaptoid went out of production, but I'm planning to take the time to make a microcontroller circuit for connecting them. Maybe I'll share.

With no shortage of solutions for the biggest complaint about Linux (no games), I don't have any immediate shortcomings I can describe. Maybe its my rose-colored glasses. Maybe its the huge array of upsides clouding my judgement.

Tasty Desktop

Tasty Desktop

Linux can be crafted to be as flashy or as spartan as the user likes. You can choose between a number of window managers (Gnome, KDE, XFCE, Enlightenment). You can have screen widgets. You can customize every single icon. You can install custom docking managers like Avant Window Navigator or Kiba Dock. You can go all out and install Compiz (previously Beryl) to give yourself wobbly, burning, alpha blended, motion blurred, dynamically zooming windows that exist across 4 desktops on the surface of a transparent 3D cube that you can rotate under a custom sky dome. There is no question that the Linux desktop environment is far superior in scope, functionality and configurability when compared to Windows.

Oldschool Tasty Desktop

Oldschool Tasty Desktop

Tags: , , ,

Chaotic Background

Posted in fractals, strange attractors on May 21st, 2009 by Chaos Engineer

I started my foray into chaos over four years ago now, at the end of 2004. I stumbled across a book by Clifford Pickover and Elahe Khorasani in the local library. It was about chaos, fractals and computer graphics.

First Julia

First Julia

At the time I was working on a game engine in Direct3D, so I quickly created a templated complex number library and set to work visualising some systems. Nothing worked at first, I was just getting pure black images as a result. Then... I thought I saw something. I increased the contrast of an image, and sure enough there was *something* hiding there in the darkness. I tweaked and adjusted my code some more. Finally, this Julia set materialised out of the void.

It may look meager, and by all counts really *is*, but at the time when those chaotic curls first appeared on my screen as a result of a some complex math, I was floored. I carefully adjusted the boundaries and sampling frequency of the system, and effectively zoomed in.

First Julia Zoom

First Julia Zoom

The tiny crevices in the curls opened up and spewed forth more detail. Where would it end? I spent hours rewriting this recursive routine and recompiling in order to change parameters of this Julia set rendering, and soon realised that I needed a better way to interface with these complex systems.

I adapted my rendering engine and created a Fractal Playground, where I could explore and play in the infinite number of fractal landscapes out there. I was limited only by the speed of my processor and the precision of 64-bit floating point maths. To me, exploring these fractal landscapes was as exciting as going on vacation to some new place. Rewriting the governing equation, defining new complex math operations, adding and modifying terms... it was like a grab bag of free vacations. I never knew where I would end up next. Some of these places were drab and repetitive, while others astounded me as soon as I stepped off the tarmac. The ones that I really remember are the ones that were drab on the outside, but with a little digging revealed themselves as fractal geodes... containing an unrivalled inner beauty encased within a plain shroud.

Buried Treasure

Buried Treasure

This image which is aptly named 'Buried Treasure' I found about 10E30 deep into a fractal landscape that seemed totally composed of white noise. I followed just a hint of a crevice in the noise down to this treasure. There were no real discernible features until this image appeared. Quite beautiful as well... it looks like the fancy sort of wood carving you would see on antique furniture.

I moved on from the typical convergence digrams where the color of a sample was defined by the number of iterations required to push it's magnitude past a threshold value. It was possible as well to track the actual orbit of a sample in complex space as you iterated it. Instead of just looking at the magnitude of a sample as it was iterated, I started plotting the values on the complex plane.

Encapsulating Sine

Encapsulating Sine

I referred to these as vector diagrams. The first time I plotted the orbits, as with many things, it didn't seem to work or make sense. There was far too much going on to understand the nuances. I needed a reference, and to start with a limited set of points. I first drew a convergence map, and then plotted the orbit of each sample on every 16th row or something. The results were intriguing. I soon found that plotting orbits in an aesthetically pleasing and efficient manner was quite difficult. Many wild and very strange images resulted from my experiments with this temperamental routine.

There was much more to be done however. This playground was fine for exploring, and giving brief reports on these landscapes, but it vastly lacked "production" features. The images I saved were limited in size to my screen resolution. The playground had a fullscreen mode, and I resorted to using the windows PrntScrn functionality to copy the full screen images to the clipboard and saving them off that way. I knew it was possible to create fractal images of arbitrary resolution... sometimes I hard coded a routine to dump a huge image of a system. It was a clunky way of accomplishing things, and many times while exploring I wished for the ability to do this dynamically. I also needed a better way to interface with the complex systems. Bringing up a dialog box and tabbing through controls, or even clicking on menu items was an annoyance while exploring. Fullscreen mode and modifying parameters (besides the zoom and pan) were mutually exclusive.

I was a bit daunted at first at the notion of entirely reworking the playground. My main code module (the one that contained the Windows entry point) had like a hundred global variables and was just under ten thousand lines long. In my state of fractal fervor, every new feature on the playground, every little test and modification was implemented as a kludge. I only cared about immediate results, and had cast maintainability to the wind. I built an empire out of bubblegum and bailing twine.

I rewrote the core routines, and this time built them out of brick instead of sticks and mud. I encapsulated everything, and made the multitude of non-exclusive boolean options for the system into a bitfield. There was now a single "state" variable where each individual bit represented a switch I could flip for a given option. One of the biggest and most effective changes was implementing a physically-based camera that existed in complex space. Physically-based, meaning the camera had momentum and friction, and moving it was all based on applying forces. When zooming/panning the weight of the camera would carry it for a bit even after releasing the controls. Note that this pre-dated the weighted interface of the iPhone by quite some time, and this idea was purely my own.

Now with the interface exclusive from the OS, I had a platform for fractal exploration that I never needed to bring out of fullscreen mode. With input and update routines built much like a game engine, I could define esoteric keypresses to my heart's desire, and the only change would be in the class's UpdateInput method. As I thought of new options, I defined a new bit in the bitfield and added accessors. It was simple to add routines for dumping the current scene to a huge detailed image, or saving each frame to make videos from. Now THIS was the kind of vehicle I needed for traversing the world of complex geometry.

Around this time I was an active member of the electronica scene in my area. I talked with some of the people setting up shows and got myself an invite to be a VJ for an upcoming event. I secured myself a projector and hauled my behemoth number cruncher (thanks, Stu!) to the venue. I had myself a little electroluminescent keyboard that worked perfect for manipulating the system in the darkness of the drum & bass arena. People were definitely impressed. One dude recognized the Mandelbrot set and was amazed to see it in such a dynamic light. That was probably the biggest compliment of the night. Everyone thought the convolving text routine where I feed text into a vector diagram and let the system swirl it around was mighty badass. All in all, it was quite a success.

Bolstered by the positive feedback from my first VJ gig, I was determined to expand the capabilities of this new application. Around this time I started experimenting with strange attractors. I used vector vector maps in the original fractal playground to build a "hit map" where computed locations of sample orbits were added to two-dimensional array that far exceeded the depth of a typical image. After subsampling the complex field and running thousands of iterations, I ran some statistical routines to get an idea of the spread of this data. I managed to clamp this data into a range acceptable by images, and interpolated the data into this clamped region to get some visual output. The results reminded me of images of strange attractors I had seen before. I didn't really know what a strange attractor was, but I figured they must be scads easier to work with than these complex vector diagrams.

I created a new application (again using parts from my game engine) for visualizing and manipulating strange attractors. These strange attractors proved to be quite varied and appealing. I especially enjoyed the way they moved when modulating the parameters over time. I produced hundreds of high resolution images and a few videos of these systems, all which were received well. I needed to get this new form of chaos integrated into my VJ software so I could switch between the systems on the fly. It was around this time that I migrated out of Windows and into linux, so this application would be the first to be resurrected in OpenGL.

Iconic Engineered Attractor

Iconic Engineered Attractor

Tags: , ,