简体   繁体   English

视口3D WPF C#-几个问题

[英]Viewport 3D WPF C# - Several Questions

what is the best way to position the Camera in a way that i can see what i paint in a certain region? 以某种方式可以看到我在某个特定区域绘制的图像的最佳方式是什么? pe I'm painting a rectangle at around 300,400,2200. pe我在300,400,2200左右绘制一个矩形。 Where do i have to place the camera and which view do i have to set so that everything fits "in"? 我必须在哪里放置相机以及必须设置哪个视图以使所有内容都适合“放入”? Is there a trick or a special method or do i have to try it out with different camera positions? 有技巧或特殊方法,还是我必须在不同的相机位置尝试一下?

There is no standard function that will position the camera this way because there are many options (think of different sides and rotations) 没有标准功能可以像这样定位相机,因为有很多选项(考虑不同的侧面和旋转角度)

A trick you could use is: 您可以使用的技巧是:

  1. Take the center of the MeshGeometry3D by using the Bounds property and add the normal vector several times to position the Camera. 通过使用Bounds属性,将MeshGeometry3D的中心作为中心,并多次添加法线向量以定位Camera。
  2. Then use the normal vector of the plane, invert it and use it as the LookDirection for the camera. 然后,使用平面的法向矢量,将其反转并将其用作相机的LookDirection。

How far you need to move the camera depends on the view angle of the camera. 您需要将相机移动多远取决于相机的视角。 It can be calculated. 可以计算出来。 Let me know if you want to know how (it will take me a little extra time) 让我知道您是否想知道(这将花费我一些额外的时间)

More information can be found here too 在这里也可以找到更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM