- Fixed normal transformation, as, obviously, normals MUST NOT be transformed by a 4x4 matrix: translation is meaningless on normals :P

- Added matrix.h to the .vcproj
This commit is contained in:
shashclp 2007-04-24 21:07:10 +00:00
parent 9b8467cbd9
commit 7eb22ce304
3 changed files with 16 additions and 4 deletions

View File

@ -30,7 +30,7 @@ void MatrixInit (float *matrix)
matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f;
}
void MatrixMultVec (float *matrix, float *vecPtr)
void MatrixMultVec4x4 (float *matrix, float *vecPtr)
{
float x = vecPtr[0];
float y = vecPtr[1];
@ -41,6 +41,17 @@ void MatrixMultVec (float *matrix, float *vecPtr)
vecPtr[2] = x * matrix[2] + y * matrix[6] + z * matrix[10] + matrix[14];
}
void MatrixMultVec3x3 (float *matrix, float *vecPtr)
{
float x = vecPtr[0];
float y = vecPtr[1];
float z = vecPtr[2];
vecPtr[0] = x * matrix[0] + y * matrix[4] + z * matrix[ 8];
vecPtr[1] = x * matrix[1] + y * matrix[5] + z * matrix[ 9];
vecPtr[2] = x * matrix[2] + y * matrix[6] + z * matrix[10];
}
void MatrixIdentity (float *matrix)
{
memset (matrix, 0, sizeof(float)*16);

View File

@ -29,7 +29,8 @@ typedef struct MatrixStack
} MatrixStack;
void MatrixInit (float *matrix);
void MatrixMultVec (float *matrix, float *vecPtr);
void MatrixMultVec3x3 (float *matrix, float *vecPtr);
void MatrixMultVec4x4 (float *matrix, float *vecPtr);
void MatrixIdentity (float *matrix);
void MatrixMultiply (float *matrix, float *rightMatrix);
float MatrixGetMultipliedIndex(int index, float *matrix, float *rightMatrix);

View File

@ -971,7 +971,7 @@ static __inline void SetVertex()
SetTextureCoordinate (s2, t2);
}
MatrixMultVec (mtxCurrent[1], coordTransformed);
MatrixMultVec4x4 (mtxCurrent[1], coordTransformed);
glVertex3fv (coordTransformed);
//glVertex3fv (coord);
@ -1377,7 +1377,7 @@ void NDS_glNormal(unsigned long v)
SetTextureCoordinate (s2, t2);
}
MatrixMultVec (mtxCurrent[2], normal);
MatrixMultVec3x3 (mtxCurrent[2], normal);
glNormal3fv(normal);
}