Insert material processing in workflow Tests and experiments with unknown values Reviewed material resolution The first approach of model constructor optimize vertices/indices numbers but doesn't support correctly texture coordinates. Raw approach output good result but need advanced functions in obj lib to efficiently store vertices, textures coord and indices together.
222 lines
5.5 KiB
C
222 lines
5.5 KiB
C
/**
|
|
* @file hob_struct.h
|
|
* @date 26/07/2022
|
|
* @author JackCarterSmith
|
|
* @copyright GPL-v3.0
|
|
* @brief HOB file mapping definition.
|
|
*
|
|
*/
|
|
|
|
#ifndef RSPMODELLIB_HOB_STRUCT_H_
|
|
#define RSPMODELLIB_HOB_STRUCT_H_
|
|
|
|
|
|
/*
|
|
* long = 64bits???
|
|
* int = 32bits
|
|
* short = 16bits
|
|
* car = 8bits
|
|
*/
|
|
|
|
#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 HOB file structure-
|
|
* +------------------+--------------------------------------+----------------------------------------+
|
|
* | T_HOBFILE_HEADER | obj_count * T_HOBFILE_OBJ_DESCRIPTOR | obj_count * T_HOBFILE_FACEGROUP_HEADER |
|
|
* +------------------+--------------------------------------+----------------------------------------+
|
|
*
|
|
* - Facegroup sub-structure -
|
|
* +----------------------------+------------------------------------------------+
|
|
* | T_HOBFILE_FACEGROUP_HEADER | object_part_count * T_HOBFILE_FACEGROUP_OFFSET |
|
|
* +----------------------------+------------------------------------------------+
|
|
*/
|
|
typedef struct PACK hobfile_header {
|
|
unsigned int obj_count;
|
|
unsigned int vertices_offset;
|
|
} T_HOBFILE_HEADER;
|
|
|
|
typedef struct PACK hobfile_obj_descriptor {
|
|
unsigned char object_name[16];
|
|
unsigned int facegroup_offset;
|
|
unsigned int object_parts_offset;
|
|
unsigned int facegroup_header_2_offset;
|
|
|
|
unsigned int reserved1; // 12B of zeros
|
|
unsigned int reserved2;
|
|
unsigned int reserved3;
|
|
|
|
unsigned int unknownOffset1;
|
|
unsigned int unknownOffset2;
|
|
unsigned int unknownOffset3;
|
|
float unknown4;
|
|
|
|
unsigned int reserved4; // 12B of zeros
|
|
unsigned int reserved5;
|
|
unsigned int reserved6;
|
|
|
|
float reserved7;
|
|
float reserved8;
|
|
float reserved9;
|
|
float reserved10;
|
|
float reserved11;
|
|
unsigned int end_mask; // Always equal to 0xFFFFFFFF
|
|
float reserved12;
|
|
float reserved13;
|
|
float reserved14;
|
|
float reserved15;
|
|
float reserved16;
|
|
float reserved17;
|
|
} T_HOBFILE_OBJ_DESCRIPTOR;
|
|
|
|
typedef struct PACK hobfile_facegroup_header {
|
|
unsigned short object_part_count;
|
|
unsigned short facegroup_count;
|
|
} T_HOBFILE_FACEGROUP_HEADER;
|
|
|
|
typedef struct PACK hobfile_facegroup_offset {
|
|
unsigned int unknown1;
|
|
unsigned int facegroup_offset;
|
|
} T_HOBFILE_FACEGROUP_OFFSET;
|
|
|
|
typedef struct PACK hobfile_meshdef0 {
|
|
unsigned int offset1;
|
|
unsigned int offset2;
|
|
unsigned int prev_meshdef0_offset;
|
|
unsigned int next_meshdef0_offset;
|
|
unsigned int meshdef1_offset_plus_4;
|
|
|
|
unsigned int reserved1; // 8B of zeros
|
|
unsigned int reserved2;
|
|
|
|
float unknown3;
|
|
|
|
unsigned int reserved3; // 12B of zeros
|
|
unsigned int reserved4;
|
|
unsigned int reserved5;
|
|
|
|
float unknown4;
|
|
|
|
unsigned int reserved6; // 12B of zeros
|
|
unsigned int reserved7;
|
|
unsigned int reserved8;
|
|
|
|
float unknown5;
|
|
|
|
unsigned int reserved9; // 12B of zeros
|
|
unsigned int reserved10;
|
|
unsigned int reserved11;
|
|
|
|
unsigned int object_id;
|
|
|
|
float unknown12; // Can be a vector???
|
|
float unknown13;
|
|
float unknown14;
|
|
|
|
float unknown15; // Can be a vector???
|
|
float unknown16;
|
|
float unknown17;
|
|
|
|
float unknown18; // Can be a matrix???
|
|
float unknown19;
|
|
float unknown20;
|
|
float unknown21;
|
|
|
|
float transform_x;
|
|
float transform_y;
|
|
float transform_z;
|
|
} T_HOBFILE_MESHDEF0;
|
|
|
|
typedef struct PACK hobfile_meshdef1 {
|
|
unsigned int facedef_end_offset;
|
|
|
|
unsigned int reserved1; // 20B of zeros
|
|
unsigned int reserved2;
|
|
unsigned int reserved3;
|
|
unsigned int reserved4;
|
|
unsigned int reserved5;
|
|
|
|
unsigned int vertex_count;
|
|
unsigned int unknown1;
|
|
unsigned int reserved6;
|
|
unsigned int faceblock_offset;
|
|
unsigned int vertexblocks_offset;
|
|
|
|
unsigned int reserved7; // 52B of zeros
|
|
unsigned int reserved8;
|
|
unsigned int reserved9;
|
|
unsigned int reserved10;
|
|
unsigned int reserved11;
|
|
unsigned int reserved12;
|
|
unsigned int reserved13;
|
|
unsigned int reserved14;
|
|
unsigned int reserved15;
|
|
unsigned int reserved16;
|
|
unsigned int reserved17;
|
|
unsigned int reserved18;
|
|
unsigned int reserved19;
|
|
} T_HOBFILE_MESHDEF1;
|
|
|
|
typedef struct PACK hobfile_faceblock {
|
|
unsigned int reserved1; // 8B of zeros
|
|
unsigned int reserved2;
|
|
|
|
unsigned int facesOffset;
|
|
unsigned int faceCounts;
|
|
} T_HOBFILE_FACEBLOCK;
|
|
|
|
typedef struct PACK hobfile_faces_header {
|
|
unsigned int flags;
|
|
unsigned char b1; // 74 = transparent / 75 = opaque
|
|
unsigned char b2;
|
|
unsigned char b3;
|
|
unsigned char faceBlockIntSize; // Bytes size divided by 4, count as number of UInt32 type.
|
|
unsigned short headerSeparator;
|
|
unsigned short materialIndex;
|
|
unsigned short vertexIndices[4]; // Relative to facegroup, the last value is equal to 0 when it's triangle shape.
|
|
} T_HOBFILE_FACES_HEADER;
|
|
|
|
typedef struct PACK hobfile_faces_extra_vertex_color {
|
|
T_RGBA v1_rgba;
|
|
T_RGBA v2_rgba;
|
|
T_RGBA v3_rgba;
|
|
T_RGBA v4_rgba; // Used with quad type face
|
|
} T_HOBFILE_FACES_VERTEX_COLOR;
|
|
|
|
typedef struct PACK hobfile_faces_extra_color {
|
|
T_RGBA rgba;
|
|
} T_HOBFILE_FACES_COLOR;
|
|
|
|
typedef struct PACK hobfile_faces_extra_vertex_texture {
|
|
T_TEXCOORD v1_texcoord; // Should be divided (no shifting) by 4096 to get 0...1 range
|
|
T_TEXCOORD v2_texcoord;
|
|
T_TEXCOORD v3_texcoord;
|
|
T_TEXCOORD v4_texcoord; // Used with quad type face
|
|
} T_HOBFILE_FACES_VERTEX_TEXTURE;
|
|
|
|
typedef struct PACK hobfile_vertex {
|
|
short x;
|
|
short y;
|
|
short z;
|
|
short w;
|
|
} T_HOBFILE_VERTEX;
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma pack(pop)
|
|
#endif
|
|
|
|
#endif /* RSPMODELLIB_HOB_STRUCT_H_ */
|