Match FaceLoad
This commit is contained in:
parent
089bd06175
commit
afac7f1f7b
2 changed files with 106 additions and 59 deletions
|
|
@ -101,7 +101,11 @@ typedef struct hsf_vertex_buf {
|
||||||
char *name;
|
char *name;
|
||||||
s32 count;
|
s32 count;
|
||||||
void *data;
|
void *data;
|
||||||
} HsfVertexBuf;
|
} HsfBuffer;
|
||||||
|
|
||||||
|
typedef struct hsf_tristrip {
|
||||||
|
u16 data[4];
|
||||||
|
} HsfTristrip;
|
||||||
|
|
||||||
typedef struct hsf_face {
|
typedef struct hsf_face {
|
||||||
u16 type;
|
u16 type;
|
||||||
|
|
@ -110,11 +114,12 @@ typedef struct hsf_face {
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
u32 count;
|
u32 count;
|
||||||
u16 *data;
|
HsfTristrip *data;
|
||||||
} strip;
|
} strip;
|
||||||
u16 ext_indices[4];
|
u16 ext_indices[4];
|
||||||
};
|
};
|
||||||
} HSFFace;
|
float nbt[3];
|
||||||
|
} HsfFace;
|
||||||
|
|
||||||
typedef struct hsf_const_data {
|
typedef struct hsf_const_data {
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
|
@ -122,38 +127,11 @@ typedef struct hsf_const_data {
|
||||||
} HsfConstData;
|
} HsfConstData;
|
||||||
|
|
||||||
typedef struct hsf_transform {
|
typedef struct hsf_transform {
|
||||||
Vec pos;
|
HsfVector3f pos;
|
||||||
Vec rot;
|
HsfVector3f rot;
|
||||||
Vec scale;
|
HsfVector3f scale;
|
||||||
} HsfTransform;
|
} HsfTransform;
|
||||||
|
|
||||||
typedef struct hsf_object_data {
|
|
||||||
struct hsf_object *parent;
|
|
||||||
u32 childrenCount;
|
|
||||||
struct hsf_object **children;
|
|
||||||
HsfTransform base;
|
|
||||||
HsfTransform curr;
|
|
||||||
Vec min;
|
|
||||||
Vec max;
|
|
||||||
u8 unk[136];
|
|
||||||
HsfVertexBuf *face;
|
|
||||||
HsfVertexBuf *vertex;
|
|
||||||
HsfVertexBuf *normal;
|
|
||||||
HsfVertexBuf *st;
|
|
||||||
HsfVertexBuf *color;
|
|
||||||
HsfMaterial *material;
|
|
||||||
HsfAttribute *attribute;
|
|
||||||
u8 unk2[36];
|
|
||||||
} HsfObjectData;
|
|
||||||
|
|
||||||
typedef struct hsf_object {
|
|
||||||
char *name;
|
|
||||||
u32 type;
|
|
||||||
HsfConstData *constData;
|
|
||||||
u32 flags;
|
|
||||||
HsfObjectData data;
|
|
||||||
} HsfObject;
|
|
||||||
|
|
||||||
typedef struct hsf_cenv {
|
typedef struct hsf_cenv {
|
||||||
u8 unk[36];
|
u8 unk[36];
|
||||||
} HsfCenv;
|
} HsfCenv;
|
||||||
|
|
@ -174,9 +152,43 @@ typedef struct hsf_shape {
|
||||||
char *name;
|
char *name;
|
||||||
u16 count1;
|
u16 count1;
|
||||||
u16 morphTargetCnt;
|
u16 morphTargetCnt;
|
||||||
HsfVertexBuf **morphTargets;
|
HsfBuffer **morphTargets;
|
||||||
} HsfShape;
|
} HsfShape;
|
||||||
|
|
||||||
|
typedef struct hsf_object_data {
|
||||||
|
struct hsf_object *parent;
|
||||||
|
u32 childrenCount;
|
||||||
|
struct hsf_object **children;
|
||||||
|
HsfTransform base;
|
||||||
|
HsfTransform curr;
|
||||||
|
Vec min;
|
||||||
|
Vec max;
|
||||||
|
u8 unk[136];
|
||||||
|
HsfBuffer *face;
|
||||||
|
HsfBuffer *vertex;
|
||||||
|
HsfBuffer *normal;
|
||||||
|
HsfBuffer *st;
|
||||||
|
HsfBuffer *color;
|
||||||
|
HsfMaterial *material;
|
||||||
|
HsfAttribute *attribute;
|
||||||
|
u8 unk2[12];
|
||||||
|
u32 vertexShapeCnt;
|
||||||
|
HsfBuffer **vertexShape;
|
||||||
|
u32 clusterCnt;
|
||||||
|
HsfCluster **cluster;
|
||||||
|
u32 hook;
|
||||||
|
HsfCenv *cenv;
|
||||||
|
void *file[2];
|
||||||
|
} HsfObjectData;
|
||||||
|
|
||||||
|
typedef struct hsf_object {
|
||||||
|
char *name;
|
||||||
|
u32 type;
|
||||||
|
HsfConstData *constData;
|
||||||
|
u32 flags;
|
||||||
|
HsfObjectData data;
|
||||||
|
} HsfObject;
|
||||||
|
|
||||||
typedef struct hsf_skeleton {
|
typedef struct hsf_skeleton {
|
||||||
char *name;
|
char *name;
|
||||||
HsfTransform transform;
|
HsfTransform transform;
|
||||||
|
|
@ -217,11 +229,11 @@ typedef struct hsf_data {
|
||||||
HsfScene *scene;
|
HsfScene *scene;
|
||||||
HsfAttribute *attribute;
|
HsfAttribute *attribute;
|
||||||
HsfMaterial *material;
|
HsfMaterial *material;
|
||||||
HsfVertexBuf *vertex;
|
HsfBuffer *vertex;
|
||||||
HsfVertexBuf *normal;
|
HsfBuffer *normal;
|
||||||
HsfVertexBuf *st;
|
HsfBuffer *st;
|
||||||
HsfVertexBuf *color;
|
HsfBuffer *color;
|
||||||
HsfVertexBuf *face;
|
HsfBuffer *face;
|
||||||
HsfBitmap *bitmap;
|
HsfBitmap *bitmap;
|
||||||
HsfPalette *palette;
|
HsfPalette *palette;
|
||||||
HsfObject *root;
|
HsfObject *root;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ char *StringTable;
|
||||||
char *DicStringTable;
|
char *DicStringTable;
|
||||||
void **NSymIndex;
|
void **NSymIndex;
|
||||||
HsfObject *objtop;
|
HsfObject *objtop;
|
||||||
HsfVertexBuf *vtxtop;
|
HsfBuffer *vtxtop;
|
||||||
HsfCluster *ClusterTop;
|
HsfCluster *ClusterTop;
|
||||||
HsfAttribute *AttributeTop;
|
HsfAttribute *AttributeTop;
|
||||||
HsfMaterial *MaterialTop;
|
HsfMaterial *MaterialTop;
|
||||||
|
|
@ -226,20 +226,20 @@ static void SceneLoad(void)
|
||||||
static void ColorLoad(void)
|
static void ColorLoad(void)
|
||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
HsfVertexBuf *file_color;
|
HsfBuffer *file_color;
|
||||||
HsfVertexBuf *new_color;
|
HsfBuffer *new_color;
|
||||||
void *data;
|
void *data;
|
||||||
void *color_data;
|
void *color_data;
|
||||||
HsfVertexBuf *temp_color;
|
HsfBuffer *temp_color;
|
||||||
|
|
||||||
if(head.color.count) {
|
if(head.color.count) {
|
||||||
temp_color = file_color = (HsfVertexBuf *)((u32)fileptr+head.color.ofs);
|
temp_color = file_color = (HsfBuffer *)((u32)fileptr+head.color.ofs);
|
||||||
data = &file_color[head.color.count];
|
data = &file_color[head.color.count];
|
||||||
for(i=0; i<head.color.count; i++, file_color++);
|
for(i=0; i<head.color.count; i++, file_color++);
|
||||||
new_color = temp_color;
|
new_color = temp_color;
|
||||||
Model.color = new_color;
|
Model.color = new_color;
|
||||||
Model.colorCnt = head.color.count;
|
Model.colorCnt = head.color.count;
|
||||||
file_color = (HsfVertexBuf *)((u32)fileptr+head.color.ofs);
|
file_color = (HsfBuffer *)((u32)fileptr+head.color.ofs);
|
||||||
data = &file_color[head.color.count];
|
data = &file_color[head.color.count];
|
||||||
for(i=0; i<head.color.count; i++, new_color++, file_color++) {
|
for(i=0; i<head.color.count; i++, new_color++, file_color++) {
|
||||||
color_data = file_color->data;
|
color_data = file_color->data;
|
||||||
|
|
@ -252,14 +252,14 @@ static void ColorLoad(void)
|
||||||
static void VertexLoad(void)
|
static void VertexLoad(void)
|
||||||
{
|
{
|
||||||
s32 i, j;
|
s32 i, j;
|
||||||
HsfVertexBuf *file_vertex;
|
HsfBuffer *file_vertex;
|
||||||
HsfVertexBuf *new_vertex;
|
HsfBuffer *new_vertex;
|
||||||
void *data;
|
void *data;
|
||||||
HsfVector3f *data_elem;
|
HsfVector3f *data_elem;
|
||||||
void *temp_data;
|
void *temp_data;
|
||||||
|
|
||||||
if(head.vertex.count) {
|
if(head.vertex.count) {
|
||||||
vtxtop = file_vertex = (HsfVertexBuf *)((u32)fileptr+head.vertex.ofs);
|
vtxtop = file_vertex = (HsfBuffer *)((u32)fileptr+head.vertex.ofs);
|
||||||
data = (void *)&file_vertex[head.vertex.count];
|
data = (void *)&file_vertex[head.vertex.count];
|
||||||
for(i=0; i<head.vertex.count; i++, file_vertex++) {
|
for(i=0; i<head.vertex.count; i++, file_vertex++) {
|
||||||
for(j=0; j<(u32)file_vertex->count; j++) {
|
for(j=0; j<(u32)file_vertex->count; j++) {
|
||||||
|
|
@ -269,7 +269,7 @@ static void VertexLoad(void)
|
||||||
new_vertex = vtxtop;
|
new_vertex = vtxtop;
|
||||||
Model.vertex = new_vertex;
|
Model.vertex = new_vertex;
|
||||||
Model.vertexCnt = head.vertex.count;
|
Model.vertexCnt = head.vertex.count;
|
||||||
file_vertex = (HsfVertexBuf *)((u32)fileptr+head.vertex.ofs);
|
file_vertex = (HsfBuffer *)((u32)fileptr+head.vertex.ofs);
|
||||||
VertexDataTop = data = (void *)&file_vertex[head.vertex.count];
|
VertexDataTop = data = (void *)&file_vertex[head.vertex.count];
|
||||||
for(i=0; i<head.vertex.count; i++, new_vertex++, file_vertex++) {
|
for(i=0; i<head.vertex.count; i++, new_vertex++, file_vertex++) {
|
||||||
temp_data = file_vertex->data;
|
temp_data = file_vertex->data;
|
||||||
|
|
@ -290,20 +290,20 @@ static void NormalLoad(void)
|
||||||
{
|
{
|
||||||
s32 i, j;
|
s32 i, j;
|
||||||
void *temp_data;
|
void *temp_data;
|
||||||
HsfVertexBuf *file_normal;
|
HsfBuffer *file_normal;
|
||||||
HsfVertexBuf *new_normal;
|
HsfBuffer *new_normal;
|
||||||
HsfVertexBuf *temp_normal;
|
HsfBuffer *temp_normal;
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
|
|
||||||
if(head.normal.count) {
|
if(head.normal.count) {
|
||||||
s32 cenv_count = head.cenv.count;
|
s32 cenv_count = head.cenv.count;
|
||||||
temp_normal = file_normal = (HsfVertexBuf *)((u32)fileptr+head.normal.ofs);
|
temp_normal = file_normal = (HsfBuffer *)((u32)fileptr+head.normal.ofs);
|
||||||
data = (void *)&file_normal[head.normal.count];
|
data = (void *)&file_normal[head.normal.count];
|
||||||
new_normal = temp_normal;
|
new_normal = temp_normal;
|
||||||
Model.normal = new_normal;
|
Model.normal = new_normal;
|
||||||
Model.normalCnt = head.normal.count;
|
Model.normalCnt = head.normal.count;
|
||||||
file_normal = (HsfVertexBuf *)((u32)fileptr+head.normal.ofs);
|
file_normal = (HsfBuffer *)((u32)fileptr+head.normal.ofs);
|
||||||
NormalDataTop = data = (void *)&file_normal[head.normal.count];
|
NormalDataTop = data = (void *)&file_normal[head.normal.count];
|
||||||
for(i=0; i<head.normal.count; i++, new_normal++, file_normal++) {
|
for(i=0; i<head.normal.count; i++, new_normal++, file_normal++) {
|
||||||
temp_data = file_normal->data;
|
temp_data = file_normal->data;
|
||||||
|
|
@ -317,15 +317,15 @@ static void NormalLoad(void)
|
||||||
static void STLoad(void)
|
static void STLoad(void)
|
||||||
{
|
{
|
||||||
s32 i, j;
|
s32 i, j;
|
||||||
HsfVertexBuf *file_st;
|
HsfBuffer *file_st;
|
||||||
HsfVertexBuf *temp_st;
|
HsfBuffer *temp_st;
|
||||||
HsfVertexBuf *new_st;
|
HsfBuffer *new_st;
|
||||||
void *data;
|
void *data;
|
||||||
HsfVector2f *data_elem;
|
HsfVector2f *data_elem;
|
||||||
void *temp_data;
|
void *temp_data;
|
||||||
|
|
||||||
if(head.st.count) {
|
if(head.st.count) {
|
||||||
temp_st = file_st = (HsfVertexBuf *)((u32)fileptr+head.st.ofs);
|
temp_st = file_st = (HsfBuffer *)((u32)fileptr+head.st.ofs);
|
||||||
data = (void *)&file_st[head.st.count];
|
data = (void *)&file_st[head.st.count];
|
||||||
for(i=0; i<head.st.count; i++, file_st++) {
|
for(i=0; i<head.st.count; i++, file_st++) {
|
||||||
for(j=0; j<(u32)file_st->count; j++) {
|
for(j=0; j<(u32)file_st->count; j++) {
|
||||||
|
|
@ -335,7 +335,7 @@ static void STLoad(void)
|
||||||
new_st = temp_st;
|
new_st = temp_st;
|
||||||
Model.st = new_st;
|
Model.st = new_st;
|
||||||
Model.stCnt = head.st.count;
|
Model.stCnt = head.st.count;
|
||||||
file_st = (HsfVertexBuf *)((u32)fileptr+head.st.ofs);
|
file_st = (HsfBuffer *)((u32)fileptr+head.st.ofs);
|
||||||
data = (void *)&file_st[head.st.count];
|
data = (void *)&file_st[head.st.count];
|
||||||
for(i=0; i<head.st.count; i++, new_st++, file_st++) {
|
for(i=0; i<head.st.count; i++, new_st++, file_st++) {
|
||||||
temp_data = file_st->data;
|
temp_data = file_st->data;
|
||||||
|
|
@ -353,7 +353,42 @@ static void STLoad(void)
|
||||||
|
|
||||||
static void FaceLoad(void)
|
static void FaceLoad(void)
|
||||||
{
|
{
|
||||||
|
HsfBuffer *file_face;
|
||||||
|
HsfBuffer *new_face;
|
||||||
|
HsfBuffer *temp_face;
|
||||||
|
HsfFace *temp_data;
|
||||||
|
HsfFace *data;
|
||||||
|
HsfFace *file_face_strip;
|
||||||
|
HsfFace *new_face_strip;
|
||||||
|
HsfTristrip *strip;
|
||||||
|
s32 i;
|
||||||
|
s32 j;
|
||||||
|
|
||||||
|
if(head.face.count) {
|
||||||
|
temp_face = file_face = (HsfBuffer *)((u32)fileptr+head.face.ofs);
|
||||||
|
data = (HsfFace *)&file_face[head.face.count];
|
||||||
|
new_face = temp_face;
|
||||||
|
Model.face = new_face;
|
||||||
|
Model.faceCnt = head.face.count;
|
||||||
|
file_face = (HsfBuffer *)((u32)fileptr+head.face.ofs);
|
||||||
|
data = (HsfFace *)&file_face[head.face.count];
|
||||||
|
for(i=0; i<head.face.count; i++, new_face++, file_face++) {
|
||||||
|
temp_data = file_face->data;
|
||||||
|
new_face->name = SetName((u32 *)&file_face->name);
|
||||||
|
new_face->count = file_face->count;
|
||||||
|
new_face->data = (void *)((u32)data+(u32)temp_data);
|
||||||
|
strip = (HsfTristrip *)(&((HsfFace *)new_face->data)[new_face->count]);
|
||||||
|
}
|
||||||
|
new_face = temp_face;
|
||||||
|
for(i=0; i<head.face.count; i++, new_face++) {
|
||||||
|
file_face_strip = new_face_strip = new_face->data;
|
||||||
|
for(j=0; j<new_face->count; j++, new_face_strip++, file_face_strip++) {
|
||||||
|
if(file_face_strip->type == 4) {
|
||||||
|
new_face_strip->strip.data = &strip[(s32)file_face_strip->strip.data];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HsfBitmap *SearchBitmapPtr(s32 id)
|
static HsfBitmap *SearchBitmapPtr(s32 id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue