add Hu3DModelLightInfoSet

This commit is contained in:
CreateSource 2023-12-26 22:00:05 -05:00
parent beb6f072d2
commit 5a2cd47fba
4 changed files with 224 additions and 153 deletions

View file

@ -247,7 +247,7 @@ config.libs = [
Object(Matching, "game/sprput.c"), Object(Matching, "game/sprput.c"),
Object(Matching, "game/hsfload.c"), Object(Matching, "game/hsfload.c"),
Object(NonMatching, "game/hsfdraw.c"), Object(NonMatching, "game/hsfdraw.c"),
Object(NonMatching, "game/hsfman.c"), Object(Matching, "game/hsfman.c"),
Object(NonMatching, "game/hsfmotion.c"), Object(NonMatching, "game/hsfmotion.c"),
Object(NonMatching, "game/hsfanim.c"), Object(NonMatching, "game/hsfanim.c"),
Object(NonMatching, "game/hsfex.c"), Object(NonMatching, "game/hsfex.c"),

View file

@ -285,6 +285,18 @@ typedef struct hsf_camera {
float far; float far;
} HsfCamera; } HsfCamera;
typedef struct hsf_light {
HsfVector3f pos;
HsfVector3f target;
u8 type;
u8 r;
u8 g;
u8 b;
float unk2C;
float ref_distance;
float ref_brightness;
float cutoff;
} HsfLight;
typedef struct hsf_object { typedef struct hsf_object {
char *name; char *name;
u32 type; u32 type;
@ -293,6 +305,7 @@ typedef struct hsf_object {
union { union {
HsfObjectData data; HsfObjectData data;
HsfCamera camera; HsfCamera camera;
HsfLight light;
}; };
} HsfObject; } HsfObject;

View file

@ -30,8 +30,8 @@ typedef struct model_data {
s16 unk_20; s16 unk_20;
u16 camera; u16 camera;
s16 unk_24; s16 unk_24;
s16 unk_26; u16 unk_26;
char unk_28[0x10]; u16 unk_28[8];
s16 unk_38[8]; s16 unk_38[8];
HsfData *unk_48; HsfData *unk_48;
HsfData *unk_4C; HsfData *unk_4C;
@ -205,7 +205,6 @@ void Hu3DCameraKill(s32);
void Hu3DCameraAllKill(void); void Hu3DCameraAllKill(void);
void Hu3DCameraSet(s32, Mtx); void Hu3DCameraSet(s32, Mtx);
BOOL Hu3DModelCameraInfoSet(s16, u16); BOOL Hu3DModelCameraInfoSet(s16, u16);
BOOL Hu3DModelLightInfoSet(s16, u16);
s16 Hu3DModelCameraCreate(s16, u16); s16 Hu3DModelCameraCreate(s16, u16);
void Hu3DCameraMotionOn(s16, s8); void Hu3DCameraMotionOn(s16, s8);
void Hu3DCameraMotionStart(s16, u16); void Hu3DCameraMotionStart(s16, u16);
@ -236,7 +235,7 @@ void Hu3DGLightPosAimSet(s16, f32, f32, f32, f32, f32, f32);
void Hu3DLLightPosAimSet(s16, s16, f32, f32, f32, f32, f32, f32); void Hu3DLLightPosAimSet(s16, s16, f32, f32, f32, f32, f32, f32);
void Hu3DGLightStaticSet(s16, s32); void Hu3DGLightStaticSet(s16, s32);
void Hu3DLLightStaticSet(s16, s16, s32); void Hu3DLLightStaticSet(s16, s16, s32);
//... s32 Hu3DModelLightInfoSet(s16, s16);
s16 Hu3DLightSet(ModelData*, s32, s32, f32); s16 Hu3DLightSet(ModelData*, s32, s32, f32);
void lightSet(LightData*, s16, s32, s32, f32); void lightSet(LightData*, s16, s32, s32, f32);
//... //...

View file

@ -1445,66 +1445,68 @@ s16 Hu3DLLightCreateV(s16 arg0, Vec* arg1, Vec* arg2, GXColor* arg3) {
return var_r30; return var_r30;
} }
void Hu3DGLightSpotSet(s16 arg0, u16 arg1, f32 arg8) { inline void Hu3DLightSpotSet(LightData *light, u16 arg1, f32 arg8) {
LightData* temp_r31; light->unk_00 &= 0xFF00;
light->unk_04 = arg8;
light->unk_02 = arg1;
}
temp_r31 = &Hu3DGlobalLight[arg0]; void Hu3DGLightSpotSet(s16 arg0, u16 arg1, f32 arg8) {
temp_r31->unk_00 &= 0xFF00; LightData *light = &Hu3DGlobalLight[arg0];
temp_r31->unk_04 = arg8;
temp_r31->unk_02 = arg1; Hu3DLightSpotSet(light, arg1, arg8);
} }
void Hu3DLLightSpotSet(s16 arg0, s16 arg1, u16 arg2, f32 arg8) { void Hu3DLLightSpotSet(s16 arg0, s16 arg1, u16 arg2, f32 arg8) {
ModelData* data; ModelData* data;
LightData* temp_r31; LightData* light;
data = &Hu3DData[arg0]; data = &Hu3DData[arg0];
temp_r31 = &Hu3DLocalLight[data->unk_38[arg1]]; light = &Hu3DLocalLight[data->unk_38[arg1]];
temp_r31->unk_00 &= 0xFF00; Hu3DLightSpotSet(light, arg2, arg8);
temp_r31->unk_04 = arg8; }
temp_r31->unk_02 = arg2;
inline void Hu3DLightInfinitytSet(LightData *light) {
light->unk_00 &= 0xFF00;
light->unk_00 |= 1;
} }
void Hu3DGLightInfinitytSet(s16 lightIndex) { void Hu3DGLightInfinitytSet(s16 lightIndex) {
LightData* temp_r31; LightData* light = &Hu3DGlobalLight[lightIndex];
temp_r31 = &Hu3DGlobalLight[lightIndex]; Hu3DLightInfinitytSet(light);
temp_r31->unk_00 &= 0xFF00;
temp_r31->unk_00 |= 1;
} }
void Hu3DLLightInfinitytSet(s16 dataIndex, s16 lightIndex) { void Hu3DLLightInfinitytSet(s16 dataIndex, s16 lightIndex) {
ModelData* data; ModelData* data;
LightData* temp_r31; LightData* light;
data = &Hu3DData[dataIndex]; data = &Hu3DData[dataIndex];
temp_r31 = &Hu3DLocalLight[data->unk_38[lightIndex]]; light = &Hu3DLocalLight[data->unk_38[lightIndex]];
temp_r31->unk_00 &= 0xFF00; Hu3DLightInfinitytSet(light);
temp_r31->unk_00 |= 1; }
inline void Hu3DLightPointSet(LightData *light, u16 arg1, f32 arg8, f32 arg9) {
light->unk_00 &= 0xFF00;
light->unk_00 |= 2;
light->unk_04 = arg8;
light->unk_08 = arg9;
light->unk_02 = arg1;
} }
void Hu3DGLightPointSet(s16 arg0, u16 arg1, f32 arg8, f32 arg9) { void Hu3DGLightPointSet(s16 arg0, u16 arg1, f32 arg8, f32 arg9) {
LightData* temp_r31; LightData* light = &Hu3DGlobalLight[arg0];
temp_r31 = &Hu3DGlobalLight[arg0]; Hu3DLightPointSet(light, arg1, arg8, arg9);
temp_r31->unk_00 &= 0xFF00;
temp_r31->unk_00 |= 2;
temp_r31->unk_04 = arg8;
temp_r31->unk_08 = arg9;
temp_r31->unk_02 = arg1;
} }
void Hu3DLLightPointSet(s16 arg0, s16 arg1, u16 arg2, f32 arg8, f32 arg9) { void Hu3DLLightPointSet(s16 arg0, s16 arg1, u16 arg2, f32 arg8, f32 arg9) {
ModelData* data; ModelData* data;
LightData* temp_r31; LightData* light;
data = &Hu3DData[arg0]; data = &Hu3DData[arg0];
temp_r31 = &Hu3DLocalLight[data->unk_38[arg1]]; light = &Hu3DLocalLight[data->unk_38[arg1]];
temp_r31->unk_00 &= 0xFF00; Hu3DLightPointSet(light, arg2, arg8, arg9);
temp_r31->unk_00 |= 2;
temp_r31->unk_04 = arg8;
temp_r31->unk_08 = arg9;
temp_r31->unk_02 = arg2;
} }
void Hu3DGLightKill(s16 index) { void Hu3DGLightKill(s16 index) {
@ -1543,161 +1545,218 @@ void Hu3DLightAllKill(void) {
} }
} }
void Hu3DGLightColorSet(s16 arg0, u8 arg1, u8 arg2, u8 arg3, u8 arg4) { inline void Hu3DLightColorSet(LightData *light, u8 r, u8 g, u8 b, u8 a) {
light->color.r = r;
light->color.g = g;
light->color.b = b;
light->color.a = a;
}
void Hu3DGLightColorSet(s16 index, u8 r, u8 g, u8 b, u8 a) {
LightData* light = &Hu3DGlobalLight[index];
Hu3DLightColorSet(light, r, g, b, a);
}
void Hu3DLLightColorSet(s16 dataIndex, s16 lightIndex, u8 r, u8 g, u8 b, u8 a) {
ModelData* data;
LightData* light; LightData* light;
light = &Hu3DGlobalLight[arg0]; data = &Hu3DData[dataIndex];
light->color.r = arg1; light = &Hu3DLocalLight[data->unk_38[lightIndex]];
light->color.g = arg2; Hu3DLightColorSet(light, r, g, b, a);
light->color.b = arg3;
light->color.a = arg4;
} }
void Hu3DLLightColorSet(s16 arg0, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) { inline void Hu3DLightPosSetV(LightData *light, Vec* pos, Vec* aim) {
light->unk_1C = *pos;
PSVECSubtract(aim, pos, &light->unk_28);
PSVECNormalize(&light->unk_28, &light->unk_28);
}
void Hu3DGLightPosSetV(s16 index, Vec* pos, Vec* aim) {
LightData* light = &Hu3DGlobalLight[index];
Hu3DLightPosSetV(light, pos, aim);
}
void Hu3DLLightPosSetV(s16 dataIndex, s16 lightIndex, Vec* pos, Vec* aim) {
ModelData* data;
LightData* light; LightData* light;
ModelData* data;
data = &Hu3DData[arg0]; data = &Hu3DData[dataIndex];
light = &Hu3DLocalLight[data->unk_38[arg1]]; light = &Hu3DLocalLight[data->unk_38[lightIndex]];
light->color.r = arg2; Hu3DLightPosSetV(light, pos, aim);
light->color.g = arg3;
light->color.b = arg4;
light->color.a = arg5;
} }
void Hu3DGLightPosSetV(s16 arg0, Vec* arg1, Point3d* arg2) { inline void Hu3DLightPosSet(LightData *light, f32 arg8, f32 arg9, f32 argA, f32 argB, f32 argC, f32 argD) {
Point3d* spC; light->unk_1C.x = arg8;
s16 sp8; light->unk_1C.y = arg9;
LightData* temp_r31; light->unk_1C.z = argA;
light->unk_28.x = argB;
temp_r31 = &Hu3DGlobalLight[arg0]; light->unk_28.y = argC;
temp_r31->unk_1C = *arg1; light->unk_28.z = argD;
PSVECNormalize(&light->unk_28, &light->unk_28);
PSVECNormalize(arg2, &temp_r31->unk_28);
}
void Hu3DLLightPosSetV(s16 arg0, s16 arg1, Vec* arg2, Point3d* arg3) {
ModelData* data;
LightData* temp_r31;
data = &Hu3DData[arg0];
temp_r31 = &Hu3DLocalLight[data->unk_38[arg1]];
temp_r31->unk_1C = *arg2;
PSVECNormalize(arg3, &temp_r31->unk_28);
} }
void Hu3DGLightPosSet(s16 arg0, f32 arg8, f32 arg9, f32 argA, f32 argB, f32 argC, f32 argD) { void Hu3DGLightPosSet(s16 arg0, f32 arg8, f32 arg9, f32 argA, f32 argB, f32 argC, f32 argD) {
LightData* temp_r31; LightData* light;
temp_r31 = &Hu3DGlobalLight[arg0]; light = &Hu3DGlobalLight[arg0];
temp_r31->unk_1C.x = arg8; Hu3DLightPosSet(light, arg8, arg9, argA, argB, argC, argD);
temp_r31->unk_1C.y = arg9;
temp_r31->unk_1C.z = argA;
temp_r31->unk_28.x = argB;
temp_r31->unk_28.y = argC;
temp_r31->unk_28.z = argD;
PSVECNormalize(&temp_r31->unk_28, &temp_r31->unk_28);
} }
void Hu3DLLightPosSet(s16 arg0, s16 arg1, f32 arg8, f32 arg9, f32 argA, f32 argB, f32 argC, f32 argD) { void Hu3DLLightPosSet(s16 arg0, s16 arg1, f32 arg8, f32 arg9, f32 argA, f32 argB, f32 argC, f32 argD) {
ModelData* data; ModelData* data;
LightData* temp_r31; LightData* light;
data = &Hu3DData[arg0]; data = &Hu3DData[arg0];
temp_r31 = &Hu3DLocalLight[data->unk_38[arg1]]; light = &Hu3DLocalLight[data->unk_38[arg1]];
temp_r31->unk_1C.x = arg8; Hu3DLightPosSet(light, arg8, arg9, argA, argB, argC, argD);
temp_r31->unk_1C.y = arg9;
temp_r31->unk_1C.z = argA;
temp_r31->unk_28.x = argB;
temp_r31->unk_28.y = argC;
temp_r31->unk_28.z = argD;
PSVECNormalize(&temp_r31->unk_28, &temp_r31->unk_28);
} }
void Hu3DGLightPosAimSetV(s16 arg0, Point3d* arg1, Point3d* arg2) { inline void Hu3DLightPosAimSetV(LightData *light, Vec* pos, Vec* aim) {
LightData* temp_r31; light->unk_1C = *pos;
PSVECSubtract(aim, pos, &light->unk_28);
PSVECNormalize(&light->unk_28, &light->unk_28);
}
temp_r31 = &Hu3DGlobalLight[arg0]; void Hu3DGLightPosAimSetV(s16 index, Vec* pos, Vec* aim) {
temp_r31->unk_1C = *arg1; LightData* light = &Hu3DGlobalLight[index];
PSVECSubtract(arg2, arg1, &temp_r31->unk_28); Hu3DLightPosAimSetV(light, pos, aim);
PSVECNormalize(&temp_r31->unk_28, &temp_r31->unk_28);
} }
void Hu3DLLightPosAimSetV(s16 arg0, s16 arg1, Point3d* arg2, Point3d* arg3) { void Hu3DLLightPosAimSetV(s16 dataIndex, s16 lightIndex, Vec* pos, Vec* aim) {
ModelData* data; ModelData* data;
LightData* temp_r31; LightData* light;
data = &Hu3DData[arg0]; data = &Hu3DData[dataIndex];
temp_r31 = &Hu3DLocalLight[data->unk_38[arg1]]; light = &Hu3DLocalLight[data->unk_38[lightIndex]];
temp_r31->unk_1C = *arg2; Hu3DLightPosAimSetV(light, pos, aim);
PSVECSubtract(arg3, arg2, &temp_r31->unk_28);
PSVECNormalize(&temp_r31->unk_28, &temp_r31->unk_28);
} }
void Hu3DGLightPosAimSet(s16 arg0, f32 arg8, f32 arg9, f32 argA, f32 argB, f32 argC, f32 argD) { void Hu3DGLightPosAimSet(s16 arg0, f32 arg8, f32 arg9, f32 argA, f32 argB, f32 argC, f32 argD) {
Vec vec2; Vec pos;
Vec vec1; Vec aim;
LightData* temp_r30; LightData *light;
LightData* temp_r31; LightData *light2;
vec2.x = arg8; pos.x = arg8;
vec2.y = arg9; pos.y = arg9;
vec2.z = argA; pos.z = argA;
vec1.x = argB; aim.x = argB;
vec1.y = argC; aim.y = argC;
vec1.z = argD; aim.z = argD;
temp_r30 = &Hu3DGlobalLight[arg0]; light = &Hu3DGlobalLight[arg0];
temp_r31 = temp_r30; light2 = light;
temp_r31->unk_1C = vec2; Hu3DLightPosAimSetV(light2, &pos, &aim);
PSVECSubtract(&vec1, &vec2, &temp_r31->unk_28);
PSVECNormalize(&temp_r31->unk_28, &temp_r31->unk_28);
} }
void Hu3DLLightPosAimSet(s16 arg0, s16 arg1, f32 arg8, f32 arg9, f32 argA, f32 argB, f32 argC, f32 argD) { void Hu3DLLightPosAimSet(s16 arg0, s16 arg1, f32 arg8, f32 arg9, f32 argA, f32 argB, f32 argC, f32 argD) {
Vec vec2; Vec pos;
Vec vec1; Vec aim;
ModelData* data; ModelData* data;
LightData* temp_r30; LightData* light;
LightData* temp_r31; LightData* light2;
vec2.x = arg8; pos.x = arg8;
vec2.y = arg9; pos.y = arg9;
vec2.z = argA; pos.z = argA;
vec1.x = argB; aim.x = argB;
vec1.y = argC; aim.y = argC;
vec1.z = argD; aim.z = argD;
data = &Hu3DData[arg0];
light = &Hu3DLocalLight[data->unk_38[arg1]];
light2 = light;
Hu3DLightPosAimSetV(light2, &pos, &aim);
}
inline void Hu3DLightStaticSet(LightData *light, s32 arg1) {
if (arg1 != 0) {
light->unk_00 |= 0x8000;
} else {
light->unk_00 &= ~0x8000;
}
}
void Hu3DGLightStaticSet(s16 index, s32 arg1) {
LightData* light = &Hu3DGlobalLight[index];
data = &Hu3DData[arg0]; Hu3DLightStaticSet(light, arg1);
temp_r30 = &Hu3DLocalLight[data->unk_38[arg1]];
temp_r31 = temp_r30;
temp_r31->unk_1C = vec2;
PSVECSubtract(&vec1, &vec2, &temp_r31->unk_28);
PSVECNormalize(&temp_r31->unk_28, &temp_r31->unk_28);
} }
void Hu3DGLightStaticSet(s16 arg0, s32 arg1) { void Hu3DLLightStaticSet(s16 dataIndex, s16 lightIndex, s32 arg2) {
LightData* temp_r31;
temp_r31 = &Hu3DGlobalLight[arg0];
if (arg1 != 0) temp_r31->unk_00 |= 0x8000;
else temp_r31->unk_00 &= ~0x8000;
}
void Hu3DLLightStaticSet(s16 arg0, s16 arg1, s32 arg2) {
ModelData* data; ModelData* data;
LightData* temp_r31; LightData* light;
data = &Hu3DData[arg0]; data = &Hu3DData[dataIndex];
temp_r31 = &Hu3DLocalLight[data->unk_38[arg1]]; light = &Hu3DLocalLight[data->unk_38[lightIndex]];
if (arg2 != 0) temp_r31->unk_00 |= 0x8000; Hu3DLightStaticSet(light, arg2);
else temp_r31->unk_00 &= ~0x8000;
} }
// ... s32 Hu3DModelLightInfoSet(s16 arg0, s16 arg1) {
Vec sp48;
Vec sp3C;
Vec sp30;
LightData* sp1C;
s16 sp12;
u8 spE;
u8 spD;
u8 spC;
HsfData* temp_r21;
HsfObject* var_r18;
HsfObject* var_r31;
ModelData* temp_r28;
s16 var_r17;
s16 var_r25;
temp_r28 = &Hu3DData[arg0];
temp_r21 = temp_r28->hsfData;
if (temp_r28->unk_26 != 0) {
return temp_r28->unk_26;
}
var_r31 = temp_r21->object;
for (var_r17 = var_r25 = 0; var_r17 < temp_r21->objectCnt; var_r17++, var_r31++) {
var_r18 = var_r31;
if (var_r18->type != 8) {
continue;
}
sp48.x = var_r18->light.target.x - var_r18->light.pos.x;
sp48.y = var_r18->light.target.y - var_r18->light.pos.y;
sp48.z = var_r18->light.target.z - var_r18->light.pos.z;
spC = var_r18->light.b;
spD = var_r18->light.g;
spE = var_r18->light.r;
sp12 = Hu3DGLightCreate(var_r18->light.pos.x, var_r18->light.pos.y, var_r18->light.pos.z,
sp48.x, sp48.y, sp48.z, spE, spD, spC);
temp_r28->unk_28[var_r25] = sp12;
sp1C = &Hu3DGlobalLight[sp12];
Hu3DGLightStaticSet(sp12, arg1);
switch (var_r18->light.type) {
case 0:
Hu3DGLightSpotSet(sp12, 2, var_r18->light.cutoff);
break;
case 1:
Hu3DGLightPointSet(sp12, 2, var_r18->data.base.scale.x - var_r18->data.base.rot.z, 1.0f);
Hu3DGLightPosSet(sp12, var_r18->light.pos.x, var_r18->light.pos.y, var_r18->light.pos.z, var_r18->light.target.x, var_r18->light.target.y, var_r18->light.target.z);
break;
case 2:
Hu3DGLightInfinitytSet(sp12);
break;
}
var_r25++;
if (var_r25 >= 8) {
break;
}
}
temp_r28->unk_26 = var_r25;
return var_r25;
}
s16 Hu3DLightSet(ModelData* arg0, s32 arg1, s32 arg2, f32 arg8) { s16 Hu3DLightSet(ModelData* arg0, s32 arg1, s32 arg2, f32 arg8) {
s16 var_r30; s16 var_r30;