Wick3d update: BSP sorting

October 4th, 2008

After some developments in Papervision3D and Alternativa3D, I decided to try to tackle BSP sorting myself (yeah yeah, months after everyone else did :p). It gets rid of those typical annoying z-sorting anomalies, and allows for intersecting objects to be rendered flawlessly. However, due to the cpu-intensity of building the initial bsp tree, it can only be applied on static scenes. I haven’t yet built in support for movable or animated objects inside the 3D world. The current implementation will probably change a lot, but as this is mainly a self-study project, it’ll do for now ;)

Check out the demo, and check the source. The cubes are generated randomly, so performance may vary from time to time, due to the BSP tree. But note how, even tho intersecting, all triangles are rendered in the correct order. And please, forgive the uglyness of the demo. The Wick3d source can still be found on Google Code.

The past few weeks have also seen some bugfixes (the matrix invert function was warped causing the camera to behave oddly) and some refactors. And more importantly, there now is a DisplayObjectMaterial which is interactive. It’s probably very buggy tho, I haven’t had time to test it thoroughly, and it’s not one of my favourite aspects of a 3D engine (creating it, that is, I love using it ;) ).

Finally, I recently got back from Flash on the Beach ‘08 (thanks to Nascom for sending us). Because Sakri already wrote a pretty accurate article on the time we had there, just check out his post at the Nascom blog. We had a great time, and some good opportunities to chat and have beers with some flash heroes and like-minded people. Needless to say, I came home stoked and full of inspiration!

On an unrelated note… (and some updates)

September 22nd, 2008

I always told myself not to post anything unrelated to Actionscript or music, but this time I’ll just have to make an exception to that rule, because I’d like to introduce two new inhabitants of my apartment. Meet Flash and Bundy, the two feline hellraisers that have taken up residence with me and, in the process, are well on their way of destroying every single thing I own ;) (Pictures below)

Cats aside, I’ve been working regularly on Wick3d since I got back from holidays and I hope I can post some interesting stuff soon. So keep an eye out for it :)

And while I’m updating, I might as well start plugging. Check out one of Nascom’s recent projects, for which I had to do the particle stream in the background: www.fullhd.be. Fun times :D

Wick3d source available + MD2 animated model demo

August 14th, 2008

Aah, finally :) I’ve been spending a large part of my free time working on Wick3d, and I’ve arrived to the point where I wouldn’t mind people looking at the source (link at the bottom of the post). I’ve said it before, and I’ll say it again: looking at it and experimenting with it is encouraged, but actually using it for a project is looking for trouble - it’s in no state to be used as such ;) My to do list just keeps on growing, but at least there’s some useful functionality.

Main things updated:

  • Major performance boost and improvement in render pipeline flow.
  • Very basic Collada support (only single objects, no hierarchic structures; buggy).
  • Animated MD2 mesh support (Quake 2 models, etc.)
  • Improved transformations: Support for Euler angles (yaw/pitch/roll), lookAt, camera target …
  • (Animated) DisplayObjectMaterial
  • Added more Primitive models

Some things you’ll find in the source aren’t used (yet), and some things might be refactored completely. Feel free to drop requests or remarks, I can always use a reason or tips to work on it ;)

Also linked below is a demonstration of the MD2 animated model support (MD2 is the file format used by f.e. Quake II). The model might take a bit to load, but it’ll show up eventually :)

To close off, I’ll be abroad for 2 weeks in a few days, so it might take long for comments to get approved.

Enjoy!

Water ripples revisited (AS3-only version)

August 3rd, 2008

I’ve been thinking of changing my previous Pixel Bender water filter to an AS3-only version for some time (since FP10 is still in beta), but never got around to it. Until trusty old Nascom told me we might perhaps use it in a project. So here it is, added to the NascomASLib and ready for you to use :) I added some functionality so the appearance of the ripples can be altered. Overall, I’m quite happy with the performance, especially since it runs smoother with bigger ripples (and usually looks better too ;) ).

So enjoy the demo, and check the source here.

Celebrating 10 years of Sony VAIO in Papervision3D

July 15th, 2008

After a couple months of work, Nascom’s latest big project for Sony Vaio was able to go live, celebrating Vaio’s 10th anniversary. To read all the grubby details about it, you can check the full blog post at Nascom.

It was a blast working on this project, mainly because it gave me a chance to solve some interesting math-related problems, which tapped right into my main interests as a programmer. Especially custom collision detection paired wall sliding in a game-like manner, and optimising paths generated by an A* algorithm. As A* is tile-based, I needed to remove superfluous nodes by checking intersections between extreme nodes with the map and iterate backwards from there to create a shorter and more natural path. Good times!

Cheers to all people involved at Nascom, as well as to Ralph, who helped us a lot with some invaluable input on do’s and don’ts of papervision, performance tweaks, …, to be able to get most out of it. So cheers, man ;)

To close up, just take a peek and a poke here: http://club.vaio.sony.co.uk/clubvaio/gb/en/vaio10/ . Enjoy!

Wick3d from scratch

June 19th, 2008

After some books finally arrived by mail, I’ve been spending the past two weeks reading up on 3D maths. Being unhappy with how my playground engine Wick3d was evolving (bad code flow resulting in poor maintainability being the worst of it), I decided to put some of this newly acquired knowledge to practice and redo the engine from scratch. Perhaps the biggest structural improvement would be that the operations such as transformations, culling, drawing, etc… are now being executed from a centralized render pipeline. Furthermore, some other things are done more correctly. For instance, the render target is now a viewport and the camera works with field of view instead of some random zoom factor. The latest addition is a rudimentary clipper, which clips triangles intersecting the projection plane so they don’t just disappear when they’re too close. Regretfully, it doesn’t look too great yet (I have linear texture mapping to thank for that). The shading that was in the previous version hasn’t been reinserted, and it will probably be a while. There’s still plenty of other things that I want to realise before I get back to that.

The code still isn’t available yet, mainly since the code’s not entirely the way I’d like it. In any case, this project is just a study case for me. But who knows what the future might bring ;)

Check the demo if you feel bored, move around the mouse a bit and use the mouse wheel to change the field of view (and notice how fast it starts to look ugly).

RotoZooming with Pixel Bender

June 9th, 2008

Time for another simple oldschool demo effect as an excuse to mess around with Pixel Bender :) So just like before, you need Player 10 if you’re interested in seeing the result. I only provided the swf this time, so if you don’t have it yet, grab the standalone player here and check the preview. Holding on to good habits, I also provided the source for the Pixel Bender kernel.

I swear, one of these days I’ll come up with something more meaningful! ;)

Pixel Bender and the old-school water effect. I’m in love.

May 29th, 2008

Well, I suppose it couldn’t wait much longer… I just had to get my hands on Pixel Bender and do some tryouts. Initially, I set out to make a simple Mandelbrot set, which was pretty darn speedy in the Toolkit. However, once I turned on the Flash error checks, a few disappointments smacked me in the face. When used with Flash, it doesn’t support loops! Furthermore, it seems you can’t make images from scratch without involving a source sample as your output pixel (I’m not too sure about this, tho, I still have some research to do). So far for the Mandelbrot, coz I’d need both.

But, I quickly accepted those limitations, and started doing an old demo-effect instead; water ripples! It’s a fairly simple algorithm using a displacement map. The map image (the actual ripples) is rendered by Pixel Bender, based on the previous two iterations of the ripple algorithm. I was very excited to see how fast the result was. I can’t wait to be able to use PB for ‘real world’ projects once Flash Player 10 is released and settled in. Anyway, if you have Flash Player 10 installed as a browser plug-in, check out the demo here (you know, right-click views source, including the pixel bender src). If you don’t, but have a stand-alone player, get the demo here, and the source view here.

Strange attraction; representing differential equations over time

May 26th, 2008

I’m not sure why this is worth writing about, but I got bored and in a visit down memory lane, I decided to revisit some of my old DOS-experiments in Actionscript, and enlighten a thing or two on the subject ;)

Chaos theory used to be a subject that interested me a lot in high school for some reason, and when looking at the subject, you can’t skim past Strange Attractors and, in particular, the famous Lorenz Attractor. An important aspect of what this system is showing, is that small changes in the initial state of a complex dynamical system can result in large and unexpected differences on a larger scale (commonly known as the butterfly effect). In this example for instance, changing the initial position just a little, will at first seem to converge with the trajectory of the original position. In later stages, however, it will diverge more and more. Plenty of that can be read in literature, and it’s beyond my scope here. The demo doesn’t really allow you to play around with that either, it only shows the trajectories for the constants in the equations. It’s mainly there for aesthetical reasons, and to give a source code example (right-click on the demo, you know the drill).

Anyway, I thought I’d just enlighten you on how to bring these babies to the screen. Why on earth would anyone even want to put them on a screen? Well, for some reason, I find them beautiful :D But perhaps more important, if you’re looking for complex, unpredictable, non-repeating, but pattern-like movements, you might just end up using differential equations (I’m thinking smoke, turbulence, adding milk to coffee…). Play around with it, and see what you can come up with.

In the case of the Lorenz attractor, the equation goes like this:
dx/dt = σ(y-x)
dy/dt = x(ρ-z)-y
dz/dt = xy-
βz

In practice, this means that over an infinitisimal amount of time (dt), the variables x, y and z will change by the respective left-hand side of the equation. Of course, in programming, we’ll have to approximate the infinitisimal character. We’ll work in steps of time, instead. Obviously, smaller steps will be more correct. Let’s rework the equation just a tiny bit, replacing dt with our time step:

dx = σ(y-x)*timestep
dy = (x(ρ-z)-y)*timestep
dz = (xy-βz)*timestep

So afterwards, we just add dx, dy, and dz to x, y, and z respectively, and we have the next position in the trajectory! σ, ρ, and β are constants that will influence the attractor. By changing these values, there will be three possible situations: the trajectory will converge towards one point, diverge towards infinity, or will endlessly seem to be attracted around a set of points without ever repeating itself, in which case we have a chaotic system going.

And that’s it! Complexity doesn’t need to be complex at all :) Checkout the demo or the source to see the implementation.

MultiMania 2008

May 24th, 2008

Belgium’s biggest web-development event (or how should I call it ;) ) is over again, and the countdown to next year’s edition has begun! And yes, that is just a screenshot from their site…

They had some big names this year, and some very good presentations. Starting out with Aral Balkan, who had lots of valid points and touched some interesting topics (such as the Google Apps engine). He also criticised the direction AS3 has taken - a Java wannabe - which is definately not something to be criticised in my eyes. Coming from a C/C++ background (granted, still in DOS-times), I always got annoyed with AS1 and 2 (I could give you plenty of reasons why) and when AS3 came out, I was finally relieved to have a real and logical OO-compliant language to work with. He also criticised frameworks such as PureMVC (actually, he reduced the whole concept of MVC to a buzzword), and showed us that you can seperate model, view and controller while still keeping a very clean and maintainable structure by just separating them in one source file and using comments… Of course, it was a single page example; I’d like to see a full-fledged application made in such a fashion, on which both several developers and designers are working… I’ve seen plenty of projects turned to rubble because of it. Nonetheless, it is true that the Flash platform has become less of a playground, and I’m hearing the complaint a lot from non-developers. In my eyes, it’s a sacrifice that needed to be made sooner or later. A programming language that invites crappy coding rather than discourages it (I’m sorry, but that’s how I feel about AS1+2), will eventually be less performant and buggy. Besides, a lot of the performance boost that AS3 got, is because of the change in language design (one of the most blatant examples: truly typed variables or classes are faster than generic objects). Then again, I guess the views on that evolution depend on who you are and what you want to do with a platform.
Anyway, enough of that rambling, back to MultiMania!

Wim Vanhenden, despite some technical difficulties, had a rather fun presentation, showing how Air can be used in combination with Flash rather than Flex, and how the Flash platform can be extended to do more interesting things. For example: communicating with Java-apps or DLL’s using socket connections, enabling us to do text-to-speech, use the Mac motion-sensor, and so on…

Stealing the show was Ralph Hauwert, who doesn’t seem to know the meaning of “impossible” ;) Pushing Flash to the limits, and then beyond with seemingly relative ease. His flying teapot was unbelievable! I could explain how it looked, but you’ll just have to see it; I hope he’ll have it on his blog sooner or later. Furthermore, he introduced his latest project called rePhlex. It looks like something to look forward to! In general, it was quite inspirational. The main lesson I got from it, was that there’s always a way and that limitations are just a challenge ;)

Last up was Mario Klingemann who needs no introduction. I’d already seen half of his presentation on Flash on the Beach ‘07, but the second half was all new to me. It’s always a joy to see him solving mathematical issues in an untraditional way; using *gasp* BitmapData! How he comes up with it, who knows, but it works ;) Finally, he demoed his modular image processing tool “Peacock” for Aviary, and tho it looked a bit confusing at times, it could produce some very cool results, that would take quite a bit of time to make in Photoshop:)

All in all, a good day! Hats off to Koen de Weggheleire! :D