Thursday, 27 May 2010

Rediscovering Processing.org

So I've been screwing with a lot of 3D in Flash recently, and while I love the fact it's easy to do (thanks to libraries like PV3D and Away3D), I often find myself handcuffed by the limitations of the Flash player (the low polygon count just isn't going to cut it for some work).

I began to look at other options, and quickly re-discovered Processing.org. I've not used Processing since waaaay back in the day when I'd just started studying, and while it was fun to screw around with I immediately dropped it in favour of Flash.

Well, how things have changed. Processing is now a streamlined, solid platform for developing everything from quick sketches up to massive beautiful projects. I'm attracted to it for two main reasons:

1. The language: Processing is a Java language under the hood (albeit quite simplified) which means that as a Flash/AS3 geek I'm already pretty comfortable with reading/writing the language. If anything, Processing's syntax looks to me how AS3 should ideally be; it's not a mile away from Actionscript but it's slightly less verbose and a little neater (although my opinion will no doubt change once I start going nuts with it and throwing code everywhere).

2. The audience: Because Processing is aimed squarely at the creative end of the programming spectrum, it's almost laughably easy to get cool stuff out of it with a few lines of code. Flash can be a little frustrating when it comes to quickly bashing something out, which is where Processing excels: I can see this being a much better rapid prototyping tool than Flash (the IDE is great too, just a code window and a few buttons, no messing about).

And of course, it's open-source and the community looks like a great one too, so everybody wins.

It's an exciting (re)discovery, and looking at some of the work online it's hard not to want to get stuck right in. I also bought the excellent Processing book, which is a real thing of beauty. Like the language itself, the book bridges the gap between technicality and art, showing not just how to program, but also how to turn that into something amazing.

And here's some eye candy to show exactly why this is so exciting:
http://www.vimeo.com/tag:processing.org

More on this soon, after I've played with it more. :D

Monday, 10 May 2010

PV3D - Easy billboards

Billboards in 3D are really useful, they're used in all sorts of ways: from particle systems right up to big pseudo-3D elements (remember how in the Doom videogames everything always faced you? Billboards!). Anyway, I was happy to discover that creating a PV3D billboard is easy.

All you need to do is add this to your rendering functionality (assuming "plane" is your billboard):

// Position billboard in 3D space
var up : Number3D = new Number3D(0, 1, 0);
Matrix3D.rotateAxis(camera.transform, up);
            
// Reorient the billboard in relation to the camera
plane.lookAt(camera, up);
plane.roll(180);
plane.pitch(180);

Which will give you:


Of course this functionality could be applied in a much smarter way; if I had a bunch of billboard shapes I'd probably store them in an array and update them all in a loop, but you get the idea.

One of the best things about this (apart from the fact that billboards are much less processor-intensive than full 3D geometry) is that you can set up multiple cameras, and the billboards will shift to point at the new perspective a different camera is used. Handy!