Here is a high-level introduction to using vtlib to render your terrain data.
- Prepare your data.
You should have, at the minimum, elevation data.
- Put the data in the correct location.
BT, ITF, and Tileset .ini files should be put in a folder called "Elevation" under your data directory.
Imagery should be in a folder "GeoSpecific" under your data directory.- Create a set of parameters describing your terrain.
An easy way is to copy one of the sample files, found in <datapath>/Terrains
These are plain text files which are easy to edit.
E.g. call yours "MyTerrain.xml". Edit it to contain the filenames of your own data.
- Make sure the necessary directories on are your include path. If you compiled vtlib, then you already have everything set up to compile applications on top of it.
Your application will create the OpenGL context. vtlib will simply draw into the current context each frame.
vtScene *pScene = vtGetScene();
pScene->Init();
pScene->SetDataPath("Data/");
vtTerrainScene *ts = new vtTerrainScene;
vtGroup *top = ts->BeginTerrainScene();
pScene->SetRoot(top);
vtTerrain *pTerr = new vtTerrain;
pTerr->SetParamFile("MyTerrain.xml");
ts->AppendTerrain(pTerr);
if (!ts->BuildTerrain(pTerr))
return;
ts->SetCurrentTerrain(pTerr);
vtTerrainFlyer *pFlyer = new vtTerrainFlyer(1.0f);
pFlyer->SetTarget(
pScene->GetCamera());
pFlyer->SetHeightField(pTerr->GetHeightField());
pScene
->AddEngine(pFlyer);
vtGetScene()->DoUpdate();