C#,WPF - HelixToolkit相机操作

时间:2016-11-24 04:47:04

标签: c# wpf

我在WPF项目中使用Helix-toolkit绘制3D线条。 我已经做的是:

  1. 将名称空间添加到WPF:xmlns:Helix="http://helix-toolkit.org/wpf"

  2. 将控件添加到WPF:<Helix:HelixViewport3D x:Name="HelixViewport3D" />

  3. 在C#中将3D线添加到Helix:Point3DCollection _points; LinesVisual3D _lines = new LinesVisual3D(); _lines.Points = _points; HelixViewport3D.Children.Add(_lines);

  4. 缩放和更改相机位置:   我使用以下代码进行缩放:HelixViewport3D.ZoomExtents(1000);

    我使用以下代码更改了视图:HelixViewport3D.CameraController.CameraUpDirection = new Vector3D(0, 0, 1); HelixViewport3D.CameraController.CameraTarget = new Point3D(0, 70, 0);

  5. 现在我想在我的项目中添加一些按钮,这些按钮将提供固定的查看命令,如TopView,BottomView,FrontView,BackView,LeftView,RightView等。

    按钮将如下所示

    enter image description here

    但我对HelixViewport3D.CameraController.CameraUpDirectionHelixViewport3D.CameraController.CameraLookDirectionHelixViewport3D.CameraController.CameraTarget

    的参数感到困惑

    如何从C#中提供那些固定视图命令。

1 个答案:

答案 0 :(得分:0)

这些是我对视图的SharpGL相机设置

<Camera:LookAtCamera x:Key="CameraLeft" Position="-10, 0, 0" Target="0, 0, 0" UpVector="0, 1, 0" />
<Camera:LookAtCamera x:Key="CameraRight" Position="10, 0, 0" Target="0, 0, 0" UpVector="0, 1, 0" />
<Camera:LookAtCamera x:Key="CameraTop" Position="0, 10, 0" Target="0, 0, 0" UpVector="0, 0, -1" />
<Camera:LookAtCamera x:Key="CameraBottom" Position="0, -10, 0" Target="0, 0, 0" UpVector="0, 0, 1" />
<Camera:LookAtCamera x:Key="CameraBack" Position="0, 0, -10" Target="0, 0, 0" UpVector="0, 1, 0" />
<Camera:LookAtCamera x:Key="CameraFront" Position="0, 0, 10" Target="0, 0, 0" UpVector="0, 1, 0" />

我刚刚将helixtoolkit放在一边并开始使用SharpGL,但这些Camera Positions,Targets和UpVectors应该有所帮助。