i did this tutorial:
http://ltslashgt.com/2011/02/28/molehill-spinning-cube/
The interesting part is that he didn't use perspectiveFieldOfViewLH and instead he defined his own projection matrix. I'm new to the 3d programming, so after reading this explenation of projection matrix:
http://www.songho.ca/opengl/gl_projectionmatrix.html
i tried to implement my own matrix to see if i really understand it:
var y2:Number = near * Math.tan(fov * Math.PI / 360);
var y1:Number = -y2;
var x1:Number = y1 * aspect;
var x2:Number = y2 * aspect;
return new Matrix3D(Vector.<Number>([
2 * near / (x2 - x1), 0, 0, 0, //x
0, 2 * near / (y2 - y1), 0, 0, //y
0, 0, (far + near) / (near - far), -2 * far * near/ (far - near), //z
0, 0, -1, 0 //w
]));
And i got the black screen. All i did was exchanging the matrix from the tutorial with this matrix. I tried to play with it for some time, but with no results. This is the matrix from the tutorial:
protected function perspectiveProjection(fov:Number=90,
aspect:Number=1, near:Number=1, far:Number=2048):Matrix3D {
var y2:Number = near * Math.tan(fov * Math.PI / 360);
var y1:Number = -y2;
var x1:Number = y1 * aspect;
var x2:Number = y2 * aspect;
var a:Number = 2 * near / (x2 - x1);
var b:Number = 2 * near / (y2 - y1);
var c:Number = (x2 + x1) / (x2 - x1);
var d:Number = (y2 + y1) / (y2 - y1);
var q:Number = -(far + near) / (far - near);
var qn:Number = -2 * (far * near) / (far - near);
return new Matrix3D(Vector.<Number>([
a, 0, 0, 0,
0, b, 0, 0,
c, d, q, -1,
0, 0, qn, 0
]));
}
Notice that the first and the second rows are the same.