Saturday, August 14, 2010

NextGenRacer - Friction


Another cool feature was the friction map I implemented. The requirement was that the cars wheels would have to behave differently on oil, grass and the road, independently.
Every other team decided to go the bounding radius way, which bogged down their programs considerably. Since we had a continuous customizable track rather than a given track comprised of sections (a requirement we decided to boost also), we couldn’t use bounding radiuses, also bounding radiuses weren’t ideal considering the oil slicks sphere would be in a tracks bounding sphere.
I designed a system very similar to a height map in the sense that for a given resolution, we would have the friction values for every point in the world (using interpolation). Now to build this map, I would render the custom track and the oil slicks separately in the stencil buffer with given values, and then save that buffer into a 2D array with given min and max world coordinates in order to map table indices to world coordinate. This would let us query our friction data in O(1) time, let us create wacky and wonderful tracks at runtime in our editor, and have very high resolution friction data.

The image that follows with the green and red dots all over the map show the data in a very low resolution way for debug purposes.


Friday, August 13, 2010

NextGenRacer - Physics


One of the requirements at about halfway through the project was to have implemented our games physics. Now after doing that, we were sort of bummed of the results. First off, well it was 2D physics in a 3D game se we would have barrels, but they would just slide around which was less than ideal.
After a short discussion with my team mates, I decided to branch our project and set out on a journey to integrate a physics engine. I did some research and considering the short timespan I had to get things up and running, I quickly forgot about the full featured engines like PhysX and Newton and grabbed a simple engine called Tokamak. The api was really simple and since our architecture was component based meaning that every game entity could have components that could act upon it, much like the unity engine, it was really simple to integrate. I had some problems at first with the lack of documentation, but after some trial and error we could add stacks of tires and ram them!

Tokamak Physics

Thursday, August 12, 2010

NextGenRacer - Particles


One of the first extras I added to our game was implementing a particle engine to add a little razzle-dazzle. What I found most surprising was the effort to results ratio of adding particles to a game. I mean, a particle engine is quite simple; you update particles with positions, speeds, and orientations and then you billboard them all over your scene towards the camera with some alpha blending. It seems as though that was the most talked about feature of our game, and yet I really didn’t feel as though this was the coolest feature we added. Especially considering the next feature, which I spent so much time on!

Wednesday, August 11, 2010

NextGenRacer - Rendering


What I am most proud of is the OpenGL rendering engine I implemented for our game. I implemented a per pixel Blinn-Phong GLSL Shader for the lighting that could calculate the effect of up to 8 lights (Point, Directional and Spot) per Game Object, which meant I could pretty much have as many lights as I wanted in my scene. Not having written any GLSL Shaders before, and being it was 4th year notions, I’m really happy with the fact that I implemented it in the last week before the final deadline and that it worked. The rendering pipeline also supported transparency, billboards, animated textures and a skybox with moving clouds.


Tuesday, August 10, 2010

NextGen Racer - Intro


As my second year project, we had to implement a racing game in C++ and OpenGL with a Java interface using JNI. As someone who loves making games and implementing awesome software I was stoked! Sadly though, during his presentation of the project the teacher seemed to insinuate that our game wouldn’t be a fun one, but rather an academic exercise to integrate the knowledge we’ve gained since the start of our Bachelor’s degree and to learn important project management skills. Challenge Accepted! I set out to complete all the requirements of the project, on time (this was a 3 month project), but with the awesomeness cranked to 11.
Now this project, for which I was the engines tech lead, was to be done in teams of 6, but sadly two of our members didn’t think working was part of the coursework, which meant the rest of us had to tighten our belts accordingly.

The following articles will discuss in greater detail some of the extras I decided to add; a particle engine, an OpenGL rendering engine I built from scratch with Pixel Perfect Lighting, the integration of a 3D physics engine, very accurate and fast friction data for the wheels. Also as a small Easter egg, in the last week of the project I added animated billboard fans that you could squash in a gruesome way (with blood splashing) as you were barreling down the track. I don’t think the teacher approved haha.
I really enjoyed this project as it let me design and implement a complex game architecture. I really love software design, and to have the opportunity to design a game engine from the ground up was quite fun!