Online games based
on small geographical zones can use position coordinates local to
zones, with low range needs. However, a large seamless environment
theoretically deals with wide-range coordinates. On the server side,
we have 32-bit integer positions with millimetre precision. An
approach would be to alternate absolute positions and “smaller”
positions relative to the latest absolute positions. However, this
technique has strong sequentially constraints, which cannot be easily
adapted to our best-effort (non-reliable) lightweight network
protocol.
A more suited
approach was based on the assumption that a client will only display
the entities in the neighbourhood, within the square kilometer
surrounding the viewer (Figure 6). Then, a virtual local basis can be
used. Instead of translating positions from absolute basis to a basis
relative to the viewer, a more CPU-effective method consists in using
the “truncated absolute coordinate” algorithm.
The server
transmits short entity coordinates, and, to save more bandwidth, also
lowers the precision to 16-millimeter in a 1024 m window by dividing
the coordinate by 16 (i.e. shifting down by 4 bits). No reference to
the viewer’s position is needed:
uint16 ec_short =
(uint16)(ec_full >> 4);
To reconstruct the
full position of an entity, the client needs the following inputs:
The client
calculates the short viewer coordinates, and the short entity delta
coordinates from the transmitted values, to finally deduce the full
entity coordinates from the full delta (obtained by sign extension)
and the damped viewer coordinates (to avoid entity flickering when
the viewer moves):
Full X Coordinates:
Viewer:
0x2C0000
Entity A: 0x2E0000
Entity B: 0x260000
Entity C:
0x320000
Short Coordinates:
Viewer: 0xC000
Entity A: 0xE000
Entity B: 0x6000
Entity C: 0x2000
Short Delta:
Entity A: 0x2000
Entity B: 0xA000
Entity C: 0x6000
Full Delta:
Entity A:
0x00020000
Entity B:
0xFFFA0000
Entity C: 0x00060000
Figure 6: Local Position Window Example
If dealing with
ground entities, the z-value (altitude) may be even more compressed,
by referring to a layer index, provided the client software can
access efficiently the 3D topography structure corresponding to a 2D
value.
1
Basic types shown are from the NeL library: uint32
is 32-bit unsigned int, sint16 is 16-bit signed int, etc.