Tex2D Rotating Header Image

Status Update

Ok, I don’t have screenshots this time :)

I’ve removed another dependency, this time the affortunate class that was removed from my software wash fboClass. Shadower, the first incarnation (and lucky for all of us now is dead, buried, burnt and… everything) of this engine used several external classes (that is not coded by myself), including lib3ds, glm and fboClass.

fboClass is a wonderful collection of classes and utility functions just to handle FBO, and it was nice to use, but now, with that engine overhauling I thought it would be nice to have my own fbo class, and integrate it with my graphic driver architecture.

Well, one less. At the end I would like to have only SDL and Devil as dependences, well, if I add sound I suppose i will have fmod or openAL too, but that’s another issue :)

The simpler the better

You know, graphics is amazing, graphics are interesting, challenging, funny and rewarding. I love reading siggraph papers as much as any other out there, but there’s a thing that I love the most: designing and coding those little helper systems that make your life easier.

Today, for first time in my blog, I will start sharing pieces of code of that pet engine I’m coding at home :) And today’s piece is the tiny Information Item System.

You know, many times you need to get runtime information from the application, information like observer position, memory consumption, frames per second or even runtime profiling information. In previous implementations I had hardcoded that information, that was clumpsy and not very scalable to be honest, so now I had the opportunity to start it all again I decided to do it better, scalable, datadriven and with all those fancy properties that are so cool today.

The idea behind it is very simple, and the system itself is stupidily simple so let’s start explaining it:

I’ve decided that every piece of information I need can fall in one of those 2 categories

  • Text: The information can be retrieved as a string
  • TextTree: The information can be retrieved as a tree of strings

In fact, to be honest, the TextTree was added lately in the design phase, when I realized that profiling could be added to this information system. But having that in mind the design was as simple as it can be.

Every information item would have this properties:

  • There would be only one item for each category (no duplicity)
  • Each item would be capable of gathering all the information needed, process it and format it.

So with that in mind I ended with this UML diagram

Info Item Class Diagram

Info Item Class Diagram

Well, I know, it’s stupidily simple! And of course, at this momment I only need 2 InfoItems (and those are the ones that are implemented).

All this items are stored into a singleton named, let’s be original, InfoItemManager. This is the only place where this info items should be stored.

Info Item Manager

Info Item Manager

Now, how all this thing work?

Pretty easy, on Init time the manager registers all the info items.  Later, on update time InfoItemManager will call to update on each info item, there each info item will process and generate the message that it will return. As I told you, it was easy :)

Ok ok, you will say, the info items have the info, but that doesn’t mean I can use it. Indeed, the information is there, you only need a way to access to it, right?

Each one of the InfoItems have 3 key methods: GetId(),  GetType() and GetInfo().

  • GetId returns the Id type of the info item (FPS, POSTION, OBJECTS and so on)
  • GetType returns if the Info Item returns a single string or a Tree
  • GetInfo returns an union, with a char* in case of being a string or … well, at this momment it only returns that

So here it goes, in case you want to access to, let’s say the Position string you could do something like this

InfoItemManager::GetInstance()->GetInfoItemId(III_POSITION)->GetInfo()


That would return you an InfoItemValue union, that, knowing that III_POSITION returns an string well, you can use it directly to write it down wherever you want.

Well, the code of the manager and the info items can be downloaded here . It’s a bit dirty and such, and it’s exactly how it’s working in my engine. You will notice some weird way to get the position on the InfoItemPosition, and you will see that InfoItemFPS does the actual calculation of the frames per second, but it should be pretty easy to adapt it to any engine (after all they’re only 3 classes!)

Further improvement

Right now this design does exactly what I need, but that doesn’t mean it can’t be improved does it?.  Here are a few:

  • Allowing not returning only strings, but actual data, like vec4.
  • Ensuring that there’s only one instance for each infoitem. That is, in fact pretty easy. Lately, in some of my class hierarchies I’m starting to add an static method named Create in the top most base class. This method takes the type of the object to create and returns an instance of the corresponding class. Well specifiying a Create method in InfoItem we could check if InfoItemManager already has an instance of that method (and it should, Init() method in manager ensures that). If the instance exists we only have to return that instance, otherwise we can create an instance, register it in the Manager and return it.

Well, that’s all, a pretty easy, simple, little example of code. The next one, I’m still thinking if it will be the Graphic Driver or the widgets system.

Stay tuned :)

A rant!

Ok, what the hell were id software’s designers thinking about when they plotted the material files?

I was happy this morning, you know, with my models loading and that things, and i’ve said “hey, wired models are cool, but properly textured models are cooler!” So this noon i’ve started to look to how materials are handled in this otherwise, pretty simple file format.

Imagine my surprise when i’ve found something like:
shader “path_to_a_shader/shader_name”
and only that!

I’ve thought, ok, there must be a file named “shader_name” so I can make an n:1 relation, easy, right? Well, no. Don’t get me wrong at Insideo we had something similar to, each mesh had a reference name to a material, but there was 1 file for each material!

At id thought that it was a bad idea doing it that way, that probably having tons of files would be a bad idea (and I can agree with that). So their solution? having files with a bunch of material definitions there, you can find something like a file named “chars_common.mtr” with that “shader_name” definition in it!!

WTF! ok, I’m ranting just due the frustration of something that could be better. I mean, was that hard to have some kind of translation table? something like “you can find shader_name in the file chars_common.mtr”? In theory what you download with the demo are somewhat production files, aren’t they?

Bah, I suppose they have that table, but they keep it somewhere hidden :) :). Well, as I don’t find it, this means I will code that table tomorrow morning. Now it’s time to go to see how  F.C Barcelona beats Manchester United and we become champions.

Status Update

Yesterday was a happy day :) As I stated in my previous post, I hadn’t tested any of all the code i had written, so yesterday (and the day before yesterday, and in fact the whole weekend) I was commited to test the loader and the shiny new math library.

Obviously it had bugs, several bugs. I spent a whole day with the quaternion class, unit testing it, and testing and testing again. I’m not able to visualize quaternions so it’s hard for me to test them or knowing what to expect when i set a watch in a quaternion during a debugging session :(.

I’m a firm believer that when you’re going to test something, start with simple cases, and later on, you can test harder and more complicated things. So being sure that quaternions were wrong, and that if i tried to test the md5 models i would be completely lost, on monday I decided to add the “feature” of being able to generate simple geometry on the fly (currently only cubes :) and start the testing session.

Da cuba man!

Da cuba man!

Yeah, i know, it’s not impressive, but it helped me to test if rotations were working ok (which weren’t) and if translation obeyed my commands (which, surprisingly, didn’t either). Once everything seemed ok I thought “Toni, it’s time to load the jeep md5 model” . And I did, and … the result was less impressive, or probably for some abstract artists, pure art :P

Abstract art

Abstract art

Ok, there was some problems there, so I went back to quaternions and they were ok, I looked at the loader, and seemed ok, I even wrote several debugging functions to get the state of the mesh… everythin ok. So where was the problem? Mesh indexes seemed to be completely messed up :| so I fixed that and…. Voilá

A wired jeep

A wired jeep

Ok, it’s not shaded and … it looks a bit… clumpsy :) but I like it :) now I can move forward to my deferred renderer, but first I will need to import md5 materials :)

And here end my status update, stay tuned!

Status update

Well, interesting times….

I’ve just removed a dependency :) GLM Math library is an excellent templated library, honest, use it if you want power and a nice syntax. Unlucky for me, I was using an old version (from 2007 IIRC) and it had several bugs. I decided to update the library to its last version, downloaded it, and then … then I realized i only use three math classes: Vec4, Mat4 and Quaternion, so I coded those classes and now i have one less dependency :)

I want to be honest here XDD I haven’t tested them and even when I will use unit testing on them (thank you for point me that possibility shash ;) I’m pretty sure that it won’t work on the first try hehehe.

More! Yes I have more! :D The md5 loader is almost complete, and working… well, after changing the math library, perhaps it’s not working anymore, but it’s there, waiting to load shiny md5 models! :)

Finally, I designed a useful notification system :) I use it in order to gather information from the application, I’m preparing a full article on that because I think it can be useful to somebody :)

And that’s all.. stay tuned :)

Things to do: The Master Plan

This are the things i have to do to be happy again.

Currently the engine still has a strong component system (which affects to its speed) and supports PCF and SSAO with a forward rendering. The idea here is convert it to a deferred renderer, and these are the steps

  • Logging System
  • Ogl Loader
  • Md5 loader
  • Calculate Normals, tangents and bitangents for Md5
  • Create new shaders
  • Deferred Shading
  • Jackpot!

Back from the graveyard

After a long period of inactivity, i’ve just decided to resurrect my components based engine.

The first thing i’m going to do is remove as many dependencies as possible.

Stay tuned!

Toni