問題描述
如何在WPF
中查看3D
模型的正面?
How to look at the front of 3D
Model in WPF
?
我很困惑為 LookDirection 設(shè)置 X Y Z.
I am confused to set X Y Z for LookDirection.
我不知道當我設(shè)置 xyz 時會發(fā)生什么,我不知道相機在看哪里.對于 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?
另外請說明如何設(shè)置 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
設(shè)置為例如 (x=1, y=0, z=10) 時,相機位置會發(fā)生如下變化:
When you set camera.Position
to for example (x=1, y=0, z=10) then camera position changes like this:
因此,相機會稍微向右移動,因此您會在視圖的左側(cè)看到您的形狀.
as a result, camera moves a little to the right and therefore you will see your shape at the left side of the view.
現(xiàn)在,如果 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:
重要修改:
根據(jù) 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
應(yīng)該是:
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
設(shè)置為 (-0.5,1,0) 會導致相機逆時針旋轉(zhuǎn):
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.
這篇關(guān)于使 Camera LookDirection 看正面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!