Here is a high-level introduction to using vtlib to render your terrain data.
- Prepare your data.
You should have, at the minimum, at BT file for elevation.
For the CLOD algorithms, the dimensions of the BT should be a power-of-2-plus-1, e.g. 1025*1025.- Put the data in the correct location.
BT files should be put in a folder called "Elevation" under your data directory.
Geospecific textures 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.
- Set the processor definition to indicate which flavor of vtlib you are using:
VTLIB_OSG=1Your 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;
vtRoot *pTopGroup = ts->BeginTerrainScene();pScene->SetRoot(pTopGroup);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();
this would occur, for example, after your call to glClear()
and before calling SwapBuffers()