Upgrade HOB struct with new uncovered fields
This commit is contained in:
parent
ec82ff4158
commit
1deb5eae2c
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file RSPModel_datatypes.h
|
||||
* @date 16/02/2023
|
||||
* @date 21/02/2023
|
||||
* @author JackCarterSmith
|
||||
* @copyright GPL-v3.0
|
||||
* @brief RSP Model workflow structures definitions
|
||||
@ -46,6 +46,8 @@ typedef struct rspmodel_vertex { short x,y,z,w; } T_RSPMODEL_VERTEX;
|
||||
|
||||
typedef struct rspmodel_texcoord { short u,v; } T_RSPMODEL_TEXCOORD;
|
||||
|
||||
typedef struct rspmodel_bbox { T_RSPMODEL_VECTOR3 start,end; } T_RSPMODEL_BBOX;
|
||||
|
||||
typedef struct face_flags {
|
||||
unsigned int fUnused0:1; //TODO: Parse all HOB to find anyone with this field different of 0
|
||||
unsigned int fUnused1:1; //TODO: Parse all HOB to find anyone with this field different of 0
|
||||
@ -99,8 +101,16 @@ typedef struct rspmodel_obj_parts {
|
||||
typedef struct rspmodel_object {
|
||||
char name[16];
|
||||
unsigned int face_group_offset;
|
||||
unsigned int object_part_header_offset;
|
||||
unsigned int face_group_header_offset;
|
||||
unsigned int object_parts_header_offset;
|
||||
unsigned int object_parts_header_offset2;
|
||||
unsigned int object_parts_header2_offset;
|
||||
unsigned int object_parts_header2_offset2;
|
||||
|
||||
unsigned int object_subparts_names_offset;
|
||||
unsigned int effects_offset;
|
||||
unsigned int properties_offset2;
|
||||
|
||||
T_RSPMODEL_BBOX bounding_box;
|
||||
|
||||
unsigned int object_part_count;
|
||||
unsigned int face_group_count;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file hob_parser.c
|
||||
* @date 16/02/2023
|
||||
* @date 21/02/2023
|
||||
* @author JackCarterSmith
|
||||
* @copyright GPL-v3.0
|
||||
* @brief Process HOB file structure and extract its datas.
|
||||
@ -12,8 +12,8 @@
|
||||
#include <string.h>
|
||||
#include "RSPModel_errordefs.h"
|
||||
#include "RSPModel_datatypes.h"
|
||||
#include "hob_struct.h"
|
||||
#include "hob_parser.h"
|
||||
#include "hob_struct.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -122,38 +122,75 @@ static unsigned short ExtractObjects(T_RSPMODEL_HOB* pHobStruct, const MEMFILE p
|
||||
if (pParams->debug_mode) printf("\n-=====================-Begin of Object part-======================-\n");
|
||||
|
||||
// Get object name
|
||||
memcpy(pHobStruct->objects[i].name, ((T_HOBFILE_OBJ_DESCRIPTOR *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_DESCRIPTOR) * i))->object_name, 16);
|
||||
memcpy(pHobStruct->objects[i].name, ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->object_name, 16);
|
||||
|
||||
if (pParams->verbose_mode) printf("\n[INFO] - Process %s object...\n", pHobStruct->objects[i].name);
|
||||
|
||||
|
||||
// Get offsets
|
||||
pHobStruct->objects[i].face_group_offset = ((T_HOBFILE_OBJ_DESCRIPTOR *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_DESCRIPTOR) * i))->facegroup_offset;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Face group offset: 0x%X\n", pHobStruct->objects[i].face_group_offset);
|
||||
pHobStruct->objects[i].object_part_header_offset = ((T_HOBFILE_OBJ_DESCRIPTOR *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_DESCRIPTOR) * i))->object_parts_offset;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Face group header/object parts offset: 0x%X\n", pHobStruct->objects[i].object_part_header_offset);
|
||||
pHobStruct->objects[i].face_group_header_offset = ((T_HOBFILE_OBJ_DESCRIPTOR *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_DESCRIPTOR) * i))->facegroup_header_2_offset;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Face group header2 offset: 0x%X\n", pHobStruct->objects[i].face_group_header_offset);
|
||||
pHobStruct->objects[i].face_group_offset = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->facegroup_start_offset;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Face group start offset: 0x%X\n", pHobStruct->objects[i].face_group_offset);
|
||||
pHobStruct->objects[i].object_parts_header_offset = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->object_parts_offset;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Object parts 1st header offset (main): 0x%X\n", pHobStruct->objects[i].object_parts_header_offset);
|
||||
pHobStruct->objects[i].object_parts_header_offset2 = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->object_parts_offset2;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Object parts 1st header offset (aux): 0x%X\n", pHobStruct->objects[i].object_parts_header_offset2);
|
||||
pHobStruct->objects[i].object_parts_header2_offset = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->object_parts2_offset;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Object parts 2nd header offset (main): 0x%X\n", pHobStruct->objects[i].object_parts_header2_offset);
|
||||
pHobStruct->objects[i].object_parts_header2_offset2 = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->object_parts2_offset2;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Object parts 2nd header offset (aux): 0x%X\n", pHobStruct->objects[i].object_parts_header2_offset2);
|
||||
pHobStruct->objects[i].object_subparts_names_offset = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->subparts_namelist_offset;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Object subparts names offset: 0x%X\n", pHobStruct->objects[i].object_subparts_names_offset);
|
||||
pHobStruct->objects[i].effects_offset = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->effects_offset;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Object effects offset: 0x%X\n", pHobStruct->objects[i].effects_offset);
|
||||
pHobStruct->objects[i].properties_offset2 = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->properties_offset;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Object properties offset: 0x%X\n", pHobStruct->objects[i].properties_offset2);
|
||||
|
||||
pHobStruct->objects[i].bounding_box.start.x = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->bbox_start_x;
|
||||
pHobStruct->objects[i].bounding_box.start.y = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->bbox_start_y;
|
||||
pHobStruct->objects[i].bounding_box.start.z = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->bbox_start_z;
|
||||
pHobStruct->objects[i].bounding_box.end.x = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->bbox_end_x;
|
||||
pHobStruct->objects[i].bounding_box.end.y = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->bbox_end_y;
|
||||
pHobStruct->objects[i].bounding_box.end.z = ((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER)
|
||||
+ sizeof(T_HOBFILE_OBJ_HEADER) * i))->bbox_end_z;
|
||||
if (pParams->verbose_mode) {
|
||||
printf("[DBG] > Bounding box start: (%.8f, %.8f, %.8f)\n",
|
||||
pHobStruct->objects[i].bounding_box.start.x,
|
||||
pHobStruct->objects[i].bounding_box.start.y,
|
||||
pHobStruct->objects[i].bounding_box.start.z
|
||||
);
|
||||
printf("[DBG] > Bounding box end: (%.8f, %.8f, %.8f)\n",
|
||||
pHobStruct->objects[i].bounding_box.end.x,
|
||||
pHobStruct->objects[i].bounding_box.end.y,
|
||||
pHobStruct->objects[i].bounding_box.end.z
|
||||
);
|
||||
}
|
||||
|
||||
if (pParams->god_mode) {
|
||||
printf("[DBG] > Face group unknown1: %d\n",((T_HOBFILE_OBJ_DESCRIPTOR *)(pMemfile + sizeof(T_HOBFILE_HEADER) + sizeof(T_HOBFILE_OBJ_DESCRIPTOR) * i))->unknownOffset1);
|
||||
printf("[DBG] > Face group unknown2: %d\n",((T_HOBFILE_OBJ_DESCRIPTOR *)(pMemfile + sizeof(T_HOBFILE_HEADER) + sizeof(T_HOBFILE_OBJ_DESCRIPTOR) * i))->unknownOffset2);
|
||||
printf("[DBG] > Face group unknown3: %d\n",((T_HOBFILE_OBJ_DESCRIPTOR *)(pMemfile + sizeof(T_HOBFILE_HEADER) + sizeof(T_HOBFILE_OBJ_DESCRIPTOR) * i))->unknownOffset3);
|
||||
printf("[DBG] > Face group unknown4: %.8f\n",((T_HOBFILE_OBJ_DESCRIPTOR *)(pMemfile + sizeof(T_HOBFILE_HEADER) + sizeof(T_HOBFILE_OBJ_DESCRIPTOR) * i))->unknown4);
|
||||
printf("[DBG] > Object header unknown4: %.8f\n",((T_HOBFILE_OBJ_HEADER *)(pMemfile + sizeof(T_HOBFILE_HEADER) + sizeof(T_HOBFILE_OBJ_HEADER) * i))->unknown4);
|
||||
}
|
||||
|
||||
// Get count and offsets from the facegroup header
|
||||
pHobStruct->objects[i].object_part_count = ((T_HOBFILE_FACEGROUP_HEADER *)(pMemfile
|
||||
+ pHobStruct->objects[i].object_part_header_offset))->object_part_count;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Object parts count: %d\n", pHobStruct->objects[i].object_part_count);
|
||||
pHobStruct->objects[i].face_group_count = ((T_HOBFILE_FACEGROUP_HEADER *)(pMemfile
|
||||
+ pHobStruct->objects[i].object_part_header_offset))->facegroup_count;
|
||||
pHobStruct->objects[i].object_part_count = ((T_HOBFILE_FACEGROUP_HEADER_1 *)(pMemfile
|
||||
+ pHobStruct->objects[i].object_parts_header_offset))->object_part_count;
|
||||
if (pParams->verbose_mode) printf("\n[DBG] > Object parts count: %d\n", pHobStruct->objects[i].object_part_count);
|
||||
pHobStruct->objects[i].face_group_count = ((T_HOBFILE_FACEGROUP_HEADER_1 *)(pMemfile
|
||||
+ pHobStruct->objects[i].object_parts_header_offset))->facegroup_count;
|
||||
if (pParams->verbose_mode) printf("[DBG] > Face groups count: %d\n", pHobStruct->objects[i].face_group_count);
|
||||
//TODO: Caution with obj/facegrp count difference. What is facegroup count???
|
||||
//TODO: Caution with obj/facegrp count difference. What is REALLY facegroup count???
|
||||
/*
|
||||
* Seem "object" are independant structure like xwing, turret, etc.
|
||||
* Facegroup is more like part of previous object, like wing-left, turret-barrel, etc.
|
||||
@ -187,8 +224,8 @@ static unsigned short ExtractObjParts(T_RSPMODEL_OBJECT* pObject, const MEMFILE
|
||||
|
||||
for ( i = 0; i < pObject->object_part_count; i++ ) {
|
||||
if (pParams->debug_mode) printf("\n-----------------------Begin of Mesh part-------------------------\n");
|
||||
subpart_offset = ((T_HOBFILE_FACEGROUP_OFFSET *)(pMemfile + pObject->object_part_header_offset
|
||||
+ sizeof(T_HOBFILE_FACEGROUP_HEADER) + sizeof(T_HOBFILE_FACEGROUP_OFFSET) * i))->facegroup_offset;
|
||||
subpart_offset = ((T_HOBFILE_FACEGROUP_OFFSET_1 *)(pMemfile + pObject->object_parts_header_offset
|
||||
+ sizeof(T_HOBFILE_FACEGROUP_HEADER_1) + sizeof(T_HOBFILE_FACEGROUP_OFFSET_1) * i))->facegroup_offset;
|
||||
if (pParams->verbose_mode) printf("\n[DBG] > Face group meshdef0 offset: 0x%X\n", subpart_offset);
|
||||
|
||||
// Get meshdef0 datas
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file hob_parser.h
|
||||
* @date 18/01/2023
|
||||
* @date 21/02/2023
|
||||
* @author JackCarterSmith
|
||||
* @copyright GPL-v3.0
|
||||
* @brief Process HOB file structure and extract its datas.
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file hob_struct.h
|
||||
* @date 26/07/2022
|
||||
* @date 21/02/2023
|
||||
* @author JackCarterSmith
|
||||
* @copyright GPL-v3.0
|
||||
* @brief HOB file mapping definition.
|
||||
@ -36,61 +36,86 @@
|
||||
/*
|
||||
* - Global HOB file structure-
|
||||
* +------------------+--------------------------------------+----------------------------------------+
|
||||
* | T_HOBFILE_HEADER | obj_count * T_HOBFILE_OBJ_DESCRIPTOR | obj_count * T_HOBFILE_FACEGROUP_HEADER |
|
||||
* | 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 |
|
||||
* +----------------------------+------------------------------------------------+
|
||||
* +------------------------------+--------------------------------------------------+
|
||||
* --> | T_HOBFILE_FACEGROUP_HEADER_1 | object_part_count * T_HOBFILE_FACEGROUP_OFFSET_1 |
|
||||
* +------------------------------+--------------------------------------------------+
|
||||
*
|
||||
* - Facegroup sub-structure 2 -
|
||||
* +------------------------------+------------------------------------------------------------------------+--------------------------------------------------------+
|
||||
* | T_HOBFILE_FACEGROUP_HEADER_2 | ( object_part_count + facegroup_count ) * T_HOBFILE_FACEGROUP_OFFSET_2 | ( object_part_count - 1 ) * T_HOBFILE_FACEGROUP_NAMEID | + padding
|
||||
* +------------------------------+------------------------------------------------------------------------+--------------------------------------------------------+
|
||||
*/
|
||||
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;
|
||||
typedef struct PACK hobfile_obj_header {
|
||||
unsigned char object_name[16]; // Name of the object
|
||||
|
||||
unsigned int reserved1; // 12B of zeros
|
||||
unsigned int reserved2;
|
||||
unsigned int reserved3;
|
||||
unsigned int facegroup_start_offset; // First facegroup datas offset. Look in T_HOBFILE_FACEGROUP_HEADER for all offsets of facegroups of the current object.
|
||||
unsigned int object_parts_offset; // Object parts descriptor offset
|
||||
unsigned int object_parts_offset2; // Facegroup descriptor offset (subpart of Object parts descriptor)
|
||||
|
||||
unsigned int unknownOffset1;
|
||||
unsigned int unknownOffset2;
|
||||
unsigned int unknownOffset3;
|
||||
float unknown4;
|
||||
unsigned int object_parts2_offset; // Optional offset - seem present in tieinter_HOB - point just after the 0xFFFFFFFF of the first one
|
||||
unsigned int object_parts2_offset2; // Optional offset - seem present in tieinter_HOB
|
||||
unsigned int reserved1; // Always zeros ?
|
||||
|
||||
unsigned int reserved4; // 12B of zeros
|
||||
unsigned int subparts_namelist_offset; // Point to an array of string value (8 chars) + ID (2 chars - 1 to obj_parts-1). Seem like name of articulation points (some have name like "node_86").
|
||||
unsigned int effects_offset; // Empty in gun_turret and no datas after, xwing have 0x5006, present in koelsch. worddevastator can have more answers...
|
||||
unsigned int properties_offset; // Offset to different string (a_b/zf/zt/zb/etc.) Animation datas ? Empty with 6x float in train_hob, a_b object is canon beams in gun_turret
|
||||
|
||||
float unknown4; // Probably scale: 1.0F/1.125F
|
||||
|
||||
unsigned int reserved4; // 12B of zeros
|
||||
unsigned int reserved5;
|
||||
unsigned int reserved6;
|
||||
|
||||
float reserved7;
|
||||
float unknown5; //Scale? ~20.0F
|
||||
float unknown6; //Scale? ~77-418.0F
|
||||
|
||||
float reserved7; //Translation matrix? Center of object?
|
||||
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 int footer_offset; //To redefine, seem to be a copy of following bounding box? Maybe there are 2 box: render and collision?
|
||||
|
||||
float bbox_start_x; // Bounding box start vector
|
||||
float bbox_start_y;
|
||||
float bbox_start_z;
|
||||
|
||||
float bbox_end_x; // Bounding box start vector
|
||||
float bbox_end_y;
|
||||
float bbox_end_z;
|
||||
} T_HOBFILE_OBJ_HEADER;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_header_1 {
|
||||
unsigned short object_part_count;
|
||||
unsigned short facegroup_count;
|
||||
} T_HOBFILE_FACEGROUP_HEADER;
|
||||
} T_HOBFILE_FACEGROUP_HEADER_1;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_offset {
|
||||
unsigned int unknown1;
|
||||
typedef struct PACK hobfile_facegroup_offset_1 {
|
||||
unsigned int unknown0; // Flags?
|
||||
unsigned int facegroup_offset;
|
||||
} T_HOBFILE_FACEGROUP_OFFSET;
|
||||
} T_HOBFILE_FACEGROUP_OFFSET_1;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_header_2 {
|
||||
unsigned short object_part_count;
|
||||
unsigned short facegroup_count;
|
||||
} T_HOBFILE_FACEGROUP_HEADER_2;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_offset_2 {
|
||||
unsigned int unknownOffset0;
|
||||
} T_HOBFILE_FACEGROUP_OFFSET_2;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_nameid {
|
||||
unsigned char name[8];
|
||||
unsigned short id;
|
||||
} T_HOBFILE_FACEGROUP_NAMEID;
|
||||
|
||||
typedef struct PACK hobfile_meshdef0 {
|
||||
unsigned int offset1;
|
||||
@ -180,11 +205,11 @@ typedef struct PACK 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 b1; // Seem to alter texture mapping on face, 49 -> quad face, 48 -> tri face, 47 -> N/A
|
||||
unsigned char b2; // 61 -> texture right rotation, 71 -> little red overlay, 81 -> bigger red overlay, x1 -> don't do anything
|
||||
unsigned char b3; // Seem to alter rendering matrix or maybe vertices position relative to
|
||||
unsigned char faceBlockIntSize; // Bytes size divided by 4, count as number of UInt32 type.
|
||||
unsigned short headerSeparator;
|
||||
unsigned short headerSeparator; // If header it's uncommon, it's probably because you made a wrong parsing
|
||||
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;
|
||||
|
@ -1,246 +0,0 @@
|
||||
/**
|
||||
* @file hob_struct.h
|
||||
* @date 16/02/2023
|
||||
* @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_1 | object_part_count * T_HOBFILE_FACEGROUP_OFFSET_1 |
|
||||
* +------------------------------+--------------------------------------------------+
|
||||
*
|
||||
* - Facegroup sub-structure 2 -
|
||||
* +------------------------------+------------------------------------------------------------------------+--------------------------------------------------------+
|
||||
* | T_HOBFILE_FACEGROUP_HEADER_2 | ( object_part_count + facegroup_count ) * T_HOBFILE_FACEGROUP_OFFSET_2 | ( object_part_count - 1 ) * T_HOBFILE_FACEGROUP_NAMEID | + padding
|
||||
* +------------------------------+------------------------------------------------------------------------+--------------------------------------------------------+
|
||||
*/
|
||||
typedef struct PACK hobfile_header {
|
||||
unsigned int obj_count;
|
||||
unsigned int vertices_offset;
|
||||
} T_HOBFILE_HEADER;
|
||||
|
||||
typedef struct PACK hobfile_obj_header {
|
||||
unsigned char object_name[16]; // Name of the object
|
||||
|
||||
unsigned int facegroup_start_offset; // First facegroup datas offset. Look in T_HOBFILE_FACEGROUP_HEADER for all offsets of facegroups of the current object.
|
||||
unsigned int object_parts_offset; // Object parts descriptor offset
|
||||
unsigned int object_parts_offset2; // Facegroup descriptor offset (subpart of Object parts descriptor)
|
||||
|
||||
unsigned int object_parts2_offset; // Optional offset - seem present in tieinter_HOB - point just after the 0xFFFFFFFF of the first one
|
||||
unsigned int object_parts2_offset2; // Optional offset - seem present in tieinter_HOB
|
||||
unsigned int reserved1; // Always zeros ?
|
||||
|
||||
unsigned int subparts_namelist_offset; // Point to an array of string value (8 chars) + ID (2 chars - 1 to obj_parts-1). Seem like name of articulation points (some have name like "node_86").
|
||||
unsigned int effects_offset; // Empty in gun_turret and no datas after, xwing have 0x5006, present in koelsch. worddevastator can have more answers...
|
||||
unsigned int properties_offset; // Offset to different string (a_b/zf/zt/zb/etc.) Animation datas ? Empty with 6x float in train_hob
|
||||
|
||||
float unknown4; // Probably scale: 1.0F/1.125F
|
||||
|
||||
unsigned int reserved4; // 12B of zeros
|
||||
unsigned int reserved5;
|
||||
unsigned int reserved6;
|
||||
|
||||
float unknown5; //Scale? ~20.0F
|
||||
float unknown6; //Scale? ~77-418.0F
|
||||
|
||||
float reserved7; //Translation matrix? Center of object?
|
||||
float reserved8;
|
||||
float reserved9;
|
||||
|
||||
unsigned int footer_offset; //To redefine, seem to be a copy of following bounding box? Maybe there are 2 box: render and collision?
|
||||
|
||||
float bbox_start_x; // Bounding box start vector
|
||||
float bbox_start_y;
|
||||
float bbox_start_z;
|
||||
|
||||
float bbox_end_x; // Bounding box start vector
|
||||
float bbox_end_y;
|
||||
float bbox_end_z;
|
||||
} T_HOBFILE_OBJ_HEADER;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_header_1 {
|
||||
unsigned short object_part_count;
|
||||
unsigned short facegroup_count;
|
||||
} T_HOBFILE_FACEGROUP_HEADER_1;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_offset_1 {
|
||||
unsigned int unknown0; // Flags?
|
||||
unsigned int facegroup_offset;
|
||||
} T_HOBFILE_FACEGROUP_OFFSET_1;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_header_2 {
|
||||
unsigned short object_part_count;
|
||||
unsigned short facegroup_count;
|
||||
} T_HOBFILE_FACEGROUP_HEADER_2;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_offset_2 {
|
||||
unsigned int unknownOffset0;
|
||||
} T_HOBFILE_FACEGROUP_OFFSET_2;
|
||||
|
||||
typedef struct PACK hobfile_facegroup_nameid {
|
||||
unsigned char name[8];
|
||||
unsigned short id;
|
||||
} T_HOBFILE_FACEGROUP_NAMEID;
|
||||
|
||||
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; // Seem to alter texture mapping on face, 49 -> quad face, 48 -> tri face, 47 -> N/A
|
||||
unsigned char b2; // 61 -> texture right rotation, 71 -> little red overlay, 81 -> bigger red overlay, x1 -> don't do anything
|
||||
unsigned char b3; // Seem to alter rendering matrix or maybe vertices position relative to
|
||||
unsigned char faceBlockIntSize; // Bytes size divided by 4, count as number of UInt32 type.
|
||||
unsigned short headerSeparator; // If header it's uncommon, it's probably because you made a wrong parsing
|
||||
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_RSPMODEL_RGBA v1_rgba;
|
||||
T_RSPMODEL_RGBA v2_rgba;
|
||||
T_RSPMODEL_RGBA v3_rgba;
|
||||
T_RSPMODEL_RGBA v4_rgba; // Used with quad type face
|
||||
} T_HOBFILE_FACES_VERTEX_COLOR;
|
||||
|
||||
typedef struct PACK hobfile_faces_extra_color {
|
||||
T_RSPMODEL_RGBA rgba;
|
||||
} T_HOBFILE_FACES_COLOR;
|
||||
|
||||
typedef struct PACK hobfile_faces_extra_vertex_texture {
|
||||
T_RSPMODEL_TEXCOORD v1_texcoord; // Should be divided (no shifting) by 4096 to get 0...1 range
|
||||
T_RSPMODEL_TEXCOORD v2_texcoord;
|
||||
T_RSPMODEL_TEXCOORD v3_texcoord;
|
||||
T_RSPMODEL_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_ */
|
Loading…
x
Reference in New Issue
Block a user