maanantai 20. helmikuuta 2012

Components entities properties and heightmaps..

Currently I am in process of creating Component/Entity based architecture, more precisely, a pure component model based architecture, with sugar coating on top.


Sugar coating goes as far as to creating classes, that inherit from Entity, and the functions being just wrappers, that call different properties, set them, initialize them, create them. 
What has gotten me worried lately, is the granularity of the properties; at the moment I have the location properties, scenegraph properties, text properties, name properties as separate things, this could cause locality proplems.. One thing would be to combine LocationProperty and SceneGraphProperty, and pack the data tightly, hopefully increasing locality.
But on the other hand, this sounds like premature optimization, if needed, I can merge properties later on, creating SceneLocationProperty.


Well anyways, I removed the depthbuffer problem..



Another thing that I am pondering about is the landscape rendering, how to do a heightmap rendering? I thought of loading data from images, but that is too limited, having only 8 bits per vertex for height just doesn't cut it. Next I went and thought of loading obj files packed in gzip files and using somesort of quad-tree to organize different pieces of the map together. But this too is a bit of limited. My current idea is saving n obj files logically, in a tiled pattern to disk. mapname_LEVEL_X_Y_Z.obj where LEVEL is the 'level of detail' level and X,Y,Z are the indexes of the tiles, LEVEL 0 tile size would be 10meters*10meters*10meters and if such file was not found, then that level of LOD is not supported. The LEVEL LOD works using n^2, so that level 0 is 10m, 1 is 20m, 2 is 40m, 3 is 80m .. etc.
For test purposes, I will first implement this using obj files, later on, when I see some results, I might create either my own filetype for the data, or use some, more sophisticated format, than obj.


The third thing that I wanted to share, was these few C++ patterns, that I've started using, quite a lot..
First, the templated Singleton, with this the classes do not need to specify a singleton inside the class (reinventing globals! :D.. with sugarcoating.). 
Second pattern is the Merge class, that can be used to merge, through multiple inheritance, two classes into one. The verdict, whether this is good idea, is still out, but I like a lot about the idea of having the ability to merge std::mutex with whatever the mutex is meant to lock. eg. Merge< std::vector<int> , std::mutex > myVector; and locking the vector by std::mutexlocker lock(myVector); , this way I use it in the Pipeline.


perjantai 17. helmikuuta 2012

Continuing on bolt framework

Some refactoring... I received some comments about the use of exception specification in functions ( virtual void foo() throws (std::exception); ) ( http://www.gotw.ca/publications/mill22.htm ). 
With exceptions I tried to convey the idea, that the function throws exception at error, but in c++, if the function throws something else than the specified exceptions, the program will crash and burn. The crashing and burning would probably create sleepless nights and odd error situations in the end, so I've decided to conform to 'no exception specification at functions' style.


Another thing that seemed like a good idea, in the beginning, is the const variables, ( void fuu( const float bar ); ).. the idea behind this, was that at the end of the function, you could still trust the bar to be what it was in the beginning. Totally useless concept, trust the programmer to know what he is doing, polluting the code with useless const's (many tiny reasons.) adds to code bloat, possibly slower etc. Use const with references.


Otherwise, I have added first test of landscape rendering, rendering a quad on bottom, unfortunately I forgot to take out the depth buffer clearing, so the tiny cubes, seem like they are behind the landscape.

tiistai 14. helmikuuta 2012

Blogging.. I've never really paid much attention to them, I got the idea to start blogging, from my brother, as a way to clarify my thoughts about the tech, patterns and architecture.. techs that I create and use in my framework for games. The tech is heavily based on open standards, with plattform independency in mind..

The long term goal is to create a rpg game, loosely based on Kalevala, but also taking heavy influence from modern fantasy literature, games and modern fantasy culture.. So even though, Kalevala describes people as village peons, without any glorious kingdoms, I think, that kingdoms et al will be added..

The currently used tech in Bolt framework is:
  • OpenGL (3.1+, preferrably going to use gl4.x)
  • OpenAL
  • glew
  • glfw 
  • C++11 (std::thread, templates, stl)