mirror of
https://github.com/holub/mame
synced 2025-04-29 11:30:28 +03:00
chihiro.cpp: clarifications and renaming for 3d matrices (nw)
This commit is contained in:
parent
3e39547742
commit
ee5afda78e
@ -706,6 +706,7 @@ public:
|
|||||||
struct {
|
struct {
|
||||||
float modelview[4][4];
|
float modelview[4][4];
|
||||||
float modelview_inverse[4][4];
|
float modelview_inverse[4][4];
|
||||||
|
float composite[4][4];
|
||||||
float projection[4][4];
|
float projection[4][4];
|
||||||
float translate[4];
|
float translate[4];
|
||||||
float scale[4];
|
float scale[4];
|
||||||
|
@ -2360,7 +2360,8 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, nv2avertex_t *desti
|
|||||||
{
|
{
|
||||||
vertex_nv vert[4];
|
vertex_nv vert[4];
|
||||||
int m, u;
|
int m, u;
|
||||||
float t[4],v[4];
|
//float t[4];
|
||||||
|
float v[4];
|
||||||
|
|
||||||
// take each vertex with its attributes and obtain data for drawing
|
// take each vertex with its attributes and obtain data for drawing
|
||||||
// should use either the vertex program or transformation matrices
|
// should use either the vertex program or transformation matrices
|
||||||
@ -2368,16 +2369,25 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, nv2avertex_t *desti
|
|||||||
// transformation matrices
|
// transformation matrices
|
||||||
// this part needs more testing
|
// this part needs more testing
|
||||||
for (m = 0; m < count; m++) {
|
for (m = 0; m < count; m++) {
|
||||||
|
#if 0
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
t[i] = 0;
|
t[i] = 0;
|
||||||
|
// in matrix.modelview[c][r] c is the column and r is the row of the direct3d matrix
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
t[i] += matrix.modelview[i][j] * source[m].attribute[0].fv[j];
|
t[i] += matrix.modelview[i][j] * source[m].attribute[0].fv[j];
|
||||||
};
|
};
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
v[i] = 0;
|
v[i] = 0;
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
v[i] += matrix.projection[i][j] * t[j];
|
v[i] += matrix.composite[i][j] * t[j];
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
v[i] = 0;
|
||||||
|
for (int j = 0; j < 4; j++)
|
||||||
|
v[i] += matrix.composite[i][j] * source[m].attribute[0].fv[j];
|
||||||
|
};
|
||||||
|
#endif
|
||||||
/* it seems these are not needed ?
|
/* it seems these are not needed ?
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
v[i] *= matrix.scale[i];
|
v[i] *= matrix.scale[i];
|
||||||
@ -3486,9 +3496,29 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN
|
|||||||
}
|
}
|
||||||
countlen--;
|
countlen--;
|
||||||
}
|
}
|
||||||
|
// projection matrix
|
||||||
|
if ((maddress >= 0x0440) && (maddress < 0x0480)) {
|
||||||
|
maddress = (maddress - 0x0440) / 4;
|
||||||
|
*(UINT32 *)(&matrix.projection[maddress >> 2][maddress & 3]) = data;
|
||||||
|
countlen--;
|
||||||
|
}
|
||||||
// modelview matrix
|
// modelview matrix
|
||||||
if ((maddress >= 0x0480) && (maddress < 0x04c0)) {
|
if ((maddress >= 0x0480) && (maddress < 0x04c0)) {
|
||||||
maddress = (maddress - 0x0480) / 4;
|
maddress = (maddress - 0x0480) / 4;
|
||||||
|
/* the modelview matrix is obtained by direct3d by multiplyng the world matrix and the view matrix
|
||||||
|
modelview = world * view
|
||||||
|
given a point in 3d space with coordinates x y and z, to find te transformed coordinates
|
||||||
|
first create a row vector with components (x,y,z,1) then multyply the vector by the matrix
|
||||||
|
transformed = rowvector * matrix
|
||||||
|
in direct3d the matrix is stored as the sequence (first digit row, second digit column)
|
||||||
|
11 12 13 14
|
||||||
|
21 22 23 24
|
||||||
|
31 32 33 34
|
||||||
|
41 42 43 44
|
||||||
|
but it is sent trasposed as the sequence
|
||||||
|
11 21 31 41 12 22 32 42 13 23 33 43 14 24 34 44
|
||||||
|
so in matrix.modelview[x][y] x is the column and y is the row of the direct3d matrix
|
||||||
|
*/
|
||||||
*(UINT32 *)(&matrix.modelview[maddress >> 2][maddress & 3]) = data;
|
*(UINT32 *)(&matrix.modelview[maddress >> 2][maddress & 3]) = data;
|
||||||
countlen--;
|
countlen--;
|
||||||
}
|
}
|
||||||
@ -3498,10 +3528,15 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN
|
|||||||
*(UINT32 *)(&matrix.modelview_inverse[maddress >> 2][maddress & 3]) = data;
|
*(UINT32 *)(&matrix.modelview_inverse[maddress >> 2][maddress & 3]) = data;
|
||||||
countlen--;
|
countlen--;
|
||||||
}
|
}
|
||||||
// projection matrix
|
// composite matrix
|
||||||
if ((maddress >= 0x0680) && (maddress < 0x06c0)) {
|
if ((maddress >= 0x0680) && (maddress < 0x06c0)) {
|
||||||
maddress = (maddress - 0x0680) / 4;
|
maddress = (maddress - 0x0680) / 4;
|
||||||
*(UINT32 *)(&matrix.projection[maddress >> 2][maddress & 3]) = data;
|
/* the composite matrix is computed by direct3d by multiplying the
|
||||||
|
world, view, projection and viewport matrices
|
||||||
|
composite = world * view * projection * viewport
|
||||||
|
the viewport matrix applies the viewport scale and offset
|
||||||
|
*/
|
||||||
|
*(UINT32 *)(&matrix.composite[maddress >> 2][maddress & 3]) = data;
|
||||||
countlen--;
|
countlen--;
|
||||||
}
|
}
|
||||||
// viewport translate
|
// viewport translate
|
||||||
|
Loading…
Reference in New Issue
Block a user