Original Post
EDIT: Nevermind, it was just a problem with my matrix multiplication function. Hello, I'm working on my own 3D software rasterizer and am having a problem with matrices. I can move vertices on the X and Y axis using translation, but when I try on the Z axis nothing happens. Here is the translation code: I think my 3D->2D transformation might be the problem. If I rotate something it appears flat when viewed from the side. I didn't calculate the depth(rz) because I'm not using a depth buffer yet. Anyone have any ideas? Thanks. [Edited by - Scet on February 5, 2009 10:43:59 AM]
public void Translate( float x, float y, float z )
{
M[12] += ( ( M[0] * x ) + ( M[4] * y ) + ( M[8] * z ) );
M[13] += ( ( M[1] * x ) + ( M[5] * y ) + ( M[9] * z ) );
M[14] += ( ( M[2] * x ) + ( M[6] * y ) + ( M[10] * z ) );
M[15] += ( ( M[3] * x ) + ( M[7] * y ) + ( M[11] * z ) );
return;
}
rw = ( ( WorldMatrix.M[3] * VertexSource.X ) + ( WorldMatrix.M[7] * VertexSource.Y ) + ( WorldMatrix.M[11] * VertexSource.Z ) + WorldMatrix.M[15] );
ry = ( ( WorldMatrix.M[1] * VertexSource.X ) + ( WorldMatrix.M[5] * VertexSource.Y ) + ( WorldMatrix.M[9] * VertexSource.Z ) + WorldMatrix.M[13] );
if( ( ( ry + rw ) < 0 ) || ( ry - rw > 0 ) )
{
continue;
}
rx = ( ( WorldMatrix.M[0] * VertexSource.X ) + ( WorldMatrix.M[4] * VertexSource.Y ) + ( WorldMatrix.M[8] * VertexSource.Z ) + WorldMatrix.M[12] );
if( ( ( rx + rw ) < 0 ) || ( rx - rw > 0 ) )
{
continue;
}
x = (int)( ( ( rx / rw ) + 1 ) * ( RenderTarget.HalfWidth ) );
y = (int)( ( ( ry / rw ) + 1 ) * ( RenderTarget.HalfHeight ) );