使相机 LookDirection 看起来像正面 [英] Make Camera LookDirection look front face
问题描述
如何在WPF
中查看3D
Model的前端?
How to look at the front of 3D
Model in WPF
?
我很困惑为 LookDirection 设置 X Y Z.
I am confused to set X Y Z for LookDirection.
我不知道设置 xyz 时会发生什么,也不知道相机在看哪里.对于 UpDirection
,我不知道同样的事情.
I don't know what happens when I set xyz and I don't know where camera is looking at. I don't know the same thing for UpDirection
.
以下是我的相机属性:
camera.Position = new Point3D(100, 100, 150);
camera.LookDirection = new Vector3D(-100, -100, -100);
camera.UpDirection = new Vector3D(0, 0, 1);
问题是摄像头是从后面看的.模型如下图所示.
The problem is that camera is looking from behind. Model is shown like cube below.
如何让它看起来像正面?
How to make it look front face?
另外请解释如何设置xyz.我知道属性的作用,但我无法想象它们.
Also please explain how to set xyz. i know what properties do but i cant imagine them.
我认为 X 是从右到左.Y 是深度.Z 从上到下.
I think X is from right to left.Y is depth. Z is up to down .
推荐答案
想象一下,您在 3D 空间中移动头部而不是相机.然后 Camera.Position
指定您的头部所在的位置,Camera.LookDirection
确定您正在看的方向,Camera.UpDirection
显示你的头部方向.以下图片为您一清二楚.
Imagine, instead of a camera, you're moving your head around in 3D space. then Camera.Position
is specifying where your head is located, Camera.LookDirection
determines the direction you're looking at and Camera.UpDirection
shows the orientation of your head. the following pictures clear things up for you.
在第一张图片中,相机以 +Z 轴为中心,向下看 -Z 轴和您的形状:
In the first Image, Camera is centered on the +Z axis looking down to -Z axis and to your shape:
当您将 camera.Position
设置为例如 (x=1, y=0, z=10) 时,相机位置会像这样变化:
When you set camera.Position
to for example (x=1, y=0, z=10) then camera position changes like this:
因此,相机会向右移动一点,因此您将在视图的左侧看到您的形状.
as a result, camera moves a little to the right and therefore you will see your shape at the left side of the view.
现在,如果 camera.LookDirection
被更改为 (x=0, y=1, z=-1),那么相机只看点 (0,1,-1) 就像这个:
Now if camera.LookDirection
gets changed to say (x=0, y=1, z=-1), then camera simply looks at the point (0,1,-1) like this:
重要修改:
根据 DaveInCaz 的评论,LookDirection
与 LookAtPoint
不同(PreferiveCamera
的前一个属性,它是一个 Point3D
而不是Vector3D
).
Based on DaveInCaz's comment, LookDirection
is different from LookAtPoint
(former property of PrespectiveCamera
which was a Point3D
rather than
Vector3D
).
LookDirection
实际上等于观察点"减去相机位置".
这意味着在上图中,如果我们想让位于 (1,0,10) 的相机看点 (0,1,-1) 那么 LookDirection
应该是:
This means that in the above diagram, if we want the camera which is located in (1,0,10) to look at point (0,1,-1) then the LookDirection
should be:
(0,1,-1) - (1,0,10) = (-1,1,-11).
(0,1,-1) - (1,0,10) = (-1,1,-11).
最后,camera.UpDirection
确定相机顶部指向的位置.在下图中,将 camera.UpDirection
设置为 (-0.5,1,0) 会导致相机逆时针旋转:
And finally, camera.UpDirection
determines where the top of your camera points at. In the following picture, setting camera.UpDirection
to (-0.5,1,0) results in rotation of the camera counter clockwise:
我希望这些图片能让你明白.
I hope these pictures clear things up for you.
这篇关于使相机 LookDirection 看起来像正面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!