# FIFE's map geometry

## Contents

## Introduction

This article explains how the map geometry that was used in Fallout 1 and Fallout 2 worked for tiles and objects.

## Single tile

- Copyright: dude obj's Fallout mod guide

## Single hex

- Copyright: dude obj's Fallout mod guide

## Tile coordinate system

- 100 * 100 floor tiles for each elevation
- 100 * 100 roof tiles for each elevation
- 20.000 tiles total for each elevation
- 3 possible elevations
- Maximum of 60.000 tiles per .map file

The following picture illustrates tile id increment direction in Fallout

### FIFE's tile coordinate system

FIFE uses a different coordinate system than Fallout, the root is not the north pole of the map, but the west pole. This image shows how the coordinates are mapped in FIFE's internal coordinate system:

## Object / hex coordinate system

- 40.000 hex / object coordinates on each floor elevation
- Four hex /object coordinates on one floor tile coordinate
- No hex coordinates on roof elevations
- 3 possible elevations
- Maximum of 120.000 hex / object coordinates per .map file

## Hexagonal Implementation Details

Geometries are defined by an interface in engine/map/geometry.h. The two current implementations of this interface are gridgeometry.h and hexgeometry.h. Coordinates are converted between map coordinates and screen coordinates by the functions toScreen and fromScreen. The issue of converting a mouse screen coordinate to a hexagon selection is presented below.

Three properties specific to a particular hex definition are used:

- m_offset - offset of origin; this is just a constant added to all values
- m_basesize - the height and width of a single hexagon
- m_transform - roughly, the x and y distance each tile occupies

On a square grid, m_transform would have the same value as m_basesize. To see why this is not the case for hexagons, consider this image:

The total height of these tiles is 4 + 8 + 4 = 16, and their width is 32. However, when put together, tile 2 overlaps half of tile 1, so in a sense, each tile only occupies m_basesize/2 width. The same phenomena occurs with height, where we observe a 4 pixel overlap.

With these properties defined, we can compute tile coordinates. First, observe a hexagonal grid:

Notice that FIFE coordinates are stored in vector form, unlike the original Fallout data. Also, note the grid's axes are skewed, and that the positive x-axis runs opposite to normal conventions. To compute a tile coordinate from a mouse position p, consider this overlay:

The rectangular grid can be obtained (roughly--see hexgeometry.cpp) by dividing the screen coordinates by m_transform. A simple transformation (see source) can then map these rectangles to hexes.