mirror of
https://github.com/zeldaret/oot.git
synced 2024-09-23 22:05:09 +00:00
7e195a3562
* osPfsIsPlug.c and osContSetCh.c OK * update * __osPfsGetStatus.c OK * removed unused asm * Updated all libultra controller files to use new structs instead of the temporary structs. Added os_pfs.h * controller updates * fixed header guard * Made suggested changes * guLookAt.c OK * commit * __osPfsSelectBank.c OK * osPfsDeleteFile.c OK * pfsreadwritefile.c OK * osPfsFreeBlocks.c OK * cleaned up ospfsfreeblocks * started pfsinitpak.c * pfsallocatefile.c OK * contpfs.c decompiled with 1 non matching * osPfsFindFile.c OK * pfsinitpak.c decompiled. one non-matching * Actually fixed merge conflict * sins.c OK * cosf.c sinf.c and sins.c OK * moved osAfterPreNMI to its own file. Renamed code_801031F0 to contquery.c * pfschecker.c OK * final update and rename * Removed makefile testing thing that i accidentally added * Made suggested changes
63 lines
1.6 KiB
C
63 lines
1.6 KiB
C
#include <ultra64.h>
|
|
#include <global.h>
|
|
|
|
void guLookAtF(f32 mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp) {
|
|
f32 length;
|
|
f32 xLook, yLook, zLook;
|
|
f32 xRight, yRight, zRight;
|
|
|
|
guMtxIdentF(mf);
|
|
|
|
xLook = xAt - xEye;
|
|
yLook = yAt - yEye;
|
|
zLook = zAt - zEye;
|
|
length = -1.0 / sqrtf(SQ(xLook) + SQ(yLook) + SQ(zLook));
|
|
xLook *= length;
|
|
yLook *= length;
|
|
zLook *= length;
|
|
|
|
xRight = yUp * zLook - zUp * yLook;
|
|
yRight = zUp * xLook - xUp * zLook;
|
|
zRight = xUp * yLook - yUp * xLook;
|
|
length = 1.0 / sqrtf(SQ(xRight) + SQ(yRight) + SQ(zRight));
|
|
xRight *= length;
|
|
yRight *= length;
|
|
zRight *= length;
|
|
|
|
xUp = yLook * zRight - zLook * yRight;
|
|
yUp = zLook * xRight - xLook * zRight;
|
|
zUp = xLook * yRight - yLook * xRight;
|
|
length = 1.0 / sqrtf(SQ(xUp) + SQ(yUp) + SQ(zUp));
|
|
xUp *= length;
|
|
yUp *= length;
|
|
zUp *= length;
|
|
|
|
mf[0][0] = xRight;
|
|
mf[1][0] = yRight;
|
|
mf[2][0] = zRight;
|
|
mf[3][0] = -(xEye * xRight + yEye * yRight + zEye * zRight);
|
|
|
|
mf[0][1] = xUp;
|
|
mf[1][1] = yUp;
|
|
mf[2][1] = zUp;
|
|
mf[3][1] = -(xEye * xUp + yEye * yUp + zEye * zUp);
|
|
|
|
mf[0][2] = xLook;
|
|
mf[1][2] = yLook;
|
|
mf[2][2] = zLook;
|
|
mf[3][2] = -(xEye * xLook + yEye * yLook + zEye * zLook);
|
|
|
|
mf[0][3] = 0;
|
|
mf[1][3] = 0;
|
|
mf[2][3] = 0;
|
|
mf[3][3] = 1;
|
|
}
|
|
|
|
void guLookAt(Mtx* m, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp) {
|
|
f32 mf[4][4];
|
|
|
|
guLookAtF(mf, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp);
|
|
|
|
guMtxF2L(mf, m);
|
|
}
|