Simplui 1.0.2 released – now with themes!

The default themes provided by simplui

The default themes provided by simplui

Today brings the 1.0.2 release of simplui. This is a beta release, previewing major enhancements, and I need as much feedback as possible on the new features. As such, this release isn’t heavily optimised – that is on the wishlist for next release.

The big news for this release is themes support. The GUI is now fully skinned, using a variant on the ninepatch method code developed by Joe Wreschnig and Alex Holkner on the pyglet mailing list.

Each GUI frame can use a different theme (even in the same time!), and the theme can be changed at runtime. I have included two sample themes, one modelled on the Mac OS X ‘Aqua’ interface, and the other on the PyWidget GUI toolkit.

Also included are the usual crop of bug-fixes, including the squashing (hopefully for the last time) of the persistent event clipping bug.

As per usual, grab the tarball, or visit SVN, and let me know if you have any comments or suggestions.

Starfall: planet rendering

I just posted a quick youtube video to demonstrate the current state of the planet renderer. This is early development stuff, and the eye candy is minimal, but it should give you some idea of the scope.

I will follow up with a more technical blog post in the next few days, explaining all that is going on behind the scenes, and can’t be seen in a video.

Part of the rationale behind this video is to stremline the whole video capture and posting process. Unfortunately, it hasn’t been entirely straightforward so far. I went through a number of video capture tools before settling on FRAPS, which works well enough (though I would have prefered a free tool).

I also have had a terrible time converting the video for youtube – ATI’s Avivo video converter is blazingly fast, but apparently produces an incompatibe audio codec in any of the high-quality settings. I was forced to fall back to the CPU-based Auto Gordian Knot, which both does a worse job, is very slow on my little Athalon 64 x2.

I am now experimenting with ffmpeg, but the command line options are confusing to say the least. If anyone has any clues/tips/tricks for getting FRAPS encoded video (and audio) into a suitable format for youtube HD, please let me know.

simplui 1.0.1 released

I am going to be performing a number of small releases for simplui over the next few weeks, as features are added and bugs are patched.

Today’s 1.0.1 release introduces a slider control, docstrings for all widget constructors detailing the keyword arguments, and a couple of bug fixes.

You can grab the release tarball, or check out the code directly from SVN.

If anyone feels like taking it for a spin, I could do with bug reports and feedback on the API.

simplui v1.0 released

A quick demo of simplui's controls and capabilities.

A quick demo of simplui's controls and capabilities.

I like pyglet a lot. Much more than a lot.

However, the lack of a compelling GUI toolkit for development purposes has been a major irritation of late. This week I finally sat down and wrote my own GUI toolkit, from scratch, and I am happy enough with the way it works to release a first version to the public.

Continue reading

Sprite collision revisited

There have been a couple of requests here and on the pyglet mailing list for my code to perform pixel-perfect sprite collisions. I finally had a bit of down time, post-exams, and put together a demo, complete with source code.

The source is pretty clear, and thoroughly commented, so it should be very easy to follow. The demo is very simple, but the concept translates to more complex applications as well. 

You can grab the source directly from my googlecode subversion repository, or if you preferrer, there is a tarball.

Let me know if you have any issues, or questions about the source, and note that it does require a fairly recent version of python (2.5+, for generator expressions and the built-in set class).

Procedural Planets

Normal-mapped planet.

Normal-mapped planet.

The semester is over at last, and my grades should be in by Monday. It has been a tiring semester, but not a bad one, with interesting courses in database implementation and parallel architectures, not to mention philosophy.

With the end of the semester comes a little more free time, and I have spent a chunk of it recreating my old procedural planet demo in Python/Pyglet.

The first big plus is that whereas my previous implementation was over 5,000 lines of C++ code, the python version is under 1,000 loc, plus a few hundred lines of tightly optimised C for the tile generation back end.

The other plus is that this version actually works. I finally found the time to fully implement the crack fixing algorithm, and the results are very good (although there are still a couple of unresolved edge cases).

I also implemented normal map generation in GLSL, to offload the computation to the GPU. This more than doubles the performance of tile generation, to the point where several tiles can be subdivided or combined each frame.

Wireframe of planet.

Wireframe of planet.

From a technical standpoint, the planet starts as a cube, and each face is subdivided to form a quad tree. For each tile at the deepest level of the quad tree, a small heightmap is generated using 32 octaves of 3-dimensional simplex noise. This heightmap is used to generate the vertices for the tile, and passed as a texture to the GPU in order to generate the normal map.

Because applying tangent-space normal maps to a sphere is an absolute nightmare, I take the unusual approach of generating object-space normal maps. These are considerably more expensive to generate, but avoid the tangent-space mismatch at cube edges, and look fairly decent in practice.

Interestingly, this version allows one to fly right down to the planet surface, and maintains interactive framerates even on my Intel integrated X3100 (complete with the awful Mac drivers). By the time I add atmosphere shaders and detail textures, I expect that I will have to switch over to my desktop, but for now, I am very happy with the performance.

Of course, there are still several challenges to overcome, in particular the issue of depth buffer precision. The planet you see above does not suffer from a lack of depth buffer precision, but it is only 1/10 scale of the Earth, and ideally I would like to be able to render gas giants on the order of Jupiter as well. This requires some clever on-the-fly adjustment of the camera frustum, and I don’t quite have a handle on the best way to accomplish it.

Love

If you haven’t already, go watch Eskil Steenberg’s GDC videos of his game Love, and the tools he uses to build it. The game itself is fresh and beautiful, but as an programmer, it is his tools that have blown me away.

The last game development tool to really catch my fancy was Carmack’s co-operative world and megatexture editor for ID Tech 5, which was demoed back in 2007, but I can honestly say that it pales by comparison to Eskil’s tools.

And the best part? All of Eskil’s tools are open-source.

Ashima IV – a brief postmortem

A couple of weeks ago I submitted a space sim to the udevgames competition (see my previous blog post). Ashima IV didn’t win any prizes, but that was hardy unanticipated, given that the game was barely to a playable state. Overall, I think the experience was very rewarding, and I hope a few of the lessons learned can be informative to others as well… Continue reading