122 lines
3.5 KiB
C
122 lines
3.5 KiB
C
/**
|
|
* @file hmp_struct.h
|
|
* @date 05/02/2023
|
|
* @author JackCarterSmith
|
|
* @copyright GPL-v3.0
|
|
* @brief HMP file mapping definition.
|
|
*
|
|
*/
|
|
|
|
#ifndef RSPTERRAINLIB_HMP_STRUCT_H_
|
|
#define RSPTERRAINLIB_HMP_STRUCT_H_
|
|
|
|
|
|
/*
|
|
* long = 64bits??? (8 Bytes)
|
|
* int = 32bits (4 Bytes)
|
|
* short = 16bits (2 Bytes)
|
|
* char = 8bits (1 Bytes)
|
|
*/
|
|
|
|
#if defined(_MSC_VER)
|
|
#define PACK
|
|
#elif defined(__GNUC__)
|
|
#define PACK __attribute__((packed))
|
|
#endif
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// Declaration of Memory Mapped Structure
|
|
// Caution: the place of variable is important for correct mapping!
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma pack(push, 1)
|
|
#endif
|
|
|
|
/*
|
|
* - Global HMP file structure-
|
|
* +------------------+-----------------------------------------+----------------------+----------------------------+
|
|
* | T_HMPFILE_HEADER | (width_BLK*height_BLK) * T_TILE_INDICES | T_HMPFILE_LIGHTDATAS | obj_count * T_HMPFILE_TILE |
|
|
* +------------------+-----------------------------------------+----------------------+----------------------------+
|
|
*
|
|
*/
|
|
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 textures_count;
|
|
/*
|
|
* #Thanaclara
|
|
* *textures_count* note - Some levels contain tiles with an animation for a texture.
|
|
* This animation consists of multiple textures, or "frames" for the animation.
|
|
* However each animation counts only as 1 towards the terrain texture count.
|
|
* An example of an animated terrain texture is a tile that is textured to look like water.
|
|
*/
|
|
|
|
unsigned int tiles_start_offset;
|
|
unsigned int lighting_datas_offset;
|
|
|
|
unsigned short width_BLK;
|
|
unsigned short height_BLK;
|
|
} T_HMPFILE_HEADER;
|
|
|
|
typedef struct PACK global_light_obj {
|
|
T_R8G8B8A8 shadow_color;
|
|
T_R8G8B8A8 world_light_color;
|
|
T_R8G8B8_F terrain_light_color;
|
|
unsigned int reserved0; // 4B of zeros
|
|
T_RSPTERRAIN_VECTOR3 terrain_light_normal;
|
|
unsigned int reserved1; // 4B of zeros
|
|
} T_HMPFILE_GLOBALLIGHT;
|
|
|
|
typedef struct PACK light_shadow_obj {
|
|
/*
|
|
* In light mode higher values = brighter light
|
|
* Shadow mode is inverted, higher values = darker shadows
|
|
* but the inversion also extends to the shadow color (i.e if you
|
|
* want to make a blue shadow you would need to set the blue
|
|
* channel to 0.0f and the red and green channel to 255.0f
|
|
*/
|
|
T_R8G8B8_F light_color;
|
|
|
|
unsigned char activated;
|
|
unsigned char shadow_mode;
|
|
unsigned char intensity_boost;
|
|
unsigned char unknown0;
|
|
|
|
T_RSPTERRAIN_VECTOR3 light_position;
|
|
float light_scale;
|
|
} T_HMPFILE_LSO;
|
|
|
|
typedef struct PACK lighting_datas {
|
|
// Lights and shadows object count
|
|
unsigned int ls_obj_count;
|
|
|
|
T_HMPFILE_GLOBALLIGHT global_light;
|
|
T_HMPFILE_LSO* pLSO; // array size = (ls_obj_count - 1) because global_light count as a light element
|
|
} T_HMPFILE_LIGHTDATAS;
|
|
|
|
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 /* RSPTERRAINLIB_HMP_STRUCT_H_ */
|