Friday, December 14, 2007

OT: Apricot

Apricot is a joint project between Blender and Crystal Space. Blender is the undisputed king of open source 3D modeling and animation systems. Crystal Space is one of the best, if not the best, open source game engine.

Now the pros of Blender and Crystal Space are joining forces to create a commercial grade game: Apricot.

The aim of the game is to prove that open source system can deliver commercial grade games, and to develop the necessary tools and documentations that make open source game development easier.

The game, including its code, art work and documentation will be under the Creative Common License, so that they can be used in your project too. Please support this project by pre-ordering the DVD at the following website:

http://www.blender3d.org/e-shop/product_info.php?products_id=102

It will be a great project!!

Tuesday, November 20, 2007

Crystal Space's users forum is a bit wacky

Is it just me or is CS' users forum a bit wacky? I tried to log into the forum, and after putting in user name and password and clicking the "log in" button, I got redirected to an invalid url. I wonder if any other users have had the same problem ...

Getting help

Well, things have been going ok so far, but I just had a look at CS's APIs and user's manual. They were both useful but also full of holes. Quite a few sections of the user's manual are empty, and the APIs contains a rather large amount of information and it's rather difficult to look for things there.

So, I just did exactly what everybody else would do -- I registered an account on CS' users' forum and subscribed to their mailing list.

The users' forum actually seemed rather empty. I was like the 850th something member, and there didn't seem to be that many posts, I didn't even see any Python related posts ... damn! On the other hand, I also checked out Ogre's users' forum and it was much much much bigger and more active, and there was even a subforum on python-ogre!! I remember reading an article that compared CS with Ogre, and one of the findings was that the CS' users' forum was far less active than Ogre's. Oh well, my observation is a confirmation of that. On the other hand, I also read somewhere that CS' mailing list was a lot more active than Ogre's ... so perhaps all is not yet lost.

Milestone No.3: testing CEGUI in crystal space

Now that I understand how a "hello world" CS application works, it's time to try something slightly harder. Since I chose CS for its integration of Crazy Eddie's GUI (CEGUI), I think it's probably a good idea to make sure that it actually works.

There is a CEGUI testing script distributed with CS contains some code related to CEGUI. I ran this script and it worked exactly the way I wanted -- great!!

Basically, the GUI actually runs on-top-of the graphics. What this means is that it always stays in front of the graphics and is always visible, just like the following picture:




The CEGUI is also event driven, but its event handling functions are separate from CS's event queue -- very nice!

Finally, like most other advanced GUI systems, you can actually define a resource file for the GUI and just load it to your code during the init phase of your application, so there is no need for the tedious process of manually coding the layout of the GUI, yeah!

So, I guess that's it, another milestone achieved. Of course, I'm going to have to lay how to edit the GUI layout of CEGUI, but that would be a milestone in the future.

Milestone No.2: making a hello wolrd application using crystal space's python binding

So, now I have installed crystal space and its python binding. It's time to start learning from the tutorial scripts.

CS comes with 4 tutorial scripts. The first one, tutorial0.py, is the simplest, all it does is opening a window, then quit when you press the ESC key. So, I've decided that the second milestone of my project is to understand how this script works.

So, after about an hour of screwing around with tutorial0.py, I think I understand how it works.

CS has an event driven framework. In other words, it's exactly like Java Swing or any other GUI libraries I've ever used. What this means is that your program basically consists of 2 parts: an initialization part and an event handling part. In the init part, you do all your preparation work such as setting up functions to handle mouse and keyboard events, requesting and registering the plugins and services that you need. Once all the preparation work is done, you just call the function csDefaultRunLoop to start your application and take care of the events as they are generated by the system or the user.

The meat of the first tutorial is in the initialization stage. It starts by creating an iObjectRegistry object to hold all the plugins. The plugins are just services that you can call upon during your game. For example, there is a plugin for doing collision detection, there is another plugin for loading various types of maps or 3D objects from files. Basically, you need to tell CS what services you need before you can use the services .... well duh!

Once the plugins have been requested and registered to the iObjectRegistry object, you have to check them to make sure they are actually there. Once the checking is done, you then need to tell CS which function is going to be handling all the events. This is done through the function: csInitializer.SetupEventHandler. Once the event handling is setup, you just need to actually open the application then start the mainloop. Simple!!

Monday, November 19, 2007

First mileston: getting crystal space installed on my linux box

It's been said that it's very important for amateur game developers to have short and achievable milestones and actually achieve them. So, here is my first milestone: getting crystal space, the game engine of my choice, installed on my linux box.

Since I'm running ubuntu, the logical first choice is to check whether there is already a pre-built package in the repository. A quick check using apt showed that there was indeed one. However, after getting this one installed, I couldn't find any python bindings! A further apt-cache search revealed that there was no debian packages for CS's python bindings ... um.

Well, there is no point in using the pre-compiled version of CS if it doesn't come with python binding, so I uninstalled it and downloaded the CS 1.2 source code.

After screwing around for about 4 hours, I managed to download and install most of the plugins needed by CS, as well as CS itself. I quickly checked some of the demo programs ... they all worked!

The first milestone had been achieved!

Well ... not so fast. It turned out that there were actually 2 cspace.py, i.e. there were 2 python interface files for the CS library! WTH? Which one do I use? There is no documentation to explain this rather strange phenomenon. Um ... I guess I should ask someone I know, but meanwhile, I just have to use the bigger and more recent one then.


Stay tuned!

Sunday, November 18, 2007

Choosing the tools

A game consists of 2 parts: the code and the data.

The code is how the game runs and the data is the artwork of the game.

Since I've been working with Blender for a few years now, I'm going to use Blender as my main artwork tool. Therefore, I need to do decide which game engine to use before I can start throwing my time away.

I already know 2 game engines: Crystal Space (CS) and Ogre3D. From the reviews I've read, CS seems to be better suited for my game because it's more tailored towards games, whereas Ogre3D is more general.

I also really like that fact that CS has extensive Python plugins. This means that I can write my entire game using just Python. Being able to use Python is crucial to me because I hate the complicated template classes of C++, not to mention the need to recompile your code every time you make a change.

Since no game is complete without some GUI elements, I was also pleased that CS provides a plugin for Crazy Eddies's GUI system, this means that I won't have to write my own GUI system just for my game -- thank God!

Furthermore, there is also the problem of map editing, i.e. how am I going to create the maps for the players. Since this is a monopoly game, I think 2D representation of the maps should suffice. This just means that I need a drawing tool for this task, a tool that can create data structures that can be directly used to create a 3D representation of the Monopoly world. There are quite a few open source drawing programs available, e.g. xfig and dia. However, I'd have to write a parser for their data files to be able to use it, and that's probably a non-trivial task by itself. So I think I will have to write my own map editor. The thing that immediately comes to my mind is Jython. Jython is a Java implementation of the Python interpreter, and it can access all the standard Java libraries. Since I'm a huge fan of the Java Swing library, I will be writing Python code that uses the Swing library to do my map editor, and save the map data structure in Python pickled format so that my real Python code can use it.

So, here is the summary of my main tools and how I intend to use them:
  • Blender: Creating 3D models
  • Crystal Space: Game engine
  • Python: Main programming language
  • Jython and Java Swing: Map editor
There will be other libraries that I will need to use for other things and I will talk about them as they come up.

Stay tuned!