www.sjwaller.com

Projects » Open GL

IslandApril 12th, 2006

current version 0.0.7
binary download (561kb)
sourcecode not available
start date April, 2006
platform Windows
language C++ (OpenGL)
description An OpenGL based application written in C++. An Ogre calculates a path to locate a target within randomly generated islands.

What is it?

This demo combines various techniques including: loading/animating a 3D model (MD2 mesh), A* pathfinding algorithm, finite state machine, dynamic landscape generation.

Overview:

A* PathFinding:

After a few weeks of head scratching, I finally managed to get my head around the A* PathFinding algorithm – now I can successfully get my game entities to calculate a path to a target and avoid any ‘unwalkable’ terrain/object.

I used the following tutorial to help understand this really helpful technique: A* Pathfinding for Beginners

MD2 model animation:

You may recognise the Ogre from that old chestnut that is Quake II. Well, you’re right – it is the same guy! Basically I’m not very good at modelling – or really I’m more interested in other aspects of game programming at the moment ;-) so I used this.

Also, the MD2 model format is really easy to deal with – and is covered extensively in the following book: OpenGL Game Programming

Finite State Machine (FSM):

For the first time I’ve implemented a finite state machine (FSM). This makes it much easier to manage the different actions my game entities can be doing. In this demo the Ogre can be either Searching, Travelling, Resting or Wandering.

For more information on state machines and other AI techniques, I highly recommend reading through this site: ai-junkie

Dynamic Landscape:

Finally, the dynamic landscape generation is based on a fractal generated heightmap feeding a triangle-strip mesh. This is textured with a simple bitmap filtered with different colours depending on height. The water is again a simple bitmap with a degree of transparency. The landscape isn’t really dynamic (although it is based on the destructabe landscape I used in my tank demo) – but it is randomly generated each time the map is reset. However, I am thinking of trying to get to grips with ‘Level of Detail’ techniques to speed up the landscape rendering.

Where can I get it?

Click the link next to ‘binary’ in the project information box. No sourcecode yet until it’s much tidier. You can however follow the links I mentioned earlier to find some great examples of the various techniques.

What do I do?

Just sit and watch the Ogre follow the path to the target … Joy! You can also interact to some extent:

What are the controls?

  • SPACEBAR – regenerate map
  • M – overhead map on/off
  • I – information box on/off
  • C – mini-cam on/off
  • T – landscape texture on/off
  • 1 – Search/Travel state
  • 2 – Work state
  • 3 – Wander state – use cursors to move

What next?

  • Find a better way to calculate the rotation toward the next waypoint!
  • Make the landscape render faster – implement LOD?
  • Create more actions depending on state. Want to get him doiong more interesting things than just finding a target.
  • Introduce more objects into the scene – trees, boulders etc. Use a secondary obstacle avoidance routine to work with the pathfinding to avoid these.
  • Get some sleep ..?

Leave a Reply