[ad_1]
There may be operate compose View Matrix, it is software program rendering mission. Used mounted level math. phd_sin() and phd_cos() consumer outlined features implement sin() and cos(). Please clarify this calculations, the place is there vector Proper, Up, Look, like in View matrix from DX for instance? How composed View matrix on this case (beneath)? I dont know this method.
typedef struct PHD_3DPOS {
int32_t x;
int32_t y;
int32_t z;
int16_t x_rot;
int16_t y_rot;
int16_t z_rot;
} PHD_3DPOS;
#outline W2V_SHIFT 14
#outline TRIGMULT2(A, B) (((A) * (B)) >> W2V_SHIFT)
#outline TRIGMULT3(A, B, C) (TRIGMULT2((TRIGMULT2(A, B)), C))
typedef struct PHD_MATRIX {
int32_t _00;
int32_t _01;
int32_t _02;
int32_t _03;
int32_t _10;
int32_t _11;
int32_t _12;
int32_t _13;
int32_t _20;
int32_t _21;
int32_t _22;
int32_t _23;
} PHD_MATRIX;
#outline MAX_MATRICES 40
PHD_MATRIX m_MatrixStack[MAX_MATRICES] = { 0 };
PHD_MATRIX g_W2VMatrix = { 0 };
void phd_GenerateW2V(PHD_3DPOS *viewpos)
{
int32_t sx = phd_sin(viewpos->x_rot);
int32_t cx = phd_cos(viewpos->x_rot);
int32_t sy = phd_sin(viewpos->y_rot);
int32_t cy = phd_cos(viewpos->y_rot);
int32_t sz = phd_sin(viewpos->z_rot);
int32_t cz = phd_cos(viewpos->z_rot);
m_MatrixStack[0]._00 = TRIGMULT3(sx, sy, sz) + TRIGMULT2(cy, cz);
m_MatrixStack[0]._01 = TRIGMULT2(cx, sz);
m_MatrixStack[0]._02 = TRIGMULT3(sx, cy, sz) - TRIGMULT2(sy, cz);
m_MatrixStack[0]._10 = TRIGMULT3(sx, sy, cz) - TRIGMULT2(cy, sz);
m_MatrixStack[0]._11 = TRIGMULT2(cx, cz);
m_MatrixStack[0]._12 = TRIGMULT3(sx, cy, cz) + TRIGMULT2(sy, sz);
m_MatrixStack[0]._20 = TRIGMULT2(cx, sy);
m_MatrixStack[0]._21 = -sx;
m_MatrixStack[0]._22 = TRIGMULT2(cx, cy);
m_MatrixStack[0]._03 = viewpos->x;
m_MatrixStack[0]._13 = viewpos->y;
m_MatrixStack[0]._23 = viewpos->z;
g_W2VMatrix = m_MatrixStack[0];
}
```
[ad_2]