Make Camera LookDirection look front face(使 Camera LookDirection 看正面)
问题描述
如何在WPF
中查看3D
模型的正面?
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
不同(PrespectiveCamera
的前属性是 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.
这篇关于使 Camera LookDirection 看正面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使 Camera LookDirection 看正面
基础教程推荐
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30