mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-28 08:49:30 +00:00
Updated all the libs, added citro3d, added ctr.swkbd (WIP, untested)
This commit is contained in:
parent
68a44645f7
commit
49c87e5526
97 changed files with 7341 additions and 944 deletions
33
libs/citro3d/source/maths/mtx_perspstereotilt.c
Normal file
33
libs/citro3d/source/maths/mtx_perspstereotilt.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include <c3d/maths.h>
|
||||
|
||||
void Mtx_PerspStereoTilt(C3D_Mtx* mtx, float fovx, float invaspect, float near, float far, float iod, float screen, bool isLeftHanded)
|
||||
{
|
||||
// Notes:
|
||||
// Once again, we are passed "fovy" and the "aspect ratio"; however the 3DS screens are sideways,
|
||||
// and the formula had to be tweaked. With stereo, left/right separation becomes top/bottom separation.
|
||||
// The detailed mathematical explanation is in mtx_persptilt.c.
|
||||
|
||||
float fovx_tan = tanf(fovx/2.0f);
|
||||
float fovx_tan_invaspect = fovx_tan*invaspect;
|
||||
float shift = iod / (2.0f*screen); // 'near' not in the numerator because it cancels out in mp.r[1].z
|
||||
|
||||
Mtx_Zeros(mtx);
|
||||
|
||||
mtx->r[0].y = 1.0f / fovx_tan;
|
||||
mtx->r[1].x = -1.0f / fovx_tan_invaspect;
|
||||
mtx->r[1].w = iod / 2.0f;
|
||||
mtx->r[2].w = near * far / (near - far);
|
||||
|
||||
if (isLeftHanded)
|
||||
{
|
||||
mtx->r[1].z = -shift / fovx_tan_invaspect;
|
||||
mtx->r[2].z = 0.5f*(near + far) / (far - near) - 0.5f;
|
||||
mtx->r[3].z = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtx->r[1].z = shift / fovx_tan_invaspect;
|
||||
mtx->r[2].z = 0.5f*(near + far) / (near - far) + 0.5f;
|
||||
mtx->r[3].z = -1.0f;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue