逆透视

发布于 2024-11-27 12:59:09 字数 300 浏览 2 评论 0原文

如何撤消透视投影(在 Direct3D 中)对下图中指向的项目的影响。我希望它看起来像一个矩形横幅(摆脱可见的梯形效果)。

example

设置视图矩阵,相机位于 (0.0f, 0.8f, 2.5f),指向 (0, 0 , 0) 并且所指向的项目与 x 轴平行绘制。

我尝试用正交投影矩阵绘制该项目,但是我一直坚持如何在透视时找出它的屏幕坐标,以便在正交投影中绘制时事物排列起来。这是动画的一部分,其中该项目在绕 y 轴旋转时成为焦点。

How can I undo the effects of perspective projection (in Direct3D) on the item pointed to in the image below. I want it to look like a rectangular banner (get rid of the trapezoid effect visible).

example

The view matrix is setup with the camera at (0.0f, 0.8f, 2.5f) pointing at (0, 0, 0) and the item pointed to is drawn parallel with the x axis.

I've tried to draw that item with an orthogonal projection matrix, however I'm stuck on how to find out the screen coordinates of it when in perspective so things line up when being drawn in orthogonal projection. This is part of an animation in which that item comes into focus as they are rotating around the y axis.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

似最初 2024-12-04 12:59:09

您无需将盒子与轴对齐,只需调整它,使其与相机视图方向平齐即可。指向物品正面的法线向量应直接指向相机。我认为 Direct3D 有一个 LookAt 函数,您可以使用它来实现此目的。

您不需要弄乱投影矩阵,除非您还想摆脱距离缩放。

Rather than aligning the box with the axes, you just need to adjust it so that it's flat on to the camera view direction. The normal vector pointing out the front of the item should point directly at the camera. I think Direct3D has a LookAt function which you can use for this.

You don't need to mess with the projection matrix, unless you also want to get rid of the distance scaling.

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