perspective projection matrix
Does anyone know how to construct a perspective projection matrix given a FOV, z values of far and near planes, and an aspect ratio??? (without using any API function calls..Thanks...
void MATRIX4::SetProjection(float fov,float aspect,float nearplane,float farplane)
{
float h = cosf(fov / 2) / sinf(fov / 2);
float w = h / aspect;
memset(this,0,sizeof(MATRIX4));
m[0][0] = w;
m[1][1] = h;
m[2][2] = farplane / (farplane - nearplane);
m[2][3] = 1;
m[3][2] = nearplane * farplane / (nearplane - farplane);
}
{
float h = cosf(fov / 2) / sinf(fov / 2);
float w = h / aspect;
memset(this,0,sizeof(MATRIX4));
m[0][0] = w;
m[1][1] = h;
m[2][2] = farplane / (farplane - nearplane);
m[2][3] = 1;
m[3][2] = nearplane * farplane / (nearplane - farplane);
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement