如何在 SlimDX 中取消投影

发布于 2024-10-30 20:31:33 字数 696 浏览 4 评论 0原文

我是游戏编程新手,也是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

誰ツ都不明白 2024-11-06 20:31:35

我不熟悉 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文