物体在 3D 平面上的透视投影
想象一下虚拟人和物体之间有一个平面。该对象是一个具有一定 xyz 缩放和旋转的盒子。飞机就像一扇玻璃窗。人通过平面观察物体。摄像机从不同的角度观察整个场景。
我想按照人们看到的方式将物体的轮廓绘制到平面上,就好像他在窗户上绘制另一侧物体的轮廓一样。
如何变换对象,使其顶点正确地位于平面上?
我知道如何进行点到平面的正交投影,但在这种情况下我想我需要透视投影。当物体移得更远时,其投影也需要根据观看者的视角调整大小和位置。
我想只要有人解释我需要采取的步骤,我就能弄清楚代码。
Imagine there is plane in between a virtual person and an object. The object is a box with a certain xyz scaling and rotation. The plane is like a glass window. The person is looking at the object through the plane. The camera is looking at the whole scene from a different angle.
I would like to draw the outline of the object onto the plane the way the person would see it, as if he were drawing on the window the outline of the object on the other side.
How can I transform the object so that its vertices end up on the plane correctly?
I know how to do a orthogonal projection of a point to a plane, but in this case I need perspective projection I guess. When the object moves further away its projection also needs to be adjusted in size and position according to the viewers perspective.
I think I can figure out the code if only someone would explain the steps I need to take.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建以人眼为中心的 3D 坐标系。编写函数将点从一个系统转换到另一个系统。您可能还有另一个系统与该对象绑定。请记住,创建系统只不过是在其他默认坐标系中写入系统原点和轴的坐标。例如:
System_ human_eye = {Point3f Origin(10, 0, 3), Xaxis(1, 0, 0), Yaxis(0, 1, 0), Zaxis(0, 0, 1) }
在人眼系统中,找到物体顶点坐标和平面法线。平面方程为p.normal=D,其中D是到平面的距离,p是平面点,法线是平面法线。人眼到顶点的光线为k*[x,y,z];当 k 改变时,你沿着射线行进。现在你需要做的就是沿着光线行进直到它与平面相交,即
k*[x, y, z] 。正常=D;
找到k,恢复点p=k*[x, y, z],这将给出射线与平面的交点;
将人眼系统的所有交集变换到相机系统;
Create a 3D coordinate system centered on human’s eye. Write function to transform points from one system to another. You might also have another system tied to the object. Remember that creating a system is nothing but writing coordinate of system origin and axes in some other default coordinate system. For example:
System_human_eye = {Point3f Origin(10, 0, 3), Xaxis(1, 0, 0), Yaxis(0, 1, 0), Zaxis(0, 0, 1) }
In the human eye system, find coordinates of the object vertices and plane normal. Plane equation is p.normal=D, where D is the distance to the plane, p is plane point and normal is plane normal. Ray from human eye to the vertex is k*[x, y, z]; as k changes you travel along the ray. All you need to do now is to travel along the ray till it intersect plane, that is
k*[x, y, z] . normal = D;
find k, restore point p=k*[x, y, z] and this will give you the intersection of the ray with the plane;
Transform all the intersections from the human's eye system to the camera system;
一般来说,您想要进行透视投影。
然而,这涉及大量的理论和数学,你必须头脑清楚。如果你想做一些更简单的事情,对于对象中的每个顶点,只需计算将眼睛连接到顶点的线,然后将其与平面相交。
In general, you want to do a perspective projection.
However, that involves a chunk of theory and math you have to get your head around. If you want to do something simpler, for every vertex in your object just calculate the line that joins the eye to the vertex, then intersect it with the plane.