perspective projection matrix

Started by
1 comment, last by NBarrett 20 years, 6 months ago
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...
Advertisement
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);
}
this is for the left handed system btw

My Site

This topic is closed to new replies.

Advertisement