/* * hmp_struct.h * * Created on: 31 juil. 2022 * Author: JackCarterSmith */ #ifndef SRC_HMP_STRUCT_H_ #define SRC_HMP_STRUCT_H_ /* * long = 64bits??? (8 Bytes) * int = 32bits (4 Bytes) * short = 16bits (2 Bytes) * car = 8bits (1 Bytes) */ #if defined(_MSC_VER) #define PACK #elif defined(__GNUC__) #define PACK __attribute__((packed)) #endif /////////////////////////////////////////////////////////////////////////////// // HMP file structure /////////////////////////////////////////////////////////////////////////////// typedef struct vector3 { float x,y,z; } T_VECTOR3; typedef T_VECTOR3 T_VERTEX; typedef struct terrain { unsigned short width; // Dimension of the height/vertices map unsigned short height; unsigned char** heightmap; unsigned int verticesmap_size; T_VERTEX* verticesmap; } T_TERRAIN ; /////////////////////////////////////////////////////////////////////////////// // Declaration of Memory Mapped Structure // Caution: the place of variable is important for correct mapping! /////////////////////////////////////////////////////////////////////////////// #if defined(_MSC_VER) #pragma pack(push, 1) #endif typedef struct PACK hmpfile_header { unsigned int reserved0; //12B of zeros unsigned int reserved1; unsigned int reserved2; float reserved3; // Always 0x3F000000 float height_scale; float reserved4; // Always 0x3F000000 unsigned short tiles_count; unsigned short unknown0; unsigned int tiles_start_offset; unsigned int unknown1; // Offset to some datas? unsigned short width_BLK; unsigned short height_BLK; } T_HMPFILE_HEADER; typedef unsigned short T_TILE_INDICES; typedef struct PACK hmpfile_tile { unsigned short texmap_id; unsigned char unknown0; unsigned char low_height; // LOD application? Clipping? Terrain render quadrants? unsigned char high_height; unsigned char height_values[5][5]; // first and last row/column overlap with a neighboring tile, "glue" for tiles, need to be identical to avoid "hill" effect } T_HMPFILE_TILE; #if defined(_MSC_VER) #pragma pack(pop) #endif #endif /* SRC_HMP_STRUCT_H_ */