I thought the concepts of the near clipping plane and the view plane(or projection plane) are unified in DirectX's world before?but they're not actually. The view plane are set to z = 1 while the near clipping plane are adjustable. So it's possible to adjust the near clipping plane while keeping the view plane unmoved.
I searched MSDN for the functions that can be used for generating projection matrix, there are two of them:
The first one is commonly used. The second one is which I am using because the point of view is movable in my projection model so the matrix will be offcenter.
Details as follows:
D3DXMATRIX* D3DXMatrixPerspectiveFovLH(
_Inout_ D3DXMATRIX *pOut,
_In_ FLOAT fovy,
_In_ FLOAT Aspect,
_In_ FLOAT zn,
_In_ FLOAT zf
);
D3DXMATRIX* D3DXMatrixPerspectiveOffCenterLH(
_Inout_ D3DXMATRIX *pOut,
_In_ FLOAT l,
_In_ FLOAT r,
_In_ FLOAT b,
_In_ FLOAT t,
_In_ FLOAT zn,
_In_ FLOAT zf
);
These two functions compute the returned matrices as shown:
- D3DXMatrixPerspectiveFovLH
xScale 0 0 0
0 yScale 0 0
0 0 zf/(zf-zn) 1
0 0 -zn*zf/(zf-zn) 0
where:
yScale = cot(fovY/2)
xScale = yScale / aspect ratio
Parameter zn represents the position of the near clipping plane,while FOV is determined by fovy.
- D3DXMatrixPerspectiveOffCenterLH
2*zn/(r-l) 0 0 0
0 2*zn/(t-b) 0 0
(l+r)/(l-r) (t+b)/(b-t) zf/(zf-zn) 1
0 0 zn*zf/(zn-zf) 0
In this matrix, zn determines both the near clipping plane and FOV. To keep FOV unchanged while zn is changing, I have to adjust the size of the view volume at the same time.
Tell me if I am wrong.
Thanks. That's really cool. How are you tracking the eye?
Well?I use a Kinect to track the eye.