如何在 SlimDX 中取消投影
我是游戏编程新手,也是 DirectX 和 DirectX 新手。苗条DX。目前,我正在将 MDX 代码转换为 SlimDX 代码,但遇到了一个无法在 SlimDX 文档中找到的问题。我正在尝试“取消投影”矢量代码,如下所示:
MDX 代码:
Vector3 p1 = new Vector3(x, y, device.Viewport.MinZ);
p1.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World);
我转换的 SlimDX 代码如下:
Vector3 p1 = new Vector3(x, y, device.Viewport.MinZ);
p1 = Vector3.Unproject(p1, device.Viewport.X, device.Viewport.Y, device.Viewport.Width,
device.Viewport.Height, device.Viewport.MinZ, device.Viewport.MaxZ,
device.GetTransform(TransformState.World));
使用上述 SlimDX 代码我无法获得正确的结果,请就此提出建议,即如何才能我在 SlimDX 中取消投影矢量。
I am new to game programming as well as new to DirectX & SlimDX. Currenty I am converting a MDX code to SlimDX code and I got stuck into an issue which I am unable to find out in the SlimDX documentation. I am trying to "Unproject" a vector code for which is as follows:
MDX code:
Vector3 p1 = new Vector3(x, y, device.Viewport.MinZ);
p1.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World);
SlimDX code which I converted is as follows:
Vector3 p1 = new Vector3(x, y, device.Viewport.MinZ);
p1 = Vector3.Unproject(p1, device.Viewport.X, device.Viewport.Y, device.Viewport.Width,
device.Viewport.Height, device.Viewport.MinZ, device.Viewport.MaxZ,
device.GetTransform(TransformState.World));
Using the above SlimDX code I am unable to get the correct results, please advice me on this i.e. how can I Unproject the vector in SlimDX.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不熟悉 SlimDX,但在 MDX 情况下,您将世界、视图和投影矩阵传递给 Unproject 函数(正如您应该的那样),而在第二个示例中,您仅传递世界矩阵。假设 Vector3.Unproject 函数仅采用一个矩阵作为参数,请尝试传递 World * View * Projection 的乘积。
I'm not familiar with SlimDX, but in the MDX case you're passing the world, view, and projection matrices to the Unproject function (as you should) and in your second example you're only passing the world matrix. Assuming that Vector3.Unproject function only takes one matrix as an argument, try passing the product of World * View * Projection instead.