Terrain Overlay

STK Engine supports terrain in the PDTT file format. This format is optimized for rendering performance.

Terrain is added to the central body using the Add method as shown in the Overlay Management help topic. The following example shows how to display the rectangular extent of an overlay without adding it to the central body.

[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsTerrainOverlay terrainOverlay = manager.Initializers.AGIProcessedTerrainOverlay.InitializeWithString(terrainOverlayPath);
Array overlayExtent = ((IAgStkGraphicsGlobeOverlay)terrainOverlay).Extent;

IAgStkGraphicsSurfaceTriangulatorResult triangles = manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth", ref overlayExtent);

IAgStkGraphicsTriangleMeshPrimitive mesh = manager.Initializers.TriangleMeshPrimitive.Initialize();


An overlay is created and initialized but not added to the central body so it is not rendered. Instead, the overlay's Extent property is used to create a triangle mesh primitive that shows the rectangular extent of the overlay. See the Triangle Mesh Primitive Overview for details on the primitive. At a later point, perhaps in response to the user picking the extent on the globe, the primitive can be removed and the overlay added.

[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;

This technique also applies to imagery overlays.

Altitude Scale and Offset

Terrain overlays support user-defined altitude scale and altitude offset. As shown in the table below, Altitude Scale is a visual aid used to exaggerate terrain and Altitude Offset is a visual aid used to uniformly raise the terrain off the globe.

No Altitude Scale or Offset

Altitude Scale: 2

Altitude Offset: 3,000

These properties are set using the TerrainOverlay interface as shown below.

[C#] Copy Code
terrainOverlay.AltitudeScale = 2;
terrainOverlay.AltitudeOffset = 3000;

Terrain Cache

Since terrain files can be extremely large, the entire file is not kept in memory. Instead, a small portion of the file is kept in a memory cache. As the camera moves around, parts of the file are paged from disk into the cache. By default, the cache is 32 megabytes, which is allocated up front. If you are using high resolution terrain or the terrain appears blurry, try increasing the cache to 64 or 128 megabytes as shown below.

[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
manager.GlobeOverlaySettings.TerrainCacheSize = 128;

Setting the cache above 128 megabytes is not recommended. Large cache sizes can slow down rendering since so much terrain will be rendered.

STK Engine for UNIX 11.2