Merge pull request #111 from mrshigure/envelope

Matched EnvelopeExec and ClusterExec
This commit is contained in:
gamemasterplc 2024-01-16 12:32:28 -06:00 committed by GitHub
commit f25b020de5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 688 additions and 31 deletions

View file

@ -6196,7 +6196,7 @@ objtop = .sbss:0x801D3D60; // type:object size:0x4 scope:local data:4byte
nMesh = .sbss:0x801D3D64; // type:object size:0x4 scope:local data:4byte nMesh = .sbss:0x801D3D64; // type:object size:0x4 scope:local data:4byte
nObj = .sbss:0x801D3D68; // type:object size:0x4 scope:local data:4byte nObj = .sbss:0x801D3D68; // type:object size:0x4 scope:local data:4byte
MtxTop = .sbss:0x801D3D6C; // type:object size:0x4 data:4byte MtxTop = .sbss:0x801D3D6C; // type:object size:0x4 data:4byte
Vertextop = .sbss:0x801D3D70; // type:object size:0x8 data:4byte Vertextop = .sbss:0x801D3D70; // type:object size:0x4 data:4byte
SeqLanguage = .sbss:0x801D3D78; // type:object size:0x4 scope:local data:4byte SeqLanguage = .sbss:0x801D3D78; // type:object size:0x4 scope:local data:4byte
PauseProcess = .sbss:0x801D3D7C; // type:object size:0x4 scope:local data:4byte PauseProcess = .sbss:0x801D3D7C; // type:object size:0x4 scope:local data:4byte
PauseActive = .sbss:0x801D3D80; // type:object size:0x4 scope:local data:4byte PauseActive = .sbss:0x801D3D80; // type:object size:0x4 scope:local data:4byte

View file

@ -338,12 +338,12 @@ config.libs = [
Object(NonMatching, "game/objdll.c"), Object(NonMatching, "game/objdll.c"),
Object(Matching, "game/frand.c"), Object(Matching, "game/frand.c"),
Object(Matching, "game/audio.c"), Object(Matching, "game/audio.c"),
Object(NonMatching, "game/EnvelopeExec.c"), Object(Matching, "game/EnvelopeExec.c"),
Object(NonMatching, "game/minigame_seq.c"), Object(NonMatching, "game/minigame_seq.c"),
Object(Matching, "game/ovllist.c"), Object(Matching, "game/ovllist.c"),
Object(NonMatching, "game/esprite.c"), Object(NonMatching, "game/esprite.c"),
Object(NonMatching, "game/code_8003FF68.c"), Object(NonMatching, "game/code_8003FF68.c"),
Object(NonMatching, "game/ClusterExec.c"), Object(Matching, "game/ClusterExec.c"),
Object(NonMatching, "game/ShapeExec.c"), Object(NonMatching, "game/ShapeExec.c"),
Object(Matching, "game/wipe.c"), Object(Matching, "game/wipe.c"),
Object(Matching, "game/window.c"), Object(Matching, "game/window.c"),

View file

@ -0,0 +1,13 @@
#ifndef _GAME_CLUSTER_EXEC_H
#define _GAME_CLUSTER_EXEC_H
#include "game/hsfformat.h"
#include "game/hsfman.h"
float GetClusterCurve(HsfTrack *arg0, float arg1);
float GetClusterWeightCurve(HsfTrack *arg0, float arg1);
void SetClusterMain(HsfCluster *arg0);
void ClusterProc(ModelData *arg0);
void ClusterMotionExec(ModelData *arg0);
#endif

View file

@ -0,0 +1,12 @@
#ifndef _GAME_ENVELOPE_EXEC_H
#define _GAME_ENVELOPE_EXEC_H
#include "game/hsfformat.h"
void InitEnvelope(HsfData *arg0);
void EnvelopeProc(HsfData *arg0);
void InitVtxParm(HsfData *arg0);
extern Vec *Vertextop;
#endif

View file

@ -238,7 +238,7 @@ typedef struct hsf_cluster {
char *name[2]; char *name[2];
union { union {
char *targetName; char *targetName;
u32 target; s32 target;
}; };
HsfPart *part; HsfPart *part;
float unk10; float unk10;

View file

@ -117,11 +117,7 @@ typedef struct light_data {
GXColor color; GXColor color;
} LightData; } LightData;
extern void ClusterMotionExec(ModelData*); /* extern */
extern void ClusterProc(ModelData*); /* extern */
extern void EnvelopeProc(HsfData*); /* extern */
extern void GXWaitDrawDone(); /* extern */ extern void GXWaitDrawDone(); /* extern */
extern void InitVtxParm(HsfData*); /* extern */
extern void ShapeProc(HsfData*); /* extern */ extern void ShapeProc(HsfData*); /* extern */
extern void GXInitSpecularDir(GXLightObj*, f32, f32, f32); extern void GXInitSpecularDir(GXLightObj*, f32, f32, f32);

View file

@ -70,8 +70,6 @@ HsfBitmap *GetBitMap(s32 arg0, UnknownHsfMotionStruct01 *arg1, float arg2);
s16 Hu3DJointMotion(s16 arg0, void *arg1); s16 Hu3DJointMotion(s16 arg0, void *arg1);
void JointModel_Motion(s16 arg0, s16 arg1); void JointModel_Motion(s16 arg0, s16 arg1);
void Hu3DMotionCalc(s16 arg0); void Hu3DMotionCalc(s16 arg0);
s32 SearchObjectIndex(HsfData *arg0, u32 arg1);
s32 SearchAttributeIndex(HsfData *arg0, u32 arg1);
extern MotionData Hu3DMotion[256]; extern MotionData Hu3DMotion[256];

174
src/game/ClusterExec.c Normal file
View file

@ -0,0 +1,174 @@
#include "game/ClusterExec.h"
#include "game/EnvelopeExec.h"
#include "game/hsfmotion.h"
float GetClusterCurve(HsfTrack *arg0, float arg1) {
float *var_r30;
switch (arg0->curveType) {
case 1:
return GetLinear(arg0->numKeyframes, arg0->data, arg1);
case 2:
return GetBezier(arg0->numKeyframes, arg0, arg1);
case 4:
var_r30 = &arg0->value;
return *var_r30;
}
return 0.0f;
}
float GetClusterWeightCurve(HsfTrack *arg0, float arg1) {
float *var_r30;
switch (arg0->curveType) {
case 1:
return GetLinear(arg0->numKeyframes, arg0->data, arg1);
case 2:
return GetBezier(arg0->numKeyframes, arg0, arg1);
case 4:
var_r30 = &arg0->value;
return *var_r30;
}
return 0.0f;
}
void SetClusterMain(HsfCluster *arg0) {
float var_f30;
float var_f31;
s32 temp_r24;
s32 temp_r29;
u16 *var_r28;
s32 var_r23;
s32 i;
s32 j;
HsfBuffer *temp_r25;
HsfPart *temp_r27;
HsfBuffer *temp_r30;
temp_r27 = arg0->part;
if (arg0->vertexCnt != 0) {
if (arg0->type == 2) {
var_r28 = temp_r27->vertex;
temp_r30 = *arg0->vertex;
var_f30 = 0.0f;
for (i = 0; i < arg0->vertexCnt; i++) {
var_f30 += arg0->unk14[i];
}
for (i = 0; i < temp_r27->count; i++, var_r28++) {
temp_r29 = *var_r28;
Vertextop[temp_r29].x = ((Vec*) temp_r30->data)[i].x;
Vertextop[temp_r29].y = ((Vec*) temp_r30->data)[i].y;
Vertextop[temp_r29].z = ((Vec*) temp_r30->data)[i].z;
}
for (i = 1; i < arg0->vertexCnt; i++) {
temp_r30 = arg0->vertex[i];
var_r28 = temp_r27->vertex;
var_f31 = arg0->unk14[i];
if (var_f31 < 0.0f) {
var_f31 = 0.0f;
} else if (var_f30 > 1.0f) {
var_f31 /= var_f30;
}
for (j = 0; j < temp_r27->count; j++, var_r28++) {
temp_r29 = *var_r28;
Vertextop[temp_r29].x += var_f31 * (((Vec*) temp_r30->data)[j].x - Vertextop[temp_r29].x);
Vertextop[temp_r29].y += var_f31 * (((Vec*) temp_r30->data)[j].y - Vertextop[temp_r29].y);
Vertextop[temp_r29].z += var_f31 * (((Vec*) temp_r30->data)[j].z - Vertextop[temp_r29].z);
}
}
return;
}
temp_r24 = arg0->unk10;
var_r23 = temp_r24 + 1;
if (var_r23 >= arg0->vertexCnt) {
var_r23 = temp_r24;
}
var_f31 = arg0->unk10 - temp_r24;
temp_r30 = arg0->vertex[temp_r24];
temp_r25 = arg0->vertex[var_r23];
var_r28 = temp_r27->vertex;
for (i = 0; i < temp_r27->count; i++, var_r28++) {
temp_r29 = *var_r28;
Vertextop[temp_r29].x = ((Vec*) temp_r30->data)[i].x + var_f31 * (((Vec*) temp_r25->data)[i].x - ((Vec*) temp_r30->data)[i].x);
Vertextop[temp_r29].y = ((Vec*) temp_r30->data)[i].y + var_f31 * (((Vec*) temp_r25->data)[i].y - ((Vec*) temp_r30->data)[i].y);
Vertextop[temp_r29].z = ((Vec*) temp_r30->data)[i].z + var_f31 * (((Vec*) temp_r25->data)[i].z - ((Vec*) temp_r30->data)[i].z);
}
}
}
void ClusterProc(ModelData *arg0) {
s32 temp_r24;
s32 i;
s32 j;
s32 k;
HsfData *temp_r27;
HsfData *temp_r23;
MotionData *temp_r22;
HsfCluster *var_r29;
HsfObject *temp_r31;
for (i = 0; i < 4; i++) {
temp_r24 = arg0->unk_10[i];
if (temp_r24 != -1) {
temp_r22 = &Hu3DMotion[temp_r24];
temp_r27 = temp_r22->unk_04;
temp_r23 = arg0->hsfData;
var_r29 = temp_r27->cluster;
for (j = 0; j < temp_r27->clusterCnt; j++, var_r29++) {
if (var_r29->target != -1) {
temp_r31 = temp_r23->object;
temp_r31 += var_r29->target;
Vertextop = temp_r31->data.vertex->data;
if (temp_r31->data.hook) {
for (k = 0; k < temp_r31->data.vertex->count; k++) {
Vertextop[k].x = ((Vec*) temp_r31->data.file[0])[k].x;
Vertextop[k].y = ((Vec*) temp_r31->data.file[0])[k].y;
Vertextop[k].z = ((Vec*) temp_r31->data.file[0])[k].z;
}
}
SetClusterMain(var_r29);
DCStoreRangeNoSync(Vertextop, temp_r31->data.vertex->count * sizeof(Vec));
temp_r31->data.unk120[0]++;
}
}
}
}
}
void ClusterMotionExec(ModelData *arg0) {
float temp_f31;
s32 i;
s32 j;
s16 var_r20;
HsfCluster *temp_r26;
HsfData *temp_r28;
HsfMotion *temp_r27;
HsfTrack *var_r31;
HsfTrack *var_r30;
MotionData *var_r23;
var_r31 = temp_r27->track;
for (i = 0; i < 4; i++) {
if (arg0->unk_10[i] != -1) {
var_r20 = arg0->unk_10[i];
var_r23 = &Hu3DMotion[var_r20];
temp_r28 = var_r23->unk_04;
temp_r27 = temp_r28->motion;
var_r31 = temp_r27->track;
temp_f31 = arg0->unk_A4[i];
for (j = 0; j < temp_r27->numTracks; j++, var_r31++) {
switch (var_r31->type) {
case 5:
temp_r26 = &temp_r28->cluster[var_r31->target_s16];
temp_r26->unk10 = GetClusterCurve(var_r31, temp_f31);
break;
case 6:
var_r30 = var_r31;
temp_r26 = &temp_r28->cluster[var_r30->target_s16];
temp_r26->unk14[var_r30->unk04] = GetClusterCurve(var_r30, temp_f31);
break;
}
}
}
}
}

463
src/game/EnvelopeExec.c Normal file
View file

@ -0,0 +1,463 @@
#include "game/EnvelopeExec.h"
#include "game/hsfex.h"
#include "string.h"
static void SetEnvelopMtx(HsfObject *arg0, HsfObject *arg1, Mtx arg2);
static void SetEnvelopMain(HsfData *arg0);
static void SetEnvelop(HsfCenv *arg0);
static void SetMtx(HsfObject *arg0, Mtx arg1);
static void SetRevMtx(void);
static HsfSkeleton *SearchSklenton(char *arg0);
Vec *Vertextop;
Mtx *MtxTop;
static u32 nObj;
static u32 nMesh;
static HsfObject *objtop;
static HsfData *CurHsf;
static Vec *vtxenv;
static Vec *normenv;
static Vec *normtop;
static s32 Meshcnt;
static s32 Meshno;
void InitEnvelope(HsfData *arg0) {
HsfBuffer *spC;
HsfBuffer *sp8;
HsfMatrix *temp_r28;
HsfObject *var_r31;
HsfSkeleton *var_r30;
Mtx sp10;
s32 i;
s32 j;
if (arg0->cenvCnt != 0) {
var_r31 = arg0->object;
for (Meshcnt = i = 0; i < arg0->objectCnt; i++, var_r31++) {
if (var_r31->type == 2) {
if (var_r31->data.file[0]) {
spC = var_r31->data.vertex;
sp8 = var_r31->data.normal;
Meshcnt++;
} else {
continue;
}
}
var_r30 = arg0->skeleton;
for (j = 0; j < arg0->skeletonCnt; j++, var_r30++) {
if (strcmp(var_r31->name, var_r30->name) == 0) {
var_r31->data.base.pos.x = var_r30->transform.pos.x;
var_r31->data.base.pos.y = var_r30->transform.pos.y;
var_r31->data.base.pos.z = var_r30->transform.pos.z;
var_r31->data.base.rot.x = var_r30->transform.rot.x;
var_r31->data.base.rot.y = var_r30->transform.rot.y;
var_r31->data.base.rot.z = var_r30->transform.rot.z;
var_r31->data.base.scale.x = var_r30->transform.scale.x;
var_r31->data.base.scale.y = var_r30->transform.scale.y;
var_r31->data.base.scale.z = var_r30->transform.scale.z;
}
}
var_r31->data.curr.pos.x = var_r31->data.base.pos.x;
var_r31->data.curr.pos.y = var_r31->data.base.pos.y;
var_r31->data.curr.pos.z = var_r31->data.base.pos.z;
var_r31->data.curr.rot.x = var_r31->data.base.rot.x;
var_r31->data.curr.rot.y = var_r31->data.base.rot.y;
var_r31->data.curr.rot.z = var_r31->data.base.rot.z;
var_r31->data.curr.scale.x = var_r31->data.base.scale.x;
var_r31->data.curr.scale.y = var_r31->data.base.scale.y;
var_r31->data.curr.scale.z = var_r31->data.base.scale.z;
}
CurHsf = arg0;
objtop = arg0->object;
temp_r28 = CurHsf->matrix;
if (temp_r28) {
MtxTop = temp_r28->data;
nObj = temp_r28->count;
nMesh = temp_r28->base_idx;
}
PSMTXIdentity(sp10);
SetMtx(arg0->root, sp10);
SetRevMtx();
}
}
static void SetEnvelopMtx(HsfObject *arg0, HsfObject *arg1, Mtx arg2) {
Mtx sp6C;
Mtx sp3C;
Mtx spC;
s32 var_r29;
s32 i;
PSMTXTrans(spC, arg1->data.curr.pos.x, arg1->data.curr.pos.y, arg1->data.curr.pos.z);
PSMTXConcat(arg2, spC, sp3C);
if (arg1->data.curr.rot.z) {
PSMTXRotRad(sp6C, 'z', MTXDegToRad(arg1->data.curr.rot.z));
PSMTXConcat(sp3C, sp6C, sp3C);
}
if (arg1->data.curr.rot.y) {
PSMTXRotRad(sp6C, 'y', MTXDegToRad(arg1->data.curr.rot.y));
PSMTXConcat(sp3C, sp6C, sp3C);
}
if (arg1->data.curr.rot.x) {
PSMTXRotRad(sp6C, 'x', MTXDegToRad(arg1->data.curr.rot.x));
PSMTXConcat(sp3C, sp6C, sp3C);
}
if (arg1->data.curr.scale.x != 1.0f) {
sp3C[0][0] *= arg1->data.curr.scale.x;
sp3C[1][0] *= arg1->data.curr.scale.x;
sp3C[2][0] *= arg1->data.curr.scale.x;
}
if (arg1->data.curr.scale.y != 1.0f) {
sp3C[0][1] *= arg1->data.curr.scale.y;
sp3C[1][1] *= arg1->data.curr.scale.y;
sp3C[2][1] *= arg1->data.curr.scale.y;
}
if (arg1->data.curr.scale.z != 1.0f) {
sp3C[0][2] *= arg1->data.curr.scale.z;
sp3C[1][2] *= arg1->data.curr.scale.z;
sp3C[2][2] *= arg1->data.curr.scale.z;
}
var_r29 = arg1 - arg0;
PSMTXCopy(sp3C, MtxTop[nMesh + var_r29]);
for (i = 0; i < arg1->data.childrenCount; i++) {
SetEnvelopMtx(arg0, arg1->data.children[i], sp3C);
}
}
void EnvelopeProc(HsfData *arg0) {
HsfMatrix *temp_r31;
HsfObject *temp_r29;
Mtx sp8;
CurHsf = arg0;
temp_r31 = CurHsf->matrix;
MtxTop = temp_r31->data;
nObj = temp_r31->count;
nMesh = temp_r31->base_idx;
temp_r29 = arg0->root;
PSMTXIdentity(sp8);
SetEnvelopMtx(arg0->object, temp_r29, sp8);
SetEnvelopMain(arg0);
}
void InitVtxParm(HsfData *arg0) {
HsfObject *var_r31;
s32 i;
var_r31 = arg0->object;
for (i = 0; i < arg0->objectCnt; i++, var_r31++) {
if (var_r31->type == 2) {
var_r31->data.unk120[0] = 0;
}
}
}
static void SetEnvelopMain(HsfData *arg0) {
void *sp10;
void *spC;
void *sp8;
HsfBuffer *temp_r28;
HsfBuffer *temp_r30;
HsfObject *var_r31;
s32 i;
s32 j;
HsfCenv *var_r25;
var_r31 = arg0->object;
for (Meshno = i = 0; i < arg0->objectCnt; i++, var_r31++) {
if (var_r31->type == 2) {
PSMTXInverse(MtxTop[&var_r31[nMesh] - arg0->object], MtxTop[Meshno]);
temp_r30 = var_r31->data.vertex;
temp_r28 = var_r31->data.normal;
if (var_r31->data.unk120[0] != 0) {
Vertextop = temp_r30->data;
} else {
Vertextop = var_r31->data.file[0];
}
vtxenv = temp_r30->data;
normtop = var_r31->data.file[1];
normenv = temp_r28->data;
var_r25 = var_r31->data.cenv;
for (j = 0; j < var_r31->data.hook; j++, var_r25++) {
SetEnvelop(var_r25);
}
sp10 = temp_r30->data;
spC = var_r31->data.file[0];
sp8 = temp_r30->data;
DCStoreRangeNoSync(normenv, temp_r28->count * sizeof(Vec));
DCStoreRangeNoSync(vtxenv, temp_r30->count * sizeof(Vec));
Meshno++;
}
}
}
static void SetEnvelop(HsfCenv *arg0) {
Vec sp44;
Vec sp38;
Vec sp2C;
Vec sp20;
Vec sp14;
s32 sp10;
u32 spC;
u32 sp8;
HsfCenvDual *var_r20;
HsfCenvDualWeight *var_r30;
HsfCenvMulti *var_r19;
HsfCenvMultiWeight *var_r25;
HsfCenvSingle *var_r27;
Vec *temp_r22;
Vec *temp_r26;
Vec *temp_r28;
Vec *temp_r31;
float temp_f31;
MtxPtr var_r29;
s32 temp_r18;
s32 temp_r21;
s32 i;
s32 j;
Mtx sp1A0;
Mtx sp170;
Mtx sp140;
Mtx sp110;
Mtx spE0;
Mtx spB0;
Mtx sp80;
Mtx sp50;
var_r27 = arg0->singleData;
for (i = 0; i < arg0->singleCount; i++, var_r27++) {
temp_r18 = var_r27->normal;
temp_r21 = var_r27->pos;
temp_r28 = &vtxenv[temp_r21];
temp_r31 = &Vertextop[temp_r21];
temp_r22 = &normenv[temp_r18];
temp_r26 = &normtop[temp_r18];
PSMTXConcat(MtxTop[nMesh + var_r27->target], MtxTop[nMesh + nObj + nObj * Meshno + var_r27->target], sp140);
PSMTXConcat(MtxTop[Meshno], sp140, sp1A0);
Hu3DMtxScaleGet(&sp1A0[0], &sp14);
if (sp14.x != 1.0f || sp14.y != 1.0f || sp14.z != 1.0f) {
PSMTXScale(spE0, 1.0 / sp14.x, 1.0 / sp14.y, 1.0 / sp14.z);
PSMTXConcat(spE0, sp1A0, sp170);
PSMTXInvXpose(sp170, sp170);
} else {
PSMTXInvXpose(sp1A0, sp170);
}
if (var_r27->posCnt == 1) {
PSMTXMultVec(sp1A0, temp_r31, temp_r28);
PSMTXMultVec(sp170, temp_r26, temp_r22);
} else if (var_r27->posCnt <= 6) {
PSMTXMultVecArray(sp1A0, temp_r31, temp_r28, var_r27->posCnt);
PSMTXMultVecArray(sp170, temp_r26, temp_r22, var_r27->normalCnt);
} else {
PSMTXReorder(sp1A0, (ROMtxPtr) sp140);
PSMTXReorder(sp170, (ROMtxPtr) sp110);
PSMTXROMultVecArray((ROMtxPtr) sp140, temp_r31, temp_r28, var_r27->posCnt);
PSMTXROMultVecArray((ROMtxPtr) sp110, temp_r26, temp_r22, var_r27->normalCnt);
}
}
var_r20 = arg0->dualData;
for (i = 0; i < arg0->dualCount; i++, var_r20++) {
spC = var_r20->target1;
sp8 = var_r20->target2;
PSMTXConcat(MtxTop[nMesh + spC], MtxTop[nMesh + nObj + nObj * Meshno + spC], sp140);
PSMTXConcat(MtxTop[Meshno], sp140, sp1A0);
PSMTXConcat(MtxTop[nMesh + sp8], MtxTop[nMesh + nObj + nObj * Meshno + sp8], sp140);
PSMTXConcat(MtxTop[Meshno], sp140, (float (*)[4]) &spB0[0]);
var_r30 = var_r20->weight;
for (j = 0; j < var_r20->weightCnt; j++, var_r30++) {
temp_r18 = var_r30->normal;
temp_r21 = var_r30->pos;
temp_r28 = &vtxenv[temp_r21];
temp_r31 = &Vertextop[temp_r21];
temp_r22 = &normenv[temp_r18];
temp_r26 = &normtop[temp_r18];
temp_f31 = var_r30->weight;
sp140[0][0] = sp1A0[0][0] * temp_f31;
sp140[1][0] = sp1A0[1][0] * temp_f31;
sp140[2][0] = sp1A0[2][0] * temp_f31;
sp140[0][1] = sp1A0[0][1] * temp_f31;
sp140[1][1] = sp1A0[1][1] * temp_f31;
sp140[2][1] = sp1A0[2][1] * temp_f31;
sp140[0][2] = sp1A0[0][2] * temp_f31;
sp140[1][2] = sp1A0[1][2] * temp_f31;
sp140[2][2] = sp1A0[2][2] * temp_f31;
sp140[0][3] = sp1A0[0][3] * temp_f31;
sp140[1][3] = sp1A0[1][3] * temp_f31;
sp140[2][3] = sp1A0[2][3] * temp_f31;
temp_f31 = 1.0f - var_r30->weight;
sp110[0][0] = spB0[0][0] * temp_f31;
sp110[1][0] = spB0[1][0] * temp_f31;
sp110[2][0] = spB0[2][0] * temp_f31;
sp110[0][1] = spB0[0][1] * temp_f31;
sp110[1][1] = spB0[1][1] * temp_f31;
sp110[2][1] = spB0[2][1] * temp_f31;
sp110[0][2] = spB0[0][2] * temp_f31;
sp110[1][2] = spB0[1][2] * temp_f31;
sp110[2][2] = spB0[2][2] * temp_f31;
sp110[0][3] = spB0[0][3] * temp_f31;
sp110[1][3] = spB0[1][3] * temp_f31;
sp110[2][3] = spB0[2][3] * temp_f31;
if (sp80 == sp110 || sp80 == sp140) {
var_r29 = sp50;
} else {
var_r29 = sp80;
}
var_r29[0][0] = sp110[0][0] + sp140[0][0];
var_r29[0][1] = sp110[0][1] + sp140[0][1];
var_r29[0][2] = sp110[0][2] + sp140[0][2];
var_r29[0][3] = sp110[0][3] + sp140[0][3];
var_r29[1][0] = sp110[1][0] + sp140[1][0];
var_r29[1][1] = sp110[1][1] + sp140[1][1];
var_r29[1][2] = sp110[1][2] + sp140[1][2];
var_r29[1][3] = sp110[1][3] + sp140[1][3];
var_r29[2][0] = sp110[2][0] + sp140[2][0];
var_r29[2][1] = sp110[2][1] + sp140[2][1];
var_r29[2][2] = sp110[2][2] + sp140[2][2];
var_r29[2][3] = sp110[2][3] + sp140[2][3];
if (var_r29 == sp50) {
PSMTXCopy(sp50, sp80);
}
Hu3DMtxScaleGet(&sp80[0], &sp14);
if (sp14.x != 1.0f || sp14.y != 1.0f || sp14.z != 1.0f) {
PSMTXScale(spE0, 1.0 / sp14.x, 1.0 / sp14.y, 1.0 / sp14.z);
PSMTXConcat(spE0, sp80, sp110);
PSMTXInvXpose(sp110, sp110);
} else {
PSMTXInvXpose(sp80, sp110);
}
if (var_r30->posCnt == 1) {
PSMTXMultVec(sp80, temp_r31, temp_r28);
} else if (var_r30->posCnt <= 6) {
PSMTXMultVecArray(sp80, temp_r31, temp_r28, var_r30->posCnt);
} else {
PSMTXReorder(sp80, (ROMtxPtr) sp140);
PSMTXROMultVecArray((ROMtxPtr) sp140, temp_r31, temp_r28, var_r30->posCnt);
}
if (var_r30->normalCnt != 0) {
if (var_r30->normalCnt == 1) {
PSMTXMultVec(sp110, temp_r26, temp_r22);
} else if (var_r30->normalCnt <= 6) {
PSMTXMultVecArray(sp110, temp_r26, temp_r22, var_r30->normalCnt);
} else {
PSMTXReorder(sp110, (ROMtxPtr) sp140);
PSMTXROMultVecArray((ROMtxPtr) sp140, temp_r26, temp_r22, var_r30->normalCnt);
}
}
}
}
var_r19 = arg0->multiData;
for (i = 0; i < arg0->multiCount; i++, var_r19++) {
var_r25 = var_r19->weight;
temp_r18 = var_r19->normal;
temp_r21 = var_r19->pos;
temp_r28 = &vtxenv[temp_r21];
temp_r31 = &Vertextop[temp_r21];
temp_r22 = &normenv[temp_r18];
temp_r26 = &normtop[temp_r18];
sp38.x = sp38.y = sp38.z = 0.0f;
sp20.x = sp20.y = sp20.z = 0.0f;
sp10 = 0;
for (j = 0; j < var_r19->weightCnt; j++, var_r25++) {
PSMTXConcat(MtxTop[nMesh + var_r25->target], MtxTop[nMesh + nObj + nObj * Meshno + var_r25->target], sp1A0);
PSMTXConcat(MtxTop[Meshno], sp1A0, sp1A0);
PSMTXInvXpose(sp1A0, sp170);
PSMTXMultVec(sp1A0, temp_r31, &sp44);
PSMTXMultVec(sp170, temp_r26, &sp2C);
sp44.x = var_r25->value * (sp44.x - temp_r31->x);
sp44.y = var_r25->value * (sp44.y - temp_r31->y);
sp44.z = var_r25->value * (sp44.z - temp_r31->z);
PSVECAdd(&sp38, &sp44, &sp38);
sp2C.x = var_r25->value * (sp2C.x - temp_r26->x);
sp2C.y = var_r25->value * (sp2C.y - temp_r26->y);
sp2C.z = var_r25->value * (sp2C.z - temp_r26->z);
PSVECAdd(&sp20, &sp2C, &sp20);
}
temp_r28->x = temp_r31->x + sp38.x;
temp_r28->y = temp_r31->y + sp38.y;
temp_r28->z = temp_r31->z + sp38.z;
temp_r22->x = temp_r26->x + sp20.x;
temp_r22->y = temp_r26->y + sp20.y;
temp_r22->z = temp_r26->z + sp20.z;
}
temp_r21 = arg0->vtxCount;
temp_r28 = &vtxenv[temp_r21];
temp_r31 = &Vertextop[temp_r21];
for (i = 0; i < arg0->copyCount; i++, temp_r28++, temp_r31++) {
temp_r28->x = temp_r31->x;
temp_r28->y = temp_r31->y;
temp_r28->z = temp_r31->z;
}
}
static void SetMtx(HsfObject *arg0, Mtx arg1) {
HsfSkeleton *temp_r3;
Mtx spFC;
Mtx spCC;
Mtx sp9C;
s32 temp_r25;
s32 i;
temp_r3 = SearchSklenton(arg0->name);
if (temp_r3) {
arg0->data.base.pos.x = temp_r3->transform.pos.x;
arg0->data.base.pos.y = temp_r3->transform.pos.y;
arg0->data.base.pos.z = temp_r3->transform.pos.z;
arg0->data.base.rot.x = temp_r3->transform.rot.x;
arg0->data.base.rot.y = temp_r3->transform.rot.y;
arg0->data.base.rot.z = temp_r3->transform.rot.z;
arg0->data.base.scale.x = temp_r3->transform.scale.x;
arg0->data.base.scale.y = temp_r3->transform.scale.y;
arg0->data.base.scale.z = temp_r3->transform.scale.z;
}
PSMTXTrans(spFC, arg0->data.base.pos.x, arg0->data.base.pos.y, arg0->data.base.pos.z);
PSMTXScale(spCC, arg0->data.base.scale.x, arg0->data.base.scale.y, arg0->data.base.scale.z);
PSMTXConcat(arg1, spFC, spFC);
PSMTXRotRad(sp9C, 'z', MTXDegToRad(arg0->data.base.rot.z));
PSMTXConcat(spFC, sp9C, spFC);
PSMTXRotRad(sp9C, 'y', MTXDegToRad(arg0->data.base.rot.y));
PSMTXConcat(spFC, sp9C, spFC);
PSMTXRotRad(sp9C, 'x', MTXDegToRad(arg0->data.base.rot.x));
PSMTXConcat(spFC, sp9C, spFC);
PSMTXConcat(spFC, spCC, spFC);
temp_r25 = arg0 - objtop;
PSMTXCopy(spFC, MtxTop[nMesh + temp_r25]);
for (i = 0; i < arg0->data.childrenCount; i++) {
SetMtx(arg0->data.children[i], spFC);
}
}
static void SetRevMtx(void) {
HsfObject *var_r29;
s32 var_r28;
s32 i;
s32 var_r30;
Mtx sp38;
Mtx sp8;
var_r29 = CurHsf->object;
for (var_r28 = i = 0; i < CurHsf->objectCnt; i++, var_r29++) {
if (var_r29->type == 2) {
PSMTXCopy(MtxTop[nMesh + i], sp8);
for (var_r30 = 0; var_r30 < CurHsf->objectCnt; var_r30++) {
PSMTXInverse(MtxTop[nMesh + var_r30], sp38);
PSMTXConcat(sp38, sp8, MtxTop[nMesh + nObj + nObj * var_r28 + var_r30]);
}
PSMTXInverse(MtxTop[nMesh + i], sp8);
var_r28++;
}
}
}
static HsfSkeleton *SearchSklenton(char *arg0) {
HsfSkeleton *var_r31;
s32 i;
var_r31 = CurHsf->skeleton;
for (i = 0; i < CurHsf->skeletonCnt; i++, var_r31++) {
if (strcmp(arg0, var_r31->name) == 0) {
return var_r31;
}
}
return NULL;
}

View file

@ -530,18 +530,18 @@ s16 Hu3DParticleCreate(AnimData *arg0, s16 arg1) {
GXBeginDisplayList(temp_r24, 0x20000); GXBeginDisplayList(temp_r24, 0x20000);
GXBegin(GX_QUADS, GX_VTXFMT0, arg1 * 4); GXBegin(GX_QUADS, GX_VTXFMT0, arg1 * 4);
for (i = 0; i < arg1; i++) { for (i = 0; i < arg1; i++) {
GXPosition1x16(i*4); GXPosition1x16(i*4);
GXColor1x16(i); GXColor1x16(i);
GXTexCoord1x16(0); GXTexCoord1x16(0);
GXPosition1x16((i*4)+1); GXPosition1x16((i*4)+1);
GXColor1x16(i); GXColor1x16(i);
GXTexCoord1x16(1); GXTexCoord1x16(1);
GXPosition1x16((i*4)+2); GXPosition1x16((i*4)+2);
GXColor1x16(i); GXColor1x16(i);
GXTexCoord1x16(2); GXTexCoord1x16(2);
GXPosition1x16((i*4)+3); GXPosition1x16((i*4)+3);
GXColor1x16(i); GXColor1x16(i);
GXTexCoord1x16(3); GXTexCoord1x16(3);
} }
temp_r31->unk_40 = GXEndDisplayList(); temp_r31->unk_40 = GXEndDisplayList();
return temp_r25; return temp_r25;

View file

@ -519,9 +519,9 @@ void Hu3DMtxRotGet(Mtx arg0, Vec *arg1) {
arg1->x = GetAngleXY(arg0[0][1], arg0[1][1]); arg1->x = GetAngleXY(arg0[0][1], arg0[1][1]);
arg1->z = 0.0f; arg1->z = 0.0f;
} }
arg1->x = arg1->x * 57.29578f; arg1->x = MTXRadToDeg(arg1->x);
arg1->y = arg1->y * 57.29578f; arg1->y = MTXRadToDeg(arg1->y);
arg1->z = arg1->z * 57.29578f; arg1->z = MTXRadToDeg(arg1->z);
return; return;
} }
} }

View file

@ -1,5 +1,7 @@
#include "game/hsfman.h" #include "game/hsfman.h"
#include "game/ClusterExec.h"
#include "game/data.h" #include "game/data.h"
#include "game/EnvelopeExec.h"
#include "game/hsfdraw.h" #include "game/hsfdraw.h"
#include "game/hsfload.h" #include "game/hsfload.h"
#include "game/hsfmotion.h" #include "game/hsfmotion.h"

View file

@ -1,4 +1,6 @@
#include "game/hsfmotion.h" #include "game/hsfmotion.h"
#include "game/ClusterExec.h"
#include "game/EnvelopeExec.h"
#include "game/hsfdraw.h" #include "game/hsfdraw.h"
#include "game/hsfload.h" #include "game/hsfload.h"
#include "game/hsfman.h" #include "game/hsfman.h"
@ -7,12 +9,9 @@
#include "math.h" #include "math.h"
#include "string.h" #include "string.h"
float GetClusterCurve(HsfTrack*, float); static s32 SearchObjectIndex(HsfData *arg0, u32 arg1);
float GetClusterWeightCurve(HsfTrack*, float); static s32 SearchAttributeIndex(HsfData *arg0, u32 arg1);
void ClusterMotionExec(ModelData*);
void ClusterProc(ModelData*);
void EnvelopeProc(HsfData*);
void InitVtxParm(HsfData*);
void ShapeProc(HsfData*); void ShapeProc(HsfData*);
MotionData Hu3DMotion[256]; MotionData Hu3DMotion[256];