Matrix4X4 SoftwareCanvas::ProjectionMatrix(float FOV_horiz, float FOV_vert, float nearplane, float farplane, Matrix4X4 &m)
{
float h,w,q;
w= (float)1/tan(FOV_horiz*0.5);
h= (float)1/tan(FOV_vert*0.5);
q= farplane/(farplane-nearplane);
m.m11=w;
m.m22=h;
m.m33=q;
m.m34=1;
m.m43=-q*nearplane;
return m;
};
i set the FOV both FOV to pi/4 the near to 1 and the farplane to 1000
Then for each point in the triangle i transform it with the matrix
Point2D SoftwareCanvas::MatVec(Point3D v, Matrix4X4 m)
{
Point3D transvec(0,0,0,1);
transvec.x= v.x*m.m11+v.y*m.m21+v.z*m.m31+v.w*m.m41;
transvec.y= v.x*m.m12+v.y*m.m22+v.z*m.m32+v.w*m.m42;
transvec.z= v.x*m.m13+v.y*m.m23+v.z*m.m33+v.w*m.m43;
transvec.w= v.x*m.m14+v.y*m.m24+v.z*m.m34+v.w*m.m44;
Point2D newpoint(transvec.w*transvec.x/transvec.z,transvec.w*transvec.y/transvec.z);
return newpoint;
};
The problem is the perspective dosn't look right it changes with a differant z value but its not really in perspective and there is not much defferance betweem 60 z and 600 z.
Has anyone got any ideas where im going wrong?
Thanks











