Games and graphics

I am very interested in computer games, computer graphics and the like, especially the programming side of things. This page shows some of the work I have done related to graphics and games.

Teapot

My first encounter with computer graphics was in the course Introduction to computergraphics. Together with Olav Madsen and Jakob Rohde I did a project on Visualization of parametric surfaces. Obviously we chose the classic Utah tea pot as the object to be rendered. NB! Everything is done in software - no hardware or graphics API used. Things such as line drawing algorithm, polygon renderer, Phong and Gouraud shading, perspective projection was done from scratch.

Program and source code available here.

Teapot

Raytracer

Everybody who is interested in computer graphics has to do a recursive raytracer... ;o) Again with Olav Madsen I did this simple raytracer.

The source code has unfortunately been lost

RayTracer

Radiosity

Again with Olav I did a radiosity engine showing the Cornell room. Different parameters can be changed by modifying the resource.xml file.

Program and source code available here.

Radiosity

Tank War

In The course AI in computer games I did (again with Olav) T.A.N.K War, a game where up to four teams consisting of a number of robots attempt to destroy each other.

The game has many advanced features:

3D Engine: The game uses a 3D engine (done using OpenGL) to show the world (a randomly generated landscape), the contestants (tanks) and objects in the world (bases, grenades, lasers, radio signals etc.). The camera can be moved around in the world in two different modes. Most of the objects in the world have can be shown with different levels of detail.

An example of level of detail:

Low Medium High
Level of detail Level of detail Level of detail

Game Engine: The game engine is a state machine keeping track of the different states of the game, eg. showing a menu, playing demo, playing a game, showing high scores etc.

AI Scripting language: The tanks are controlled by AI programs written in a procedural programming language called ROBOlang. The AI programs are compiled to byte code called roboASM using a compiler written in Haskell. The byte code programs are read by an interpreter in the game, that executes an instruction per tank each frame. An example of a program (a recursive factorial function) can be seen here:

proc fac(int n; int r)
int t;
{
  if n<=1 then r:=1; else {
    fac(n-1; t)
    r:=n*t;
  }
}
proc main(;)
             int n r;
             {
               n:=1;
               while n<10 do {
                 out(1,n)
                 fac(n; r)
                 out(1,r)
                 out(0,10) 
                 n:=n+1;
               }
             }

It's obviously not very clever for a robot to spend its time calculating factorials, but this demonstrates the scope and flexibility of the language and interpreter. The Robots are of course supposed to be programmed to exterminate their enemies by using weapons (laser and mortars) and communication by radio and avoid being wasted themselves.

The game can use a configuration file given as a command line option. Try executing radartest.bat where two defenseless teams (red and grey) are wiped out by two aggressive teams (blue and green) who have been instructed to just fire at the nearest enemy.

Program and source code available here.

Tank War

Tank War Improved

I was somewhat unsatisfied with the quality of parts of the code in T.A.N.K War, so I recently started a major refactoring of the code (I tend to be a bit of a perfectionist from time to time, especially when it comes to code). Have not come that far yet: The game so far only has to states: The Menu and visualization of the world, but the code has been enormously improved. Try comparing the procedure GenerateWorld() in world.cpp before and after...

Besides the game has been improved by not being frame rate dependant (the previous version behaved very differently on different machines).

Program and source code available here.

Tank War Improved

Stencil Shadows

An implementation of stencil shadows, inspired by the algorithm given in Mathematics for 3D Game Programming & Computer Graphics by Eric Lengyel. The program is able to draw shadows from any object (not just boxes ;-), as long as the object consists of a closed triangle mesh with consistent winding. I am looking for more interesting models at the moment, as well as making the program interactive...

Program available here. Source code is on the way...

Stencil Shadows

Comments?

Please write me with any comments or questions!

E-mail: fenne <at> itu <dot> dk

Back to my homepage