mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-08 00:44:42 +00:00
Fix matrices documentation (#952)
* Update names and doc of `Matrix_RotateRPY` and `SkinMatrix_SetRotateRPY` to ZYX Tait-Bryan angles * Update name and doc of `Matrix_JointPosition` to `Matrix_TranslateRotateZYX` * `Euler ***` -> `Tait-Bryan *** angles` * Update docs of `SkinMatrix_Vec3fMtxFMultXYZW` and `SkinMatrix_Vec3fMtxFMultXYZ` * Fix doc of `SkinMatrix_MtxFMtxFMult` * Update docs of `SkinMatrix_Invert` * Change name and docs of `SkinMatrix_SetRotateYRP` to `SkinMatrix_SetRotateYXZ` * Change name and docs of `SkinMatrix_SetScaleRotateRPYTranslate` to `SkinMatrix_SetScaleRotateZYXTranslate` * Change name and docs of `SkinMatrix_SetScaleRotateYRPTranslate` to `SkinMatrix_SetScaleRotateYXZTranslate` * Change name and docs of `SkinMatrix_SetRotateRPYTranslate` to `SkinMatrix_SetRotateZYXTranslate` * Add renamed functions to `namefixer.py` * Run formatter * Consistent function names (`ABC()` if equivalent to `A() B() C()`)
This commit is contained in:
parent
9ca6bfdac3
commit
03636166b3
53 changed files with 373 additions and 357 deletions
|
@ -9,14 +9,14 @@ void func_800430A0(CollisionContext* colCtx, s32 bgId, Actor* actor) {
|
|||
Vec3f tempPos;
|
||||
|
||||
if (DynaPoly_IsBgIdBgActor(bgId)) {
|
||||
SkinMatrix_SetScaleRotateYRPTranslate(
|
||||
SkinMatrix_SetTranslateRotateYXZScale(
|
||||
&prevTransform, colCtx->dyna.bgActors[bgId].prevTransform.scale.x,
|
||||
colCtx->dyna.bgActors[bgId].prevTransform.scale.y, colCtx->dyna.bgActors[bgId].prevTransform.scale.z,
|
||||
colCtx->dyna.bgActors[bgId].prevTransform.rot.x, colCtx->dyna.bgActors[bgId].prevTransform.rot.y,
|
||||
colCtx->dyna.bgActors[bgId].prevTransform.rot.z, colCtx->dyna.bgActors[bgId].prevTransform.pos.x,
|
||||
colCtx->dyna.bgActors[bgId].prevTransform.pos.y, colCtx->dyna.bgActors[bgId].prevTransform.pos.z);
|
||||
if (SkinMatrix_Invert(&prevTransform, &prevTransformInv) != 2) {
|
||||
SkinMatrix_SetScaleRotateYRPTranslate(
|
||||
SkinMatrix_SetTranslateRotateYXZScale(
|
||||
&curTransform, colCtx->dyna.bgActors[bgId].curTransform.scale.x,
|
||||
colCtx->dyna.bgActors[bgId].curTransform.scale.y, colCtx->dyna.bgActors[bgId].curTransform.scale.z,
|
||||
colCtx->dyna.bgActors[bgId].curTransform.rot.x, colCtx->dyna.bgActors[bgId].curTransform.rot.y,
|
||||
|
|
|
@ -293,12 +293,12 @@ void Matrix_RotateZ(f32 z, u8 mode) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Rotates the top of the matrix stack by `z` degrees, then
|
||||
* rotates that matrix by `y` degrees, then rotates that matrix
|
||||
* by `x` degrees. (roll-pitch-yaw)
|
||||
* Rotate using ZYX Tait-Bryan angles.
|
||||
* This means a (column) vector is first rotated around X, then around Y, then around Z, then (if `mode` is
|
||||
* `MTXMODE_APPLY`) gets transformed according to whatever the matrix was before adding the ZYX rotation.
|
||||
* Original Name: Matrix_RotateXYZ, changed to reflect rotation order.
|
||||
*/
|
||||
void Matrix_RotateRPY(s16 x, s16 y, s16 z, u8 mode) {
|
||||
void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode) {
|
||||
MtxF* cmf = sCurrentMatrix;
|
||||
f32 temp1;
|
||||
f32 temp2;
|
||||
|
@ -379,14 +379,16 @@ void Matrix_RotateRPY(s16 x, s16 y, s16 z, u8 mode) {
|
|||
cmf->wz = temp2 * cos - temp1 * sin;
|
||||
}
|
||||
} else {
|
||||
SkinMatrix_SetRotateRPY(cmf, x, y, z);
|
||||
SkinMatrix_SetRotateZYX(cmf, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll-pitch-yaw rotation and position
|
||||
* Translate and rotate using ZYX Tait-Bryan angles.
|
||||
* This means a (column) vector is first rotated around X, then around Y, then around Z, then translated, then gets
|
||||
* transformed according to whatever the matrix was previously.
|
||||
*/
|
||||
void Matrix_JointPosition(Vec3f* position, Vec3s* rotation) {
|
||||
void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation) {
|
||||
MtxF* cmf = sCurrentMatrix;
|
||||
f32 sin = Math_SinS(rotation->z);
|
||||
f32 cos = Math_CosS(rotation->z);
|
||||
|
@ -395,25 +397,25 @@ void Matrix_JointPosition(Vec3f* position, Vec3s* rotation) {
|
|||
|
||||
temp1 = cmf->xx;
|
||||
temp2 = cmf->xy;
|
||||
cmf->xw += temp1 * position->x + temp2 * position->y + cmf->xz * position->z;
|
||||
cmf->xw += temp1 * translation->x + temp2 * translation->y + cmf->xz * translation->z;
|
||||
cmf->xx = temp1 * cos + temp2 * sin;
|
||||
cmf->xy = temp2 * cos - temp1 * sin;
|
||||
|
||||
temp1 = cmf->yx;
|
||||
temp2 = cmf->yy;
|
||||
cmf->yw += temp1 * position->x + temp2 * position->y + cmf->yz * position->z;
|
||||
cmf->yw += temp1 * translation->x + temp2 * translation->y + cmf->yz * translation->z;
|
||||
cmf->yx = temp1 * cos + temp2 * sin;
|
||||
cmf->yy = temp2 * cos - temp1 * sin;
|
||||
|
||||
temp1 = cmf->zx;
|
||||
temp2 = cmf->zy;
|
||||
cmf->zw += temp1 * position->x + temp2 * position->y + cmf->zz * position->z;
|
||||
cmf->zw += temp1 * translation->x + temp2 * translation->y + cmf->zz * translation->z;
|
||||
cmf->zx = temp1 * cos + temp2 * sin;
|
||||
cmf->zy = temp2 * cos - temp1 * sin;
|
||||
|
||||
temp1 = cmf->wx;
|
||||
temp2 = cmf->wy;
|
||||
cmf->ww += temp1 * position->x + temp2 * position->y + cmf->wz * position->z;
|
||||
cmf->ww += temp1 * translation->x + temp2 * translation->y + cmf->wz * translation->z;
|
||||
cmf->wx = temp1 * cos + temp2 * sin;
|
||||
cmf->wy = temp2 * cos - temp1 * sin;
|
||||
|
||||
|
@ -740,7 +742,7 @@ void func_800D1FD4(MtxF* mf) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the rotation the specified matrix represents, using Euler YXZ.
|
||||
* Gets the rotation the specified matrix represents, using Tait-Bryan YXZ angles.
|
||||
* The flag value doesn't matter for a rotation matrix. Not 0 does extra calculation.
|
||||
*/
|
||||
void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag) {
|
||||
|
@ -793,7 +795,7 @@ void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the rotation the specified matrix represents, using Euler ZYX.
|
||||
* Gets the rotation the specified matrix represents, using Tait-Bryan ZYX angles.
|
||||
* The flag value doesn't matter for a rotation matrix. Not 0 does extra calculation.
|
||||
*/
|
||||
void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag) {
|
||||
|
|
|
@ -2810,7 +2810,7 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3
|
|||
*polyStartIndex += pbgdata->numPolygons;
|
||||
*vtxStartIndex += pbgdata->numVertices;
|
||||
} else {
|
||||
SkinMatrix_SetScaleRotateYRPTranslate(
|
||||
SkinMatrix_SetTranslateRotateYXZScale(
|
||||
&mtx, dyna->bgActors[bgId].curTransform.scale.x, dyna->bgActors[bgId].curTransform.scale.y,
|
||||
dyna->bgActors[bgId].curTransform.scale.z, dyna->bgActors[bgId].curTransform.rot.x,
|
||||
dyna->bgActors[bgId].curTransform.rot.y, dyna->bgActors[bgId].curTransform.rot.z,
|
||||
|
@ -3136,7 +3136,7 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
|
|||
polyIndex = *dynaRaycast->resultPoly - polyMin;
|
||||
poly = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].colHeader->polyList[polyIndex];
|
||||
|
||||
SkinMatrix_SetScaleRotateYRPTranslate(&srpMtx, curTransform->scale.x, curTransform->scale.y,
|
||||
SkinMatrix_SetTranslateRotateYXZScale(&srpMtx, curTransform->scale.x, curTransform->scale.y,
|
||||
curTransform->scale.z, curTransform->rot.x, curTransform->rot.y,
|
||||
curTransform->rot.z, curTransform->pos.x, curTransform->pos.y,
|
||||
curTransform->pos.z);
|
||||
|
|
|
@ -76,7 +76,7 @@ void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalCo
|
|||
Matrix_Translate(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW);
|
||||
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);
|
||||
Matrix_Mult(&globalCtx->mf_11DA0, MTXMODE_APPLY);
|
||||
Matrix_RotateRPY(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY);
|
||||
Matrix_RotateZYX(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY);
|
||||
|
||||
gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP,
|
||||
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
||||
|
|
|
@ -192,9 +192,9 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) {
|
|||
}
|
||||
|
||||
SkinMatrix_SetTranslate(&spC4, this->position.x, this->position.y, this->position.z);
|
||||
SkinMatrix_SetRotateRPY(&sp104, 0, elem->yaw, 0);
|
||||
SkinMatrix_SetRotateZYX(&sp104, 0, elem->yaw, 0);
|
||||
SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84);
|
||||
SkinMatrix_SetRotateRPY(&sp104, 0, 0, elem->pitch);
|
||||
SkinMatrix_SetRotateZYX(&sp104, 0, 0, elem->pitch);
|
||||
SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4);
|
||||
SkinMatrix_SetTranslate(&sp104, temp1, 0.0f, 0.0f);
|
||||
SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84);
|
||||
|
|
|
@ -120,7 +120,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve*
|
|||
pos.y = transform->y;
|
||||
pos.z = transform->z;
|
||||
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY);
|
||||
|
||||
if (lod == 0) {
|
||||
|
|
|
@ -758,9 +758,9 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime,
|
|||
sp74 = D_80126068[(void)0, gSaveContext.linkAge] - this->unk_6C4;
|
||||
|
||||
Matrix_Push();
|
||||
Matrix_JointPosition(pos, rot);
|
||||
Matrix_TranslateRotateZYX(pos, rot);
|
||||
Matrix_MultVec3f(&D_8012602C, &spA4);
|
||||
Matrix_JointPosition(&D_80126038[(void)0, gSaveContext.linkAge], &skelAnime->jointTable[shinLimbIndex]);
|
||||
Matrix_TranslateRotateZYX(&D_80126038[(void)0, gSaveContext.linkAge], &skelAnime->jointTable[shinLimbIndex]);
|
||||
Matrix_Translate(D_80126050[(void)0, gSaveContext.linkAge], 0.0f, 0.0f, MTXMODE_APPLY);
|
||||
Matrix_MultVec3f(&D_8012602C, &sp98);
|
||||
Matrix_MultVec3f(&D_80126070, &footprintPos);
|
||||
|
@ -842,7 +842,7 @@ s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
|
|||
if (this->unk_6C2 != 0) {
|
||||
Matrix_Translate(pos->x, ((Math_CosS(this->unk_6C2) - 1.0f) * 200.0f) + pos->y, pos->z, MTXMODE_APPLY);
|
||||
Matrix_RotateX(this->unk_6C2 * (M_PI / 0x8000), MTXMODE_APPLY);
|
||||
Matrix_RotateRPY(rot->x, rot->y, rot->z, MTXMODE_APPLY);
|
||||
Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY);
|
||||
pos->x = pos->y = pos->z = 0.0f;
|
||||
rot->x = rot->y = rot->z = 0;
|
||||
}
|
||||
|
@ -1062,7 +1062,7 @@ void Player_DrawGetItemImpl(GlobalContext* globalCtx, Player* this, Vec3f* refPo
|
|||
|
||||
Matrix_Translate(refPos->x + (3.3f * Math_SinS(this->actor.shape.rot.y)), refPos->y + height,
|
||||
refPos->z + ((3.3f + (IREG(90) / 10.0f)) * Math_CosS(this->actor.shape.rot.y)), MTXMODE_NEW);
|
||||
Matrix_RotateRPY(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY);
|
||||
Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY);
|
||||
Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY);
|
||||
|
||||
GetItem_Draw(globalCtx, drawIdPlusOne - 1);
|
||||
|
@ -1207,7 +1207,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s*
|
|||
}
|
||||
|
||||
Matrix_Translate(-428.26f, 267.2f, -33.82f, MTXMODE_APPLY);
|
||||
Matrix_RotateRPY(-0x8000, 0, 0x4000, MTXMODE_APPLY);
|
||||
Matrix_RotateZYX(-0x8000, 0, 0x4000, MTXMODE_APPLY);
|
||||
Matrix_Scale(1.0f, this->unk_85C, 1.0f, MTXMODE_APPLY);
|
||||
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player_lib.c", 2653),
|
||||
|
@ -1243,7 +1243,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s*
|
|||
if (!Player_HoldsHookshot(this) && ((hookedActor = this->heldActor) != NULL)) {
|
||||
if (this->stateFlags1 & 0x200) {
|
||||
Matrix_MultVec3f(&D_80126128, &hookedActor->world.pos);
|
||||
Matrix_RotateRPY(0x69E8, -0x5708, 0x458E, MTXMODE_APPLY);
|
||||
Matrix_RotateZYX(0x69E8, -0x5708, 0x458E, MTXMODE_APPLY);
|
||||
Matrix_Get(&sp14C);
|
||||
Matrix_MtxFToYXZRotS(&sp14C, &hookedActor->world.rot, 0);
|
||||
hookedActor->shape.rot = hookedActor->world.rot;
|
||||
|
@ -1325,7 +1325,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s*
|
|||
s32 pad;
|
||||
|
||||
Matrix_MultVec3f(&D_80126190, &heldActor->world.pos);
|
||||
Matrix_RotateRPY(0, -0x4000, -0x4000, MTXMODE_APPLY);
|
||||
Matrix_RotateZYX(0, -0x4000, -0x4000, MTXMODE_APPLY);
|
||||
Matrix_Get(&sp44);
|
||||
Matrix_MtxFToYXZRotS(&sp44, &heldActor->world.rot, 0);
|
||||
heldActor->shape.rot = heldActor->world.rot;
|
||||
|
@ -1359,7 +1359,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s*
|
|||
func_80090604(globalCtx, this, &this->shieldQuad, D_8012619C);
|
||||
}
|
||||
|
||||
Matrix_JointPosition(&D_801261CC, &D_801261D8);
|
||||
Matrix_TranslateRotateZYX(&D_801261CC, &D_801261D8);
|
||||
Matrix_Get(&this->shieldMf);
|
||||
}
|
||||
} else if (limbIndex == PLAYER_LIMB_HEAD) {
|
||||
|
|
|
@ -39,7 +39,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele
|
|||
dList = limb->dLists[lod];
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, arg)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (dList != NULL) {
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 805), G_MTX_LOAD);
|
||||
gSPDisplayList(POLY_OPA_DISP++, dList);
|
||||
|
@ -97,7 +97,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa
|
|||
dList = rootLimb->dLists[lod];
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, arg)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (dList != NULL) {
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 881), G_MTX_LOAD);
|
||||
gSPDisplayList(POLY_OPA_DISP++, dList);
|
||||
|
@ -144,7 +144,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s
|
|||
newDList = limbDList = limb->dLists[lod];
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, arg)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (newDList != NULL) {
|
||||
Matrix_ToMtx(*mtx, "../z_skelanime.c", 945);
|
||||
{
|
||||
|
@ -212,7 +212,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi
|
|||
newDList = limbDList = rootLimb->dLists[lod];
|
||||
|
||||
if ((overrideLimbDraw == 0) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, arg)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (newDList != NULL) {
|
||||
Matrix_ToMtx(mtx, "../z_skelanime.c", 1033);
|
||||
gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_LOAD);
|
||||
|
@ -259,7 +259,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele
|
|||
dList = limb->dList;
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, arg)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (dList != NULL) {
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1103), G_MTX_LOAD);
|
||||
gSPDisplayList(POLY_OPA_DISP++, dList);
|
||||
|
@ -315,7 +315,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa
|
|||
dList = rootLimb->dList;
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, arg)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (dList != NULL) {
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1176), G_MTX_LOAD);
|
||||
gSPDisplayList(POLY_OPA_DISP++, dList);
|
||||
|
@ -362,7 +362,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s
|
|||
newDList = limbDList = limb->dList;
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, arg)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (newDList != NULL) {
|
||||
Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 1242);
|
||||
gSPMatrix(POLY_OPA_DISP++, *limbMatricies, G_MTX_LOAD);
|
||||
|
@ -431,7 +431,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi
|
|||
newDList = limbDList = rootLimb->dList;
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, arg)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (newDList != NULL) {
|
||||
Matrix_ToMtx(mtx, "../z_skelanime.c", 1327);
|
||||
gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_LOAD);
|
||||
|
@ -523,7 +523,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton
|
|||
dList = limb->dList;
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, arg, &gfx)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (dList != NULL) {
|
||||
gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1489), G_MTX_LOAD);
|
||||
gSPDisplayList(gfx++, dList);
|
||||
|
@ -581,7 +581,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable
|
|||
dList = rootLimb->dList;
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, arg, &gfx)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (dList != NULL) {
|
||||
gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1558), G_MTX_LOAD);
|
||||
gSPDisplayList(gfx++, dList);
|
||||
|
@ -626,7 +626,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel
|
|||
|
||||
newDList = limbDList = limb->dList;
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, arg, &gfx)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (newDList != NULL) {
|
||||
Matrix_ToMtx(*mtx, "../z_skelanime.c", 1623);
|
||||
gSPMatrix(gfx++, *mtx, G_MTX_LOAD);
|
||||
|
@ -691,7 +691,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT
|
|||
newDList = limbDList = rootLimb->dList;
|
||||
|
||||
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, arg, &gfx)) {
|
||||
Matrix_JointPosition(&pos, &rot);
|
||||
Matrix_TranslateRotateZYX(&pos, &rot);
|
||||
if (newDList != NULL) {
|
||||
Matrix_ToMtx(mtx, "../z_skelanime.c", 1710);
|
||||
gSPMatrix(gfx++, mtx, G_MTX_LOAD);
|
||||
|
|
|
@ -150,9 +150,9 @@ s32 func_800A6AC4(PSkinAwb* skin, MtxF* arg1, Actor* actor, s32 arg3) {
|
|||
|
||||
yRot += horse->turnRot;
|
||||
}
|
||||
SkinMatrix_SetRotateRPYTranslate(arg1, xRot, yRot, zRot, xTransl, yTransl, zTransl);
|
||||
SkinMatrix_SetTranslateRotateZYX(arg1, xRot, yRot, zRot, xTransl, yTransl, zTransl);
|
||||
} else {
|
||||
SkinMatrix_SetRotateRPYTranslate(arg1, xRot, yRot, zRot, 0.0f, 0.0f, 0.0f);
|
||||
SkinMatrix_SetTranslateRotateZYX(arg1, xRot, yRot, zRot, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
jointRot++;
|
||||
for (i = 1; i < skin->skeletonHeader->limbCount; i++) {
|
||||
|
@ -165,10 +165,10 @@ s32 func_800A6AC4(PSkinAwb* skin, MtxF* arg1, Actor* actor, s32 arg3) {
|
|||
yRot = jointRot->y;
|
||||
zRot = jointRot->z;
|
||||
jointRot++;
|
||||
SkinMatrix_SetRotateRPYTranslate(&arg1[i], xRot, yRot, zRot, xTransl, yTransl, zTransl);
|
||||
SkinMatrix_SetTranslateRotateZYX(&arg1[i], xRot, yRot, zRot, xTransl, yTransl, zTransl);
|
||||
}
|
||||
|
||||
SkinMatrix_SetScaleRotateYRPTranslate(
|
||||
SkinMatrix_SetTranslateRotateYXZScale(
|
||||
&skin->mtx, actor->scale.x, actor->scale.y, actor->scale.z, actor->shape.rot.x, actor->shape.rot.y,
|
||||
actor->shape.rot.z, actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y),
|
||||
actor->world.pos.z);
|
||||
|
|
|
@ -11,10 +11,13 @@ MtxF sMtxFClear = {
|
|||
// clang-format on
|
||||
|
||||
/**
|
||||
* Multiplies a 4 component row vector [ src , 1 ] by the matrix mf and writes the resulting 4 components to xyzDest
|
||||
* Multiplies the matrix mf by a 4 components column vector [ src , 1 ] and writes the resulting 4 components to xyzDest
|
||||
* and wDest.
|
||||
*
|
||||
* \f[ [\texttt{xyzDest}, \texttt{wDest}] = [\texttt{src}, 1] \cdot [mf] \f]
|
||||
* \f[ \begin{bmatrix} \texttt{xyzDest} \\ \texttt{wDest} \\ \end{bmatrix}
|
||||
* = [\texttt{mf}] \cdot
|
||||
* \begin{bmatrix} \texttt{src} \\ 1 \\ \end{bmatrix}
|
||||
* \f]
|
||||
*/
|
||||
void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest) {
|
||||
xyzDest->x = mf->xw + ((src->x * mf->xx) + (src->y * mf->xy) + (src->z * mf->xz));
|
||||
|
@ -24,9 +27,12 @@ void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDe
|
|||
}
|
||||
|
||||
/**
|
||||
* Multiplies a 4 component row vector [ src , 1 ] by the matrix mf and writes the resulting xyz components to dest.
|
||||
* Multiplies the matrix mf by a 4 components column vector [ src , 1 ] and writes the resulting xyz components to dest.
|
||||
*
|
||||
* \f[ [\texttt{dest}, -] = [\texttt{src}, 1] \cdot [mf] \f]
|
||||
* \f[ \begin{bmatrix} \texttt{dest} \\ - \\ \end{bmatrix}
|
||||
* = [\texttt{mf}] \cdot
|
||||
* \begin{bmatrix} \texttt{src} \\ 1 \\ \end{bmatrix}
|
||||
* \f]
|
||||
*/
|
||||
void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest) {
|
||||
f32 mx = mf->xx;
|
||||
|
@ -49,133 +55,133 @@ void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest) {
|
|||
|
||||
/**
|
||||
* Matrix multiplication, dest = mfA * mfB.
|
||||
* mfA and dest should not be the same matrix.
|
||||
* mfB and dest should not be the same matrix.
|
||||
*/
|
||||
void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest) {
|
||||
f32 x2;
|
||||
f32 y2;
|
||||
f32 z2;
|
||||
f32 w2;
|
||||
void SkinMatrix_MtxFMtxFMult(MtxF* mfA, MtxF* mfB, MtxF* dest) {
|
||||
f32 cx;
|
||||
f32 cy;
|
||||
f32 cz;
|
||||
f32 cw;
|
||||
//---ROW1---
|
||||
f32 x1 = mfB->xx;
|
||||
f32 y1 = mfB->xy;
|
||||
f32 z1 = mfB->xz;
|
||||
f32 w1 = mfB->xw;
|
||||
f32 rx = mfA->xx;
|
||||
f32 ry = mfA->xy;
|
||||
f32 rz = mfA->xz;
|
||||
f32 rw = mfA->xw;
|
||||
//--------
|
||||
|
||||
x2 = mfA->xx;
|
||||
y2 = mfA->yx;
|
||||
z2 = mfA->zx;
|
||||
w2 = mfA->wx;
|
||||
dest->xx = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xx;
|
||||
cy = mfB->yx;
|
||||
cz = mfB->zx;
|
||||
cw = mfB->wx;
|
||||
dest->xx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xy;
|
||||
y2 = mfA->yy;
|
||||
z2 = mfA->zy;
|
||||
w2 = mfA->wy;
|
||||
dest->xy = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xy;
|
||||
cy = mfB->yy;
|
||||
cz = mfB->zy;
|
||||
cw = mfB->wy;
|
||||
dest->xy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xz;
|
||||
y2 = mfA->yz;
|
||||
z2 = mfA->zz;
|
||||
w2 = mfA->wz;
|
||||
dest->xz = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xz;
|
||||
cy = mfB->yz;
|
||||
cz = mfB->zz;
|
||||
cw = mfB->wz;
|
||||
dest->xz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xw;
|
||||
y2 = mfA->yw;
|
||||
z2 = mfA->zw;
|
||||
w2 = mfA->ww;
|
||||
dest->xw = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xw;
|
||||
cy = mfB->yw;
|
||||
cz = mfB->zw;
|
||||
cw = mfB->ww;
|
||||
dest->xw = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
//---ROW2---
|
||||
x1 = mfB->yx;
|
||||
y1 = mfB->yy;
|
||||
z1 = mfB->yz;
|
||||
w1 = mfB->yw;
|
||||
rx = mfA->yx;
|
||||
ry = mfA->yy;
|
||||
rz = mfA->yz;
|
||||
rw = mfA->yw;
|
||||
//--------
|
||||
x2 = mfA->xx;
|
||||
y2 = mfA->yx;
|
||||
z2 = mfA->zx;
|
||||
w2 = mfA->wx;
|
||||
dest->yx = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xx;
|
||||
cy = mfB->yx;
|
||||
cz = mfB->zx;
|
||||
cw = mfB->wx;
|
||||
dest->yx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xy;
|
||||
y2 = mfA->yy;
|
||||
z2 = mfA->zy;
|
||||
w2 = mfA->wy;
|
||||
dest->yy = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xy;
|
||||
cy = mfB->yy;
|
||||
cz = mfB->zy;
|
||||
cw = mfB->wy;
|
||||
dest->yy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xz;
|
||||
y2 = mfA->yz;
|
||||
z2 = mfA->zz;
|
||||
w2 = mfA->wz;
|
||||
dest->yz = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xz;
|
||||
cy = mfB->yz;
|
||||
cz = mfB->zz;
|
||||
cw = mfB->wz;
|
||||
dest->yz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xw;
|
||||
y2 = mfA->yw;
|
||||
z2 = mfA->zw;
|
||||
w2 = mfA->ww;
|
||||
dest->yw = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xw;
|
||||
cy = mfB->yw;
|
||||
cz = mfB->zw;
|
||||
cw = mfB->ww;
|
||||
dest->yw = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
//---ROW3---
|
||||
x1 = mfB->zx;
|
||||
y1 = mfB->zy;
|
||||
z1 = mfB->zz;
|
||||
w1 = mfB->zw;
|
||||
rx = mfA->zx;
|
||||
ry = mfA->zy;
|
||||
rz = mfA->zz;
|
||||
rw = mfA->zw;
|
||||
//--------
|
||||
x2 = mfA->xx;
|
||||
y2 = mfA->yx;
|
||||
z2 = mfA->zx;
|
||||
w2 = mfA->wx;
|
||||
dest->zx = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xx;
|
||||
cy = mfB->yx;
|
||||
cz = mfB->zx;
|
||||
cw = mfB->wx;
|
||||
dest->zx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xy;
|
||||
y2 = mfA->yy;
|
||||
z2 = mfA->zy;
|
||||
w2 = mfA->wy;
|
||||
dest->zy = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xy;
|
||||
cy = mfB->yy;
|
||||
cz = mfB->zy;
|
||||
cw = mfB->wy;
|
||||
dest->zy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xz;
|
||||
y2 = mfA->yz;
|
||||
z2 = mfA->zz;
|
||||
w2 = mfA->wz;
|
||||
dest->zz = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xz;
|
||||
cy = mfB->yz;
|
||||
cz = mfB->zz;
|
||||
cw = mfB->wz;
|
||||
dest->zz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xw;
|
||||
y2 = mfA->yw;
|
||||
z2 = mfA->zw;
|
||||
w2 = mfA->ww;
|
||||
dest->zw = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xw;
|
||||
cy = mfB->yw;
|
||||
cz = mfB->zw;
|
||||
cw = mfB->ww;
|
||||
dest->zw = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
//---ROW4---
|
||||
x1 = mfB->wx;
|
||||
y1 = mfB->wy;
|
||||
z1 = mfB->wz;
|
||||
w1 = mfB->ww;
|
||||
rx = mfA->wx;
|
||||
ry = mfA->wy;
|
||||
rz = mfA->wz;
|
||||
rw = mfA->ww;
|
||||
//--------
|
||||
x2 = mfA->xx;
|
||||
y2 = mfA->yx;
|
||||
z2 = mfA->zx;
|
||||
w2 = mfA->wx;
|
||||
dest->wx = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xx;
|
||||
cy = mfB->yx;
|
||||
cz = mfB->zx;
|
||||
cw = mfB->wx;
|
||||
dest->wx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xy;
|
||||
y2 = mfA->yy;
|
||||
z2 = mfA->zy;
|
||||
w2 = mfA->wy;
|
||||
dest->wy = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xy;
|
||||
cy = mfB->yy;
|
||||
cz = mfB->zy;
|
||||
cw = mfB->wy;
|
||||
dest->wy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xz;
|
||||
y2 = mfA->yz;
|
||||
z2 = mfA->zz;
|
||||
w2 = mfA->wz;
|
||||
dest->wz = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xz;
|
||||
cy = mfB->yz;
|
||||
cz = mfB->zz;
|
||||
cw = mfB->wz;
|
||||
dest->wz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
x2 = mfA->xw;
|
||||
y2 = mfA->yw;
|
||||
z2 = mfA->zw;
|
||||
w2 = mfA->ww;
|
||||
dest->ww = (x1 * x2) + (y1 * y2) + (z1 * z2) + (w1 * w2);
|
||||
cx = mfB->xw;
|
||||
cy = mfB->yw;
|
||||
cz = mfB->zw;
|
||||
cw = mfB->ww;
|
||||
dest->ww = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,8 +230,7 @@ void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Inverts a matrix using a slight modification of the Gauss-Jordan method
|
||||
* (column operations instead of row operations).
|
||||
* Inverts a matrix using the Gauss-Jordan method.
|
||||
* returns 0 if successfully inverted
|
||||
* returns 2 if matrix non-invertible (0 determinant)
|
||||
*/
|
||||
|
@ -235,50 +240,53 @@ s32 SkinMatrix_Invert(MtxF* src, MtxF* dest) {
|
|||
s32 pad;
|
||||
f32 temp2;
|
||||
f32 temp1;
|
||||
s32 thisRow;
|
||||
s32 thisCol;
|
||||
s32 thisRow;
|
||||
|
||||
SkinMatrix_MtxFCopy(src, &mfCopy);
|
||||
SkinMatrix_Clear(dest);
|
||||
for (thisRow = 0; thisRow < 4; thisRow++) {
|
||||
thisCol = thisRow;
|
||||
while ((thisCol < 4) && (fabsf(mfCopy.mf[thisRow][thisCol]) < 0.0005f)) {
|
||||
thisCol++;
|
||||
for (thisCol = 0; thisCol < 4; thisCol++) {
|
||||
thisRow = thisCol;
|
||||
while ((thisRow < 4) && (fabsf(mfCopy.mf[thisCol][thisRow]) < 0.0005f)) {
|
||||
thisRow++;
|
||||
}
|
||||
if (thisCol == 4) {
|
||||
// reaching col = 4 means the row is either all 0 or a duplicate row.
|
||||
// therefore singular matrix (0 determinant).
|
||||
if (thisRow == 4) {
|
||||
// Reaching row = 4 means the column is either all 0 or a duplicate column.
|
||||
// Therefore src is a singular matrix (0 determinant).
|
||||
|
||||
osSyncPrintf(VT_COL(YELLOW, BLACK));
|
||||
osSyncPrintf("Skin_Matrix_InverseMatrix():逆行列つくれません\n");
|
||||
osSyncPrintf(VT_RST);
|
||||
return 2;
|
||||
}
|
||||
if (thisCol != thisRow) { // responsible for swapping columns if zero on diagonal
|
||||
for (i = 0; i < 4; i++) {
|
||||
temp1 = mfCopy.mf[i][thisCol];
|
||||
mfCopy.mf[i][thisCol] = mfCopy.mf[i][thisRow];
|
||||
mfCopy.mf[i][thisRow] = temp1;
|
||||
|
||||
temp2 = dest->mf[i][thisCol];
|
||||
dest->mf[i][thisCol] = dest->mf[i][thisRow];
|
||||
dest->mf[i][thisRow] = temp2;
|
||||
if (thisRow != thisCol) {
|
||||
// Diagonal element mf[thisCol][thisCol] is zero.
|
||||
// Swap the rows thisCol and thisRow.
|
||||
for (i = 0; i < 4; i++) {
|
||||
temp1 = mfCopy.mf[i][thisRow];
|
||||
mfCopy.mf[i][thisRow] = mfCopy.mf[i][thisCol];
|
||||
mfCopy.mf[i][thisCol] = temp1;
|
||||
|
||||
temp2 = dest->mf[i][thisRow];
|
||||
dest->mf[i][thisRow] = dest->mf[i][thisCol];
|
||||
dest->mf[i][thisCol] = temp2;
|
||||
}
|
||||
}
|
||||
|
||||
// Scale this whole column s.t. the diag element = 1
|
||||
temp1 = mfCopy.mf[thisRow][thisRow];
|
||||
// Scale this whole row such that the diagonal element is 1.
|
||||
temp1 = mfCopy.mf[thisCol][thisCol];
|
||||
for (i = 0; i < 4; i++) {
|
||||
mfCopy.mf[i][thisRow] /= temp1;
|
||||
dest->mf[i][thisRow] /= temp1;
|
||||
mfCopy.mf[i][thisCol] /= temp1;
|
||||
dest->mf[i][thisCol] /= temp1;
|
||||
}
|
||||
|
||||
for (thisCol = 0; thisCol < 4; thisCol++) {
|
||||
if (thisCol != thisRow) {
|
||||
temp1 = mfCopy.mf[thisRow][thisCol];
|
||||
for (thisRow = 0; thisRow < 4; thisRow++) {
|
||||
if (thisRow != thisCol) {
|
||||
temp1 = mfCopy.mf[thisCol][thisRow];
|
||||
for (i = 0; i < 4; i++) {
|
||||
mfCopy.mf[i][thisCol] -= mfCopy.mf[i][thisRow] * temp1;
|
||||
dest->mf[i][thisCol] -= dest->mf[i][thisRow] * temp1;
|
||||
mfCopy.mf[i][thisRow] -= mfCopy.mf[i][thisCol] * temp1;
|
||||
dest->mf[i][thisRow] -= dest->mf[i][thisCol] * temp1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -309,85 +317,84 @@ void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Produces a rotation matrix = (roll rotation matrix) * (pitch rotation matrix) * (yaw rotation matrix)
|
||||
* Produces a rotation matrix using ZYX Tait-Bryan angles.
|
||||
*/
|
||||
void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) {
|
||||
f32 cos2;
|
||||
f32 sin = Math_SinS(yaw);
|
||||
f32 cos = Math_CosS(yaw);
|
||||
void SkinMatrix_SetRotateZYX(MtxF* mf, s16 x, s16 y, s16 z) {
|
||||
f32 cos;
|
||||
f32 sinZ = Math_SinS(z);
|
||||
f32 cosZ = Math_CosS(z);
|
||||
f32 xy;
|
||||
f32 sin2;
|
||||
f32 sin;
|
||||
f32 xz;
|
||||
f32 yy;
|
||||
f32 yz;
|
||||
|
||||
mf->yy = cos;
|
||||
mf->xy = -sin;
|
||||
mf->yy = cosZ;
|
||||
mf->xy = -sinZ;
|
||||
mf->wx = mf->wy = mf->wz = 0;
|
||||
mf->xw = mf->yw = mf->zw = 0;
|
||||
mf->ww = 1;
|
||||
|
||||
if (pitch != 0) {
|
||||
sin2 = Math_SinS(pitch);
|
||||
cos2 = Math_CosS(pitch);
|
||||
if (y != 0) {
|
||||
sin = Math_SinS(y);
|
||||
cos = Math_CosS(y);
|
||||
|
||||
mf->xx = cos * cos2;
|
||||
mf->xz = cos * sin2;
|
||||
mf->xx = cosZ * cos;
|
||||
mf->xz = cosZ * sin;
|
||||
|
||||
mf->yx = sin * cos2;
|
||||
mf->yz = sin * sin2;
|
||||
mf->zx = -sin2;
|
||||
mf->zz = cos2;
|
||||
mf->yx = sinZ * cos;
|
||||
mf->yz = sinZ * sin;
|
||||
mf->zx = -sin;
|
||||
mf->zz = cos;
|
||||
|
||||
} else {
|
||||
mf->xx = cos;
|
||||
mf->xx = cosZ;
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
xz = sin; // required to match
|
||||
mf->yx = sin;
|
||||
xz = sinZ; // required to match
|
||||
mf->yx = sinZ;
|
||||
mf->zx = mf->xz = mf->yz = 0;
|
||||
mf->zz = 1;
|
||||
}
|
||||
|
||||
if (roll != 0) {
|
||||
sin2 = Math_SinS(roll);
|
||||
cos2 = Math_CosS(roll);
|
||||
if (x != 0) {
|
||||
sin = Math_SinS(x);
|
||||
cos = Math_CosS(x);
|
||||
|
||||
xy = mf->xy;
|
||||
xz = mf->xz;
|
||||
mf->xy = (xy * cos2) + (xz * sin2);
|
||||
mf->xz = (xz * cos2) - (xy * sin2);
|
||||
mf->xy = (xy * cos) + (xz * sin);
|
||||
mf->xz = (xz * cos) - (xy * sin);
|
||||
|
||||
if (1) {}
|
||||
yz = mf->yz;
|
||||
yy = mf->yy;
|
||||
mf->yy = (yy * cos2) + (yz * sin2);
|
||||
mf->yz = (yz * cos2) - (yy * sin2);
|
||||
mf->yy = (yy * cos) + (yz * sin);
|
||||
mf->yz = (yz * cos) - (yy * sin);
|
||||
|
||||
if (cos2) {}
|
||||
mf->zy = mf->zz * sin2;
|
||||
mf->zz = mf->zz * cos2;
|
||||
if (cos) {}
|
||||
mf->zy = mf->zz * sin;
|
||||
mf->zz = mf->zz * cos;
|
||||
} else {
|
||||
mf->zy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a rotation matrix = (yaw rotation matrix) * (roll rotation matrix) * (pitch rotation matrix)
|
||||
* Produces a rotation matrix using YXZ Tait-Bryan angles.
|
||||
*/
|
||||
void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) {
|
||||
f32 cos2;
|
||||
f32 sin;
|
||||
void SkinMatrix_SetRotateYXZ(MtxF* mf, s16 x, s16 y, s16 z) {
|
||||
f32 cos;
|
||||
f32 sinY = Math_SinS(y);
|
||||
f32 cosY = Math_CosS(y);
|
||||
f32 zx;
|
||||
f32 sin2;
|
||||
f32 sin;
|
||||
f32 zy;
|
||||
f32 xx;
|
||||
f32 xy;
|
||||
sin = Math_SinS(roll);
|
||||
cos = Math_CosS(roll);
|
||||
mf->xx = cos;
|
||||
mf->zx = -sin;
|
||||
|
||||
mf->xx = cosY;
|
||||
mf->zx = -sinY;
|
||||
mf->wz = 0;
|
||||
mf->wy = 0;
|
||||
mf->wx = 0;
|
||||
|
@ -396,43 +403,43 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) {
|
|||
mf->xw = 0;
|
||||
mf->ww = 1;
|
||||
|
||||
if (yaw != 0) {
|
||||
sin2 = Math_SinS(yaw);
|
||||
cos2 = Math_CosS(yaw);
|
||||
if (x != 0) {
|
||||
sin = Math_SinS(x);
|
||||
cos = Math_CosS(x);
|
||||
|
||||
mf->zz = cos * cos2;
|
||||
mf->zy = cos * sin2;
|
||||
mf->zz = cosY * cos;
|
||||
mf->zy = cosY * sin;
|
||||
|
||||
mf->xz = sin * cos2;
|
||||
mf->xy = sin * sin2;
|
||||
mf->yz = -sin2;
|
||||
mf->yy = cos2;
|
||||
mf->xz = sinY * cos;
|
||||
mf->xy = sinY * sin;
|
||||
mf->yz = -sin;
|
||||
mf->yy = cos;
|
||||
|
||||
} else {
|
||||
mf->zz = cos;
|
||||
mf->zz = cosY;
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
xy = sin; // required to match
|
||||
mf->xz = sin;
|
||||
xy = sinY; // required to match
|
||||
mf->xz = sinY;
|
||||
mf->xy = mf->zy = mf->yz = 0;
|
||||
mf->yy = 1;
|
||||
}
|
||||
|
||||
if (pitch != 0) {
|
||||
sin2 = Math_SinS(pitch);
|
||||
cos2 = Math_CosS(pitch);
|
||||
if (z != 0) {
|
||||
sin = Math_SinS(z);
|
||||
cos = Math_CosS(z);
|
||||
xx = mf->xx;
|
||||
xy = mf->xy;
|
||||
mf->xx = (xx * cos2) + (xy * sin2);
|
||||
mf->xy = xy * cos2 - (xx * sin2);
|
||||
mf->xx = (xx * cos) + (xy * sin);
|
||||
mf->xy = xy * cos - (xx * sin);
|
||||
if (1) {}
|
||||
zy = mf->zy;
|
||||
zx = mf->zx;
|
||||
mf->zx = (zx * cos2) + (zy * sin2);
|
||||
mf->zy = (zy * cos2) - (zx * sin2);
|
||||
if (cos2) {}
|
||||
mf->yx = mf->yy * sin2;
|
||||
mf->yy = mf->yy * cos2;
|
||||
mf->zx = (zx * cos) + (zy * sin);
|
||||
mf->zy = (zy * cos) - (zx * sin);
|
||||
if (cos) {}
|
||||
mf->yx = mf->yy * sin;
|
||||
mf->yy = mf->yy * cos;
|
||||
} else {
|
||||
mf->yx = 0;
|
||||
}
|
||||
|
@ -461,45 +468,46 @@ void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Produces a matrix which scales, then rotates (RPY), then translates a vector
|
||||
* Produces a matrix which scales, then rotates (using ZYX Tait-Bryan angles), then translates.
|
||||
*/
|
||||
void SkinMatrix_SetScaleRotateRPYTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 roll, s16 pitch, s16 yaw,
|
||||
f32 dx, f32 dy, f32 dz) {
|
||||
void SkinMatrix_SetTranslateRotateZYXScale(MtxF* dest, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ,
|
||||
f32 translateX, f32 translateY, f32 translateZ) {
|
||||
MtxF mft1;
|
||||
MtxF mft2;
|
||||
|
||||
SkinMatrix_SetTranslate(mf, dx, dy, dz);
|
||||
SkinMatrix_SetRotateRPY(&mft1, roll, pitch, yaw);
|
||||
SkinMatrix_MtxFMtxFMult(mf, &mft1, &mft2);
|
||||
SkinMatrix_SetTranslate(dest, translateX, translateY, translateZ);
|
||||
SkinMatrix_SetRotateZYX(&mft1, rotX, rotY, rotZ);
|
||||
SkinMatrix_MtxFMtxFMult(dest, &mft1, &mft2);
|
||||
SkinMatrix_SetScale(&mft1, scaleX, scaleY, scaleZ);
|
||||
SkinMatrix_MtxFMtxFMult(&mft2, &mft1, mf);
|
||||
SkinMatrix_MtxFMtxFMult(&mft2, &mft1, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a matrix which scales, then rotates (YRP), then translates a vector
|
||||
* Produces a matrix which scales, then rotates (using YXZ Tait-Bryan angles), then translates.
|
||||
*/
|
||||
void SkinMatrix_SetScaleRotateYRPTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 scaleZ, s16 yaw, s16 roll, s16 pitch,
|
||||
f32 dx, f32 dy, f32 dz) {
|
||||
void SkinMatrix_SetTranslateRotateYXZScale(MtxF* dest, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ,
|
||||
f32 translateX, f32 translateY, f32 translateZ) {
|
||||
MtxF mft1;
|
||||
MtxF mft2;
|
||||
|
||||
SkinMatrix_SetTranslate(mf, dx, dy, dz);
|
||||
SkinMatrix_SetRotateYRP(&mft1, yaw, roll, pitch);
|
||||
SkinMatrix_MtxFMtxFMult(mf, &mft1, &mft2);
|
||||
SkinMatrix_SetTranslate(dest, translateX, translateY, translateZ);
|
||||
SkinMatrix_SetRotateYXZ(&mft1, rotX, rotY, rotZ);
|
||||
SkinMatrix_MtxFMtxFMult(dest, &mft1, &mft2);
|
||||
SkinMatrix_SetScale(&mft1, scaleX, scaleY, scaleZ);
|
||||
SkinMatrix_MtxFMtxFMult(&mft2, &mft1, mf);
|
||||
SkinMatrix_MtxFMtxFMult(&mft2, &mft1, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a matrix which rotates (RPY), then translates a vector
|
||||
* Produces a matrix which rotates (using ZYX Tait-Bryan angles), then translates.
|
||||
*/
|
||||
void SkinMatrix_SetRotateRPYTranslate(MtxF* mf, s16 roll, s16 pitch, s16 yaw, f32 dx, f32 dy, f32 dz) {
|
||||
MtxF mft1;
|
||||
MtxF mft2;
|
||||
void SkinMatrix_SetTranslateRotateZYX(MtxF* dest, s16 rotX, s16 rotY, s16 rotZ, f32 translateX, f32 translateY,
|
||||
f32 translateZ) {
|
||||
MtxF rotation;
|
||||
MtxF translation;
|
||||
|
||||
SkinMatrix_SetTranslate(&mft2, dx, dy, dz);
|
||||
SkinMatrix_SetRotateRPY(&mft1, roll, pitch, yaw);
|
||||
SkinMatrix_MtxFMtxFMult(&mft2, &mft1, mf);
|
||||
SkinMatrix_SetTranslate(&translation, translateX, translateY, translateZ);
|
||||
SkinMatrix_SetRotateZYX(&rotation, rotX, rotY, rotZ);
|
||||
SkinMatrix_MtxFMtxFMult(&translation, &rotation, dest);
|
||||
}
|
||||
|
||||
void SkinMatrix_Vec3fToVec3s(Vec3f* src, Vec3s* dest) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue