pipeline:
建模空间--(世界变换)--世界空间--(视见变换)--摄像头空间--(投影变换)--投影空间。
关于投影变换:
D3DXMatrixPerspectiveFovLH 函数
D3DXMATRIX *WINAPI D3DXMatrixPerspectiveFovLH(
D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf );
Remarks
The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXMatrixPerspectiveFovLH function can be used as a parameter for another function.
This function computes the returned matrix as shown.
w 0 0 0 0 h 0 0 0 0 zf/(zf-zn) 1 0 0 -zn*zf/(zf-zn) 0 where: h is the view space height. It is calculated from h = cot(fovY/2); w is the view space width. It is calculated from h = w / Aspect
-------------------------------------------
推导一个摄像机空间的点(x,y,z,1)最终要变成投影空间的点(x',y',z',1)=(ax,by,cz,1) 而a,b,c的值就是通过上面的计算矩阵计算出来的。
hy/z=cot(fovY/2)y/z=(z/y1)y/z=y/y1(此y/y1是缩放比,即原vertex要投影在近平面时,应该缩放的系数。)