【发布时间】:2012-12-19 15:33:23
【问题描述】:
我有一个正交投影,我尝试从屏幕空间中取消投影一个点。
以下是视图和投影矩阵:
var w2 = ScreenWidthInPixels/2;
var h2 = ScreenHeightInPixels/2;
view = Matrix.LookAtLH(new Vector3(0, 0, -1), new Vector3(0, 0, 0),
Vector3.UnitY);
proj = Matrix.OrthoOffCenterLH(-w2, w2, -h2, h2, 0.1f, 10f);
这是我取消投影点p 的方法,该点以屏幕像素为单位:
var m = Vector3.Unproject(p, 0, 0, ScreenWidthInPixels, ScreenHeightInPixels,
0.1f, 10f, // znear and zfar
view *proj);
我的代码不起作用,矩阵m 仅包含Nan。
当我尝试反转 view * proj 时,我得到一个只有零的矩阵。
所以我怀疑我的问题与正交投影矩阵有关。
这是我的问题:
- 这个问题是否是由于 OrthoOffCenterLH 投影中的大值导致的下溢引起的?
- 我必须为
x,y,width,height在Unproject(...)中传递哪些参数? -
Unproject(...)中的minZ和maxZ参数有什么意义? - 我在
Unproject(...)中传递的p.Z重要吗?
【问题讨论】:
标签: 3d directx directx-11 sharpdx direct3d11