I’m trying to get my head around some 3D graphics, but ran into trouble.
I have a number of points that make up a cube. Very simple.
I use an orthographic projection matrix to display it.
But when I try to apply a perspective projection matrix it looks like anything but a cube. I’ve tried multiple
ways to get it to work but it still doesn’t.
I have attached my source code.
By commenting an uncommenting the following lines (in 3DGraphics.as) you can switch between the orthographic projection and perspective projection matrix. As you can see when just using the orthographic projection matrix it works fine. But with the perspective it doesn’t.
// Ortographic and perspective
// mP = mPers.multiplyMatrix(mOrto);
// Just ortographic
mP = mOrto;
Any help on why my perspective matrix isn’t working is appreciated.
The perspective matrix looks like this. In a column major order:
n is the near plane and f the far plane.
mA[0] = n;
mA[5] = n;
mA[10] = n+f;
mA[11] = 1;
mA[14] = -(f*n);
mA[15] = 0;
Thanks!
/ Magnus