Shoot'n Shoot'n


My friend Steven de Rooij came up with an algorithm to generate random mountain-like landscapes. Together we implemented the first version of a visualisation program for it. It could render a grid of size 7 (128x128 points, which means 32768 triangles) at 60 FPS, using a modest window size. This was accomplished by brute-forcefully sending all triangles to the OpenGL renderer, in 128 polygon strips. This method does not scale. And it does not involve violence.


I 'attacked' the second problem by adding tanks, bullets and explosions. I used OpenGL lighting to create realistic flashes on bullet firing and impact explosions. My current plan is to integrate the threading and network library I created for the combined C++/Reseaux project. The final program will be a Client-Server Multi-Player Real-Time Tank-Battle Simulator, or CS MP RT TB S (say it out loud).


I solved the first problem (in-scalability) by using an hierarchical decomposition of the grid. This allows me to efficiently determine which pieces of the world are visible to the tank and which are not. At first I used a bounding-box approach as shown in the following picture:

Hierarchical decomposition using bounding boxes

The visible region of the world (usually called frustum) is defined by six plane equations. Testing whether a box intersects with the frustum can require up to 6x8=48 in-product calculations. Intersection with a sphere is much simpler, it requires only 6 in-product calculations. The problem with spheres is that they are usually much too large. Therefore I currently use a hybrid approach as shown in the picture below:

Hybrid bounding box and sphere approach

This combination of techniques allows me to render worlds of size grid size 10 (1024x1024 points, 2 million triangles) on a window of size 1600x1200 at 60 FPS!

Smooth shading, eh!


You can download a pre-compiled executable for GNU/Linux x86 here: gzipped tar (146 KB), or get the full source here: gzipped tar (36 KB).


F1 - F5 change view
Enter toggle fire
Arrows drive/steer
w,a,s,d rotate turret and cannon
Esc quit