Actionscript Flash

Alternativa platform : fog, pixel material and more

As I was looking for some new stuff for the Alternativa engine, intending to start a big new project, I came accross this very good blog by David E Jones.

There’s some really cool stuff there, so I thought I’d try them out – well, at least some of them – still in my demo sample. I quickly picked the pixel material that prevents texture smoothing and the addition of fog. But there are other that are worth beeing tried. I’d like to point out again that Alternativa is entirely open source and that’s why these cutomizations are made possible. I’m not going to give the details as David E Jones describes it perfectly. If you’re interested, here are the links to his posts :

Fog with alternativa3d 8

Turning off texture smoothing alternativa3d 8

Try out the demo :


The other new thing about this demo is that I added an algorithm that assembles each type of cubes into one global object. In this case I have 2 kind of cubes, therefore only 2 objects.

There are several benefits to this :

  • The hidden faces (the ones facing each other) are no longer present, so this relieves the engine
  • The resulting objects have there faces sorted, meaning they have 6 surfaces, one with all the below faces, one with the top faces, etc… this would allow to easily put a different texture to all the top faces for example – which is something I forgot to show in the demo !

Of course, in this demo, there aren’t that many cubes, so the benefit isn’t noticeable, but consider a great amount of them – you know, like in a well known cube game for instance – it may count !

This piece of code achieves this. It was inspired by a mesh-combine method I found :

This is only usable in my demo as it is. It requires a vector of meshes to combine and a map of the cubes as parameters. The map is a 3 dimensional array where 0 is the absence of a cube, other numbers being a cube type, presumably. Checking the map for cubes means it has to be entirely defined. I know it’s restrictive, someday I might give it extra thought to make it as general as possible.

Other restrictions would be that the cubes must be of the same size of course, and must have the geometry of a primitive box created with only 1 subdivision on the 3 axis (widthSegments=1, lengthSegments=1, heightSegments=1). I’m not really sure how to adapt in other cases…

I’m very sure this can be optimized, and I wouldn’t be surprised if somebody did !

In the demo, you can hit the [X] key to toggle from customized controller to regular simple controller, so that you can cancel the collision detection and go check inside the cubes that there are no extra faces !