WWIIOL - Range-Finder

I've been playing around with jME (http://jmonkeyengine.com/) as an engine for a game, and after reading a post on the WWIIOL forums about how it would be nice if there was an alternative to the 'laser rangefinder' currently ingame. I decided to whip up a prototype to get myself a little more familiar with the jME framework.

How does it work

Basically, the idea is to have the player responsible for setting an accurate range using the rangefinder, rather than having the computer calculate it automatically. This has the advantage of making the rangefinders a little more fun (IMHO) and more challenging to use, as well as eliminating the ability to hit 'R' ingame to range a target, and switch to the gunner/driver/etc. while the range is being calculated.

I originally wanted to have something that was similar to the method used in real life by tank-operators using a steroscopic rangefinder. As far as I can tell (from a bunch of googling) the rangefinders worked by either overlaying two images on top of one another in order to get the range, or by aligning two peices of a split image.

However, the problem with going with either of these routes is:

  1. In order to overlay two portions of a steroscopic image, each image must be rendered seperatley (ie. through each of the lenses of the rangefinder) and then overlayed (by the user). This means it would essentially cut the framerate in half, as the scene would need to be drawn twice. This is probably unacceptable.
  2. In order to do the second kind of rangefinder (lining up the single split-image) distance information on all objects along the axis of split (ie, near the edge of the picture, that will be lined up) must be calculated. This is because, if there are objects in the foreground (eg. a bush 10m away, and a tree 200m away) they should ONLY line up at their correct ranges (eg. the bush will line up when the rangefinder is set to 10, but not the tree, or any other objects at different distances). In order to have this happen, one of the images (left or right) would have to be stretched the correct amount, which is difficult to calculate (and I didn't really feel like getting into it ATM, maybe sometime in the future...)

So, the method I implemented is as follows:

  1. The user aims the reticle (as currently implemented)
  2. The user presses the 'range' key (as currently implemented) in order to indicate that THIS is the object for which the range is to be set
  3. Once the key is pressed, a set of 'ranging bars' appear (or are reset) on the screen
  4. The user uses the 'increase range' and 'decrease range' keys to manouver these bars until they are overlapping and centred on the screen. When this is acheived, the correct range is set.
  5. The user then reads the correct range from the instrument (probably presented on screen as a number, dial, or similar) and can fire.

Here is a screenshot of how it looks (the range is not set correclty in this picture BTW :) ):

A screenshot showing the ranging bars

 

In order to demonstrate how quick and easy this is to implement, and how it would look and feel to the user, I implemented it in under a day (most of it was learning the jME API, the actual algorithm for moving the bars took under 1 hour to devise / implement).

The program

A .zip file is available HERE of the program. It requires Java 1.4 or greater to run. A .bat file (run.bat) is provided to make running the program easier (you don't have to mess with stupid Java classpaths and whatnot). The jME and lwjgl .jar files and native libraries for windows are included in the ./lib directory in the .zip file.

Note: In the demo, the true range is automatically calculated every frame, rather than requiring the 'range' key be pressed.