I'm starting work on a flight simulator, and I've got a bit of a hangup in getting my terrain to match the scale and values of the real life equivalents. I generated a heightmap (http://db.tt/TQcs1CmP for the map itself) from the National Elevation Dataset, and would like to use it to generate the terrain for the part of the earth I'm currently flying over. When I get close to the end of a given map, I was simply going to load the next one and position it along the edge..
Will this work? Can I just load heightmaps as I go and make it seamless to the user? Is there a better way to do this?
Also, if this will work, I can't seem to get the scales correct. For example, I know that the tallest mountain around is 11,000 feet or so.. but I get 14,000 and some change in my render. I was setting the scales using 1 px = 98 feet or so (30 meters from the raw data documentation), and then multiplying that since I reduced the raw heightmap by a factor of 2 in the X and Y dimensions.
Additionally, I get the 14,000' mountain if I use 98 as a scale. If I use 197 (as below) I seem to only get a flat mesh with no mountains.
The code is almost exactly the Terrain example at this point, since I wanted to prove this would work before going on a big custom program.
I tried searching for "real life terrain" and "terrain scale" etc.. but nothing particularly useful came up
This is how I'm creating my TerrainSceneNode.
Code: Select all
// add terrain scene node
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"/Users/mruno/Desktop/N37W116.bmp",
0, // parent node
-1, // node id
core::vector3df(0.f, 0.f, 0.f), // position
core::vector3df(0.f, 0.f, 0.f), // rotation
core::vector3df(197.f, 197.f, 197.f), // scale
video::SColor ( 255, 255, 255, 255 ), // vertexColor
5, // maxLOD
scene::ETPS_17, // patchSize
10 // smoothFactor
);
Code: Select all
int height = terrain->getHeight(camera->getAbsolutePosition().X,
camera->getAbsolutePosition().Z);
int cameraHeight = camera->getAbsolutePosition().Y;
int altitudeAGL = cameraHeight - height