Back on track!

Published April 21, 2010
Advertisement
Ugh! Turned out that implementing the game state system into my current codebase quickly got messy. Tons of strange bugs started to errupt. Also, I found that alot of garbage code and inconsistency had creeped into my project over time. Thus I decided to do a complete rewrite of the project from ground up with Game States built into the core from the start. Yes it would take me a bit longer to finish, but I'd get much cleaner code, more consistency and something that I knew couldn't explode at any time (I would take control over my own code again!).

So, the rewrite took quite some time, and I haven't implemented all the systems back in yet (notably collision detection haven't been reimplemented yet).

I now follow a very rigid Factory pattern for creating nodes, objects, states and components. Every new type has to be registered with the factory, it's constructor is protected, so it can only be instanciated from it's friend, the Factory.

I also changed the render system a bit. Now the scene manager gets a flat node list from the root node of the current game state and iterates through it in order of opaque nodes first, then transparent nodese, and sends it to the scene renderer object. I've implemented two scene renderers, one VBO version and one basic glBegin/End renderer. What a difference in performance between those two!!! I now handle the transformation matrix manualy for each node, instead of doing hierarchial glMultMatrix, each node holds onto it's own global transformation, so for each node that is drawn in the renderer, I do a push/pop matrix around a flat glMultMatrix for that transformation. Works perfectly (though not sure if this gives any performance advantages over the other, at least it's more flexible with future shader implementation in mind).

I can now change between states, unload one and load a new one, or just push/pop between states (like level to menu and back again). This works surprisingly well :) Yey!

Yesterday was quite a blast! I woke up early and fixed some issues I had had with picking after the rewrite. Once this was in and I could place towers on the grid again, I decided to spend some time on the graphics since I've done nothing for the graphics up till now. It's only a week until deadline (25. april), so it was time to get in the mesh loaders and such, so that I had time to compensate for unexpected bugs or pipeline mistakes.

I implemented a ms3d mesh loader with animation support, and it was very easy to get it working! I wrote a simple node wrapper that wraps the loaded mesh info into the node render info object, and it just worked. Now, the mesh consist of groups, triangles and vertices. This is a bit different than I have done with the VBORenderer. I'm finding it difficult to see how I can implement it that way without losing quite a bit of performance... So I just convert the mesh info into a flat vertex/index list, which works "ok", but the texcoords and normals are a little bit off.



Naturally, the next step was to get texturing in. I downloaded FreeImage and after some struggeling with setting everything up correctly in terms of OpenGL texture handling, I got it working!



I then started on the heightmapped grid implementation for the terrain. Using the texture buffer data produced by the FreeImage loader, this was fairly simple once I had a peek at the Lighthouse tutorial.



So all in all a very productive day yesterday!

So far today, I've implemented the protected object (the player must protect with from critters) and I've added and loaded misc info into the heightmap (now terrain_info map). It contains the height info in the alpha, path info (waypoints) in the blue channel and the position of the protected object in the green channel. Since each pixel in the map is consistent with each cell in the grid, this works great!

I've just implemented the waypointPath container/object, next up is a PathHolder and PathWalker component for terrain and monsters respectfully. Won't be long until I have the monsters running all over the map now, attacking the protected object! Very exciting week for the project!
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement