相机的位置取决于型号吗? [英] Camera position based on model size?
问题描述
在C#WPF中如何自动根据 3D模型 尺寸设置相机 位置 >。
in C# WPF how to automatically set camera Position based on 3DModel size.
例如,如果我加载较小型号的相机,位置应更近,而如果加载较大型号的相机位置则应更长。
For example if I load small model,position be closer and if I load large model camera position be longer.
我想从模型的各个侧面获取 Max 和 Min Point3D
。
What I thought was to get the Max and Min Point3D
from model from each side.
-通过X值查找最大和最小point3D。
-Find Max and Min point3D by X value.
-通过Y值查找最大和最小point3D。
-Find Max and Min point3D by Y value.
这是通过 foreach
循环遍历所有3D点来完成的。
this is done by foreach
loop through all 3D points.
现在我在边缘有4个点,但是如何计算相机位置?
Now I have 4 points at the edges, but how to calculate camera position?
是否有任何公式可以获取正确的位置,并为位置增加一些额外的长度?
Is there any formula to get the right position and the add some additional length to position?
推荐答案
所有取决于您使用的框架/库,但是我想您必须使用摄像机的FOV来计算宽和高gh相机可以在一定距离内看到。
All depends on the framework / library you're using, but I'd guess you'd have to use the camera's FOV to calculate how wide and high the camera can 'see' at a certain distance.
如果您看摄像机的示意图,则FOV是摄像机看到东西的角度。它可能是Camera对象的成员变量。将三角形一分为二将为您提供两个具有已知角度(1/2 FOV)的直角三角形。基本数学应该让您计算窗口的距离和大小。
If you look at the schematic of the camera, the FOV is the angle at which the camera sees stuff. It is probably a member variable of your Camera object. Splitting the triangle in two will give you two right triangles with a know angle ( 1/2 FOV ). Basic mathematics should let you calculate the distance and size of the viewwindow.
由于您已经有4个点,因此您已经知道 L(在示意图中)应该有多大
Since you already have 4 points you already know how big 'L' (in the schematic) should be.
这篇关于相机的位置取决于型号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!