使 Camera LookDirection 看正面

Make Camera LookDirection look front face(使 Camera LookDirection 看正面)
本文介绍了使 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 的评论,LookDirectionLookAtPoint 不同(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 看正面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to MOQ an Indexed property(如何最小起订量索引属性)
Mocking generic methods in Moq without specifying T(在 Moq 中模拟泛型方法而不指定 T)
How Moles Isolation framework is implemented?(Moles Isolation 框架是如何实现的?)
Difference between Dependency Injection and Mocking Framework (Ninject vs RhinoMocks or Moq)(依赖注入和模拟框架之间的区别(Ninject vs RhinoMocks 或 Moq))
How to mock Controller.User using moq(如何使用 moq 模拟 Controller.User)
How do I mock a class without an interface?(如何模拟没有接口的类?)