Basic Concepts

Terrain vs. Scenario

Some games – most notably the early Ace Combat series – have different terrain for each and every mission. You see the terrain once and move on. Others – e.g. Total Air War – play out all missions in the same environment.

UAW separates terrain from scenarios. Think of terrain as the stage for a play, and of scenarios as the actual play.

RationaleWith this approach, both is possible – you can use a terrain in just one scenario or in many.

This chapter is about adding terrain to UAW.

Coordinate Space

North, East, Down (NED)

Terrain and Scenarios use the North, East, Down (NED) coordinate convention. I.e. in 3D coordinates, the numbers represent meters towards North, meters towards East, and meters towards the ground.

RationaleNo deep reason: NED happens to be the coordinate space of both Ace Combat 3 and Total Air War, and it happens to be used widely. It is right-handed, too.

This implies that all points above sea level have a negative down coordinate. Terrain may, however, also extend below sea level (to positive down coordinates).

RationaleThere are actual places on Earth way below sea level. Arcade-ish games like Ace Combat sometimes have underground levels.

There is a coordinate cutoff one kilometer below sea level (+1000 down). Nothing is allowed below this point.

RationaleObjects may at times fall through the ground – game physics are not perfect, and neither is terrain. A lower bound on altitude helps cleaning up abandoned/buggy objects that would otherwise keep falling forever.

Coordinate Origin

Terrain has its coordinate origin at the geographic position specified in the terrain enumeration. All content must be North and East of this point.

RationaleTile indices are computed relative to this point, and negative indices must be avoided for integer math complexity problems. Specifically, languages disagree over rounding in negative integer division, making negative coordinates prone to errors.

Even though Earth is flat in UAW, geographic coordinates of the terrain are used to compute the position of Sun, Moon, and stars based on the scenario’s time.

Tiles

UAW expects any terrain be subdivided into rectangular tiles.

RationaleTiled terrains are the most common approach to managing terrain.
RationaleWith tiles, it is easy to implement common operations like: culling of terrain beyond visual range; level of detail; collision detection.

All tiles have the same sidelength. The sidelength is arbitrary, but it must be picked when the terrain is enumerated and cannot change after that.

RationaleDifferent terrain implementations desire different tile sidelengths (e.g. 2496.922 m in TAW vs. 512 m in Ace Combat 3).
RationaleSidelength must be known before loading terrain because the GUI may need to know the terrain size upfront, e.g. for displaying it on a globe.
RationaleChanging the sidelength later on is very complicated, as many coordinates are expressed in terms of tile indices (see below).

Tiles are addressed by two numbers called tile indices. Tile indices start at zero and increment towards North and East.

RationaleIt would be possible to address tiles in a single number, but the additional complexity is not worth it.

Tile indices (and therefore the maximal terrain size) are limited to [0, 32767] range.

RationaleEven at a relatively small sidelength of 2 km, this would allow for the entire globe being mapped.
RationaleFitting into 15 bits is nice for internal bookkeeping while avoiding the pitfalls of signed integers.
3,0 3,1 3,2 3,3 2,0 2,1 2,2 2,3 1,0 1,1 1,2 1,3 0,0 0,1 0,2 0,3 East North Geographic origin

Flat Earth

UAW does not (yet) use spherical coordinate system like WGS84.

RationaleExtremely high complexity.
RationaleFlat terrain is good enough for many combat flight simulations.

This API, however, is designed to make a possible future transition as smooth as possible. For example, global coordinates are used as sparingly as possible and vehicles receive all coordinates as relative to their own position.

Terrain Views

Terrain rendering is not stateless: Data like level of detail must be stored across frames.

Imagine, for example, a split screen game. (Split-screen games might be far-fetched, but they are in essence identical to infrared displays, on-board weapon cameras, satellite views, etc.) The left player is close to terrain tile X, but the right player is not. The game must render the tile in high detail for the left player, but in low detail for the right player. A naïve implementation would swap the levels of detail once per frame, putting extreme load on scene management.

UAW, on the other hand, creates a view for every observer of the terrain. Terrain views store all information that is specific to an observer.

Extensions are not forced to provide terrain views, but UAW will offer them the opportunity.