逆透视
如何撤消透视投影(在 Direct3D 中)对下图中指向的项目的影响。我希望它看起来像一个矩形横幅(摆脱可见的梯形效果)。
设置视图矩阵,相机位于 (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).
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无需将盒子与轴对齐,只需调整它,使其与相机视图方向平齐即可。指向物品正面的法线向量应直接指向相机。我认为 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.