-
Notifications
You must be signed in to change notification settings - Fork 2
sec
aspadm edited this page Aug 12, 2018
·
6 revisions
Map chunk (section)
File contain one header:
struct header
{
uint magic; // 74 F7 4B CF
byte water;
};
After header lay data arrays:
struct vertex
{
byte x_offset;
byte y_offset;
ushort altitude; // z coord
uint packed_normal;
};
struct vertex land_vertex_array[33][33];
If water != 0
there are additional vertex table:
struct vertex water_vertex_array[33][33];
After that lay texture information:
ushort land_textures[16][16];
If water != 0
there are additional textures table:
ushort water_textures[16][16];
After that if water != 0
:
uint water_visible[16][16]; // 1 if visible
Normal unpacking (10 bits for z, 11 for x and y):
uint packed_normal;
float x = ((float)((packed_normal >> 11) & 0x7FF) - 1000.0f) / 1000.0f;
float y = ((float)(packed_normal & 0x7FF) - 1000.0f) / 1000.0f;
float z = (float)(packed_normal >> 22) / 1000.0f;