When working with 3D programming, it is often challenging to keep track of the numerous coordinate systems and frames of reference involved. In a geospatial system like the VTP software, it is yet more complicated because of the presence of traditional cartographic coordinate systems in addition to those of the 3D graphics system.
Although there is no well-established naming system or standards, these are the names that vtlib uses:
- Earth coordinates. These are the original coordinates as would appear in a GIS system - degrees, feet, meters etc. in the coordinate system (projection) of the original data.
- World coordinates / terrain coordinates. Each terrain has a origin at sea level at its lower-left corner. These coordinates are suitable for passing directly to vtlib/OpenGL, and are as close to 1 unit = 1 meter as feasible. The axes are also the same as the most common OpenGL convention (X right, Z forward, Y up).
- Local coordinates. For any specific features within the terrain, e.g. a building, which has its own origin.
At runtime, a simple transformation is created (
vtLocalConversion) to convert from (1) to (2). Each structure with its own reference frame, e.g.
vtBuilding, has a means of converting from (2) to (3).
Everything that the scene graph classes do -
vtMeshetc. - goes straight to the graphics pipeline, so they are in OpenGL coordinates, usefully the same as (2).
Suppose you have a terrain in UTM coordinates:
These are projected to world (terrain) coordinates: