Created
September 16, 2011 08:23
-
-
Save nikolaykasyanov/1221540 to your computer and use it in GitHub Desktop.
current VHGT parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
esm.getHNExact(&rawHeights, sizeof(VHGT), "VHGT"); | |
float base = rawHeights.heightOffset; | |
int currentHeightIndex = 0; | |
for (int y = 0; y < LAND_SIZE; y++) | |
{ | |
uint8_t delta = rawHeights.heightData[currentHeightIndex]; | |
currentHeightIndex++; | |
base += delta; | |
landData->heights[y * LAND_SIZE] = base * HEIGHT_SCALE; | |
float scratch = base; | |
for (int x = 1; x < LAND_SIZE; x++) | |
{ | |
uint8_t delta = rawHeights.heightData[currentHeightIndex]; | |
currentHeightIndex++; | |
scratch += delta; | |
landData->heights[x + y * LAND_SIZE] = scratch | |
* HEIGHT_SCALE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI, search for "VHGT" in https://github.com/athile/lxengine/blob/master/lx0/dev/samples/games/lxmorrowind/tes3loader/imp.cpp to see the code I used to load the heights.
Also, there's no "HEIGHT_SCALE" in my code. As far as I could tell, the heights are already in Morrowind units. (The horizontal and vertical has a fixed scale though, as the landscape represents a 8192x8192 rectangular area with 65x65 height samples, each 128 Morrowind units apart.)