Tuesday, November 18, 2008

Random things..

Before getting carried away with the platformer rambling, again, here's something about PolyAnim. Yesterday I added automatic polygon triangulation for concave polygons into PolyAnims LWJGL-renderer. This is mainly for convenience, since the triangulation is quite expensive - it remains to be seen if this is fast enough for more general use. At least with simpler scenes it might work alright. Convex polygons should still be preferred for speed reasons, but I admit it: they're major pain in the ass when animating. It's cumbersome to build and animate non-convex shapes from several convex pieces.. Hopefully somebody will contribute faster triangulation code at some point! ;)

What else.. I've been working a lot on the platformer engine. JBox2D got an update, so I ditched the old polygonal approach (which had a lot of problems, as Box2D is very picky about the shape of the collision polygons) and implemented the collision geometry using the new feature: edge chains. They work nicely and are just perfect for this kind of usage. I use triangulation with convex decomposition now only for the renderer, which luckily doesn't mind very thin triangles. I've added more eye candy as well, generation of level outlines and support for background/foreground polygons (which are not collidable, of course). I still need to implement other decoration elements, such as a stripe of grass blades running along top edge of things, for example. Parallax scrolling is something I want to have in too, I mean, if you're making a side scroller, why shouldn't there be parallax scrolling!? =)

And finally I did bite the bullet and implemented those damn PBuffers (enjoy the picture there, that's them buffers giving me hard time!). They work okay when FBO is not available, but they're yucky to code. Luckily LWJGL makes it a bit less painful than it truly is. Looking back, in Funguloids things were almost too easy, as I had Ogre at my disposal! Along with PBuffers the thing now supports plain old frame buffer copying as well, though I couldn't be bothered to make bloom work with it (lighting does, though, which is more important anyway).

While fighting with PBuffers, I noticed I could make the bloom much faster and more importantly allow for more shader effects if I used RTT (render-to-texture) same size as the screen dimensions. I could then render the scene only once to the RTT (currently I have to render twice!), have bloom shaders use that and actually do the final additive composition in the fragment shader too. Having a screen sized RTT would allow some neat shader effects like screen distortions and shock waves. There's one problem, many cards don't support rectangular (non power-of-two) RTTs.. The solution: separate rendering paths. I would implement several render paths with varying amount of shader and RTT usage, then determine what the host system supports and have things running nice and solid. Sounds like bit of work to me, but I guess the end results would be worth the trouble. We shall see. :)

Oh, and I've finished my bachelor's thesis, like a month ago. Forgot to mention that earlier. :P Now I'd need to decide if I continue to write master's thesis on the same subject, or choose something completely different. If only I could think of a subject having to do with game programming, that would certainly help with the motivation..

Monday, October 20, 2008

Shader goodness: Bloom!

In the last post I talked about lighting, this time it's shaders and more specifically bloom. I must say I like the effect when it's used subtly as a mood enhancement and dislike it in it's quite common burn-your-eyes-out -form..

For the platformer game I'm planning to use the effect for a nice and quiet dreamlike feel, although I'm still not sure what kind of game it will be (except that it's a 4-way scrolling platformer!).. And as I often do, I find myself getting carried away doing all sorts of graphical effects (lighting, shaders) when I don't even have the basic game mechanics in place! Can't help it though, I must have some eye candy going on to keep myself motivated in a project. *shrugs*

So I coded a quick & dirty shader support to the engine, and today I've been trying to get the bloom working. And now it does. :) I'm still not done with it, needs some tweaking - and that's somewhat impossible right now since I have no final assets for the game yet! Everything you see in those screens is temporary and/or random. For anyone interested, here's some technical details on the subject.

I based the implementation on the GLSL bloom shaders from Funguloids, which in turn are modified from Ogre sample shaders. I'm still a beginner with the shader programming as I may have mentioned, so having anything to work from was invaluable. I tweaked the shaders to get the subtle look I was aiming for.

I'm using two small render textures (which are FBOs, no support for Pbuffers yet - and I think I'll have to do those at some point, as my laptop doesn't support FBOs), 128x128 in dimension and one bigger 512x512 RT. I render the scene normally to the bigger RT. The blurring is then done in two passes: first the scene RT gets rendered to 128x128 RT #1 using a horizontal blur shader (it also does some luminance stuff to have the bright parts more bright and dim parts more dim). Then RT #1 gets rendered to RT #2, this time with a vertical blur shader. Finally the RT #2 contents are blended additively over a normal 1:1 render of the scene. It needs quite a lot of tweaking, but I think it looks quite nice now.

In another news, my thesis is now almost complete! ^^

Thursday, October 16, 2008

Let there be LIGHT!

Wouldn't you know, after I complained about lack of coding motivation in my last post, I started hacking at my Java platformer engine the very same evening! I finished the Inkscape SVG importer, now I can create the levels in Inkscape using polygons, rectangles and circles.

Last couple of days I've been implementing a lighting system to the engine (and preliminary scripting support before that). The lighting system is based on very simple ideas and was quite easy to implement. No troubles whatsoever, I was actually surprised. First I was contemplating on doing it using pixel shaders, but that would've required much more work (still learning the shader stuff) and I'm not sure if I could have pulled it off anyway. I still need to incorporate some shader support to the engine if I want to have a bloom effect later on.. Pixel shader lighting would have allowed to have normal maps for the textures though, now that would have looked very nice if done properly! Oh well.

Instead I went for texture based approach using a single FBO (Frame-Buffer-Object) where the lights get rendered to (additive blending naturally). Then with help of some stencil buffer magic, the light map is rendered over the scene using multiply blending. Stencil buffer is needed because it makes no sense to render the lights/shadows over the background (i.e. sky in my platformer). That would be very unrealistic (you can't really cast shadows on the sky, now can you?) not to mention ugly. For top-down games no stencil buffer would be needed, unless the area that gets lit must be restricted somehow.

This technique allows completely dynamic lights of any shape (like flashlight cones) using one render-to-texture (FBO in my case). The light map doesn't even need to be large, since (at least with soft lights) it's hard to see the difference between 256x256 or 512x512. I'm using 256x256 currently, but even 128x128 looks fine. The system works nicely and I've yet to optimize anything about it: for starters I'm currently rendering each light, no matter if they're actually visible or not!

Overall it suits my purposes perfectly - carefully arranged lighting can make a tremendous difference in the feeling and apprearance of the game. :)

Here's a few sample screenshots. Please ignore all the graphics etc., as the level is just random polygons and lights are literally randomly generated. And the background is lifted off Jewels. :P


Wednesday, October 8, 2008

Long Time No See

So what's going on for me in these days? Well, that depends.

Not much coding, unfortunately (or is it unfortunate, don't know really.. :P). The fact is, while the Qt Jambi patch is now out and indeed fixed the problem I was having, I haven't found out the motivation to work on the editor. That doesn't mean I've abandoned the project, not at all. I have these periods when I just don't feel like doing much hobby coding, if any. But no worries, some day I find myself hacking at it like no tomorrow! ;)

Guess what has been draining my free time recently? PS3. No kidding. PS3, that black monolith, a product of pure genious (not unlike the monolith in 2001: A Space Odyssey!). That's mostly what's going on here! Oblivion (GOTY edition), GTA IV, Uncharted.. Oh, and the wondrous Blu-ray capabilities!

Speaking of movies (well, technically at least), I finally updated the movie list with latest additions. Unfortunately I had forgotten most of their purchase dates and prices, so I couldn't add those.. Note to self: enter new movies to the "database" in much shorter time span from the purchase than this. I'm also celebrating my first Blu-ray movie, I Am Legend. It was a nice flick and the picture looked awesome even on my 32" HD-ready TV. Looking forward to having more BRs. ^^ (damn they're expensive, though!)

In other news, I'm still working on my Bacherlor's thesis.. Hopefully I'll get it finished in few weeks tops. That is all for now.

Saturday, August 23, 2008

A quick update..

I haven't been coding much, but instead writing my Bachelor's thesis. There's still plenty of work to do before it's finished. Well, serves me right for not starting it earlier in the Summer like I intended to.. ;)

School starts in September again, yawn. The Qt Jambi update I'm waiting for might also happen in Sept.

Oh, I went to see The Dark Knight again - it was even better this time, like I thought it would. 5/5 it is.. :)


Friday, July 25, 2008

Why so serious?

Saw The Dark Knight today. Awesome movie! I'm still digesting it, but it feels like a solid *****/***** for me. Now, just waiting for the dvd release.. :)

Sunday, July 20, 2008

Somewhere Back In Time 2008


Just a short post, for a change: Went to see Iron Maiden yesterday, it was great! \m/ Above is a photo I took - one of the few that actually turned out alright..

In addition, I managed to wash my cell phone in 40 degrees Celcius two days ago. It doesn't work any more. :(

Oh, and PolyAnim now has some Java Web Start demos up at http://code.google.com/p/polyanim/wiki/WebStartDemos..

Sunday, July 13, 2008

Inkscape to the rescue!

You know what, after starting to write a simple editor to be used before the proper animation editor gets finished (not anytime soon..), I started to think - what am I doing? Why to make a crappy editor, while I could use something else to do the job, and way better (yet I hope and believe that the custom made editor will be the most comfortable way of creating the animations).

Once again, Inkscape proved its worth. SVG was relatively easy to parse (except the damn transformation matrix - I wasted hours searching for clues how to decompose the original scaling and rotation from the matrix, finally got it working though..), and the Inkscape layers turned nicely into animation key frames. It requires quite a lot of patience, and my conversion tool is dodgy to say the least, but it will enable the creation of animations for PolyAnim!

So I wasted more hours, and created the very first proper PolyAnim animation, in Inkscape. After seeing the animated dude moving on the screen, I felt very pleased about how it all turned out. :) Rare moments, those. Hell, I even made a video to celebrate the event! ;) In case anyone would want to try the Inkscape route, I also wrote a tutorial about it.

Check out this screen shot from the demo, and compare it to the earlier shot a post or two back.. The biggest dude is the original, the others are rendered using the various render modifiers.

Friday, July 11, 2008

PolyAnim progress..


Well, I've made a logo. See? ;)

Okay, there's a bit more. The core library itself is in (somewhat arbitary) versi0n 0.5. Most of the important functionality is in there already. Anchors and different blending modes are still missing. Read more about the current state of features here.

There's still a big mystery in this project, for I have no idea if the code is fast enough for the intended usage (which is game sprites)! The tests I have made are composed only of a few polygons, which is not very demanding.. Therefore I've started the work on the animation editor, using Qt Jambi. But alas, I have bumped into a severe bug, which unfortunately crashes the Java VM. While waiting for that to be solved (the bug fix is scheduled for the next Qt Jambi patch release), I'm wondering what I'm going to do in the mean time.

Should I hack a quick and dirty editor in Swing? Or work on the other (unimportant) parts of the real editor? Implement more features to the library? I don't know, I'd rather not add more stuff to the lib, because in that case the editor's going to have a lot of catching up to do.. :P Perhaps I could throw together a stress test using lots of random shapes.. Hmm..

Or I could succumb to the goodness that is (J)Box2D, like I momentarily did about a week ago. I made some platformer physics tests with it. Good stuff. :) All this is obviously for a grand purpose: finally making a (platformer) game that's perhaps a bit more than just nice and simple 10-30 minutes fun. That's my intention anyway, we'll see what happens.

Friday, July 4, 2008

Introducing PolyAnim!

I decided to unveil the project I've been working on lately. It's a polygonal (i.e. vector) animation library called PolyAnim, now up at Google Code. First things first: I'm not trying to compete with Flash, this thing is mainly meant as a game sprite replacement. :)

Too bad there's still not anything nice to show yet.. :P The stuff I have so far is a few hard coded animations consisting of couple of triangles and squares, it's not very sexy to look at, mmkay? But all that will change once I get the editor going and can finally make something cool with this thing. So, be patient. ^^

Just to prove I've achieved *something*, here's an ugly screenshot of the test program. I'd say it looks better when it's animating... I mean, really. Hey, it really does.. *sigh*

Tuesday, June 24, 2008

Getting tired of C++?

I'm starting to notice, that I've been probably spoiled beyond all redemption by the wonders of Java and Python. And by that, I mean the general relaxed feeling when developing, such as not having to deal with memory management* and so on. As I've been working with Java and Python all this spring (plus we use Java at work), now writing C++ for the sekrit projekt(tm) feels cumbersome.. Dealing with const references, virtual destructors, templates and whatnot just doesn't have the same effect for me it once did.. What's happening to me? Am I really getting tired of C++? :/

But wait! There's more.. *bows head in shame*

I've been further tempted to the Dark Side by my very recent interest in Qt Jambi and LWJGL.. :P I mean, what the hell, is there really anything stopping me of doing the sekrit projekt(tm) in Java, using LWJGL and Qt Jambi for the editor (ooops, slipped that out!)? I think not!

So.. Perhaps we hear more about these shocking developments later on. Perhaps.

*) Incidentally, I'm doing my bachelor's thesis on "Automatic Garbage Collection In Programming Languages".. ;)

Saturday, June 14, 2008

Intellisense in Visual C++ Express, and getting it working with Qt 4.4

Visual Studio Express editions are nice and free, but Visual C++ 2005/2008 Express seem to be lacking in the code completion (or Intellisense as it's officially known) department. If I recall correctly, in MSVC++ 2003 (version 7.1, that is) Intellisense worked perfectly. When writing new code, Intellisense picked it right away, even without saving the source file. I never had any problems with it.


In MSVC++ 2005 and 2008 (Express editions, I haven't tried the full featured versions - although I doubt they'd work any better..), the code completion has definitely taken a step backward. It just doesn't work as nicely as it did in MSVC++ 2003. It seems to parse the source files quite lazily, and sometimes just doesn't work at all. When given a moment, it works again. I've found out that switching between Release and Debug from the toolbar dropdown causes "Updating Intellisense..." to appear in the status bar. That helps, but it's still not very convenient.


As I recently installed and compiled Qt 4.4, I noticed that Qt classes would not be in the code completion list at all. I included Qt's include-directory to the "VC++ Directories" in Options. That wasn't enough. Finally I got it working by including "$(QTDIR)\src" to the "Source files", and listing all the Qt include subdirectories separately in "Include files".



Monday, June 9, 2008

Status update

Just a quick status update: school is now over (apart from one exam), the application project course that lasted for four months is also finished. I'm glad that it's done. :) I've started going to work as well.

My sekrit projekt(tm) is proceeding, albeit quite slowly. Today I have coded it a lot, though. It's still too early to be shown - not that there is anything interesting to show in any case.. Not yet. But fear not: I'll write about it once it is developed a bit more. ^^

So yes. I'm still alive.

Monday, May 26, 2008

Plans for summer - Revisited

Change of plans: I don't think I'll do the CSSTint-rewrite this time.. I've got a much more interesting idea. While it's still too early to talk about this, it involves Qt 4.4 (yay!) and OpenGL. I will write more about it when (or if) I have something to show. =)

Right now I'm wondering whether to go with SourceForge like I always have, or to use Google Code. Google Code seems nice and simple, as I'll only need SVN and some pages (or a wiki). And yes, it'll be open source. ;)

Sunday, May 18, 2008

"Jewels" version 1.0 is out

Just wanted to mention that version 1.0 of Jewels is finally released. I'm glad it's out of my hands now, phew! :) Download it from http://www.codeplex.com/jewels.

"Jewels - Now with a Game Settings -menu!"


Thursday, May 8, 2008

Qt 4.4 released + plans for summer

Qt 4.4 framework was recently released. Hopefully PyQT 4.4 soon follows. Qt just rocks. =) Having been working with Java Swing (*cough*h o r r i b l e*cough*) these last four months, Qt 4.4 brings some light to the end of the tunnel..

Now that that's out of the table, I can talk a little about a project I'm perhaps going to do next summer. It's about remaking CSSTint. While I think the current Windows version of CSSTint is quite nice, it's still... well, Windows-only. While I am using wxWidgets, it's still doesn't work in Linux properly - I have tried. I'm doing some nasty, ugly hacks in the code, so no wonder. All this could probably be fixed, but for the sake of learning and for an interesting experience, I've been thinking of rewriting the whole shebang.

I'm sure I will use Qt for the job, but I'm still undecided between C++ and Python. Learning Python has been interesting for me, as I've blogged before. Python version would also work on Windows as is, which won't hurt even if the original is also for Windows. On the other hand I could reuse some of my non-GUI CSSTint code if I went with C++.. Decisions, decisions...

Anyway, that's my current plan - things might still change. :)

Sunday, May 4, 2008

Why my stuff is Open Source?

I have several reasons why most of my games and programs are Open Source. Here are some of them.

Let's consider an example. Why is Formido available for Windows, Linux, MacOS X, BeOS, Xbox, AmigaOS and even OS/2..? The answer is obvious. Should I have kept it closed source, it'd be for Windows only, and maybe Linux.

Here's another example. Recently I was contacted regarding a bug in Funguloids that prevented it from working with Ogre versions 1.4.6 and newer. I had no idea of this bug, as I haven't personally touched the game since its last release, which uses Ogre 1.4.1. Things have been happening on the community front however, as Funguloids has found its way into Ubuntu Hardy (for which I'm very grateful! :)) After exchanging a few e-mails, the person who reported the bug presented me a patch (an one-liner, even) that fixes the problem. I didn't even get started examining the issue myself! Very nice.

Also, as I have learned a lot by reading source code, I feel kind of obliged to do the same.. I'm not worried about people stealing my code - the code's not that good to begin with. ;)

Monday, April 28, 2008

Why I use Linux more than Windows on these days..

Yesterday I dug up my Jewels-project from under the thick layer of frost it had gathered during the winter days. As it is a XNA-game, I have to boot into Windows to develop it. I installed XNA 2.0 and started porting the game. After a few head scratchers I finally got the game working properly in XNA 2.0. Great!

I'll try to finally finish that game, so I have been making some improvements and fixes. I need to add the timed play mode, and the do the game settings menus.. *sigh* Damn, why games must have settings menus..!?

Anyway, I noticed that I needed a key typing sound for the highscore screen where the player enters their name. You know, the old typewriter sound. So, I browsed my earlier game sounds, found a sound, double clicked it. Winamp starts. At this point it occured to me: oh crap! I have Winamp set to playlist looping, which is what I like when I listen to music. However, double clicking a file replaces the current playlist and plays the single file looped. In case of a short sound clip, the sound repeats quite often. It sounds a bit annoying, but that's not the worst effect here.

You see, on this machine, Winamp somehow cannot handle a short sound clip played on repeat (I only remembered that *after* I had activated the file!) - it crashes. And hard. So Windows presents me a message the Winamp had to close. When I click on Close, the computer reboots cold. Same as when I press the reset switch. And that annoys me. This has happened several times, and it's annoying. A cold reboot doesn't exactly do wonders on your HD.. :(

When Windows finally comes up (that's another thing, it takes ages to start up - although I do have years worth of crap installed, so no wonder..), it presents me a familiar little dialog:


Feels like coming home.

Saturday, April 26, 2008

My adventures with Python / PyQT

First of all, let me just say that Python + PyQt just rocks.

I've been recently learning Python. Just for fun, basically. Additional benefit is that now I have a better understanding on how to cope with Zope/Plone at my work. Anyway, apart from the Zope/Plone stuff the first thing I did in Python was a command-line script that allows creation and handling of .mpk files that I've used in a couple of my games. MPK or MPak is a simple WAD-like format that stores all the game files in a single package file. I had a C++ CLI application that did the job, but it was really a piece of crap..

So I deciced to write a replacement for that app, in Python. The finished script (mpak.py) is much nicer to use and works better. I wrote it in Linux and it worked as is in Windows too - neat.

Then, I wanted to try GUI stuff and went with PyQt. I had a simple DVD collection management software called MyDVDCollection that I had written in .NET using C#. It worked, but was not too good either. So I began hacking away with PyQt and now I have PyDVDCollection (pretty clever names, huh? ;)) that I use for maintaining my collection. It has less code and more features than its .NET counterpart. It works in Linux, naturally, and also beautifully in Vista.

As you can probably tell, I'm very impressed with PyQt and the Python language, and I'll be using them in the future as well. =)


Friday, April 25, 2008

I Have No Delete Key

Ubuntu 8.04 LTS aka Hardy Heron was released yesterday. I had previously installed 7.10 aka Gutsy Gibbon on my new laptop, and upgraded to Hardy last night. The update process went quite nicely, except for one strange thing: my delete key no longer works! O.o

When I press delete, the laptops WLAN led goes on - nothing else happens. When I press it again, the led goes off. [Homer impression:]"Led goes on, led goes off, led goes on, led goes off...". (sorry about that - just when they're going to release the season 11 on dvd!?)

On this laptop (Acer Extensa 5220) the WLAN led is always inverted in Ubuntu; when the WLAN is in use, the led is off. That doesn't bother me at all. However, I would like to get my delete key to work again. I use that one quite a lot in typing/programming, and well, in deleting things...

I made a thread about this on the Ubuntu forums, but so far the problem remains a mystery. Other than this little annoyance, Hardy seems very nice. And it works quite well in this laptop.

Update: Turned out it was a known bug. It works now. :)

So it's finally come to this..

Yes, I've started a blog. I'll try to write here at least somewhat regularly, but knowing me, it's probably not going to work.. ;) I'm quite busy in school (a software project course going on right now, it's big!) at the moment, but I should be able to do more this summer. On the other hand, I do have work then and I'm hoping to write my bachelor's thesis too.. So we'll see. I have some other plans too, but I'll talk about them in another post.

And that's that. I guess this shall do as The First Post(tm).