我是Helix的新手,到目前为止我很喜欢它,我正在构建一个WPF应用程序,它可以在面板内加载Helix视口窗口,然后我通过WPF中的创建按钮实例化一个立方体(CubedVisual3D(,它会创建立方体,但当我点击或拖动/移动它时,它不会移动。我该怎么做?最佳方法?示例图像
private void Helix_ViewPort_MouseDown(object sender, MouseButtonEventArgs e)
{
Console.WriteLine("Mouse down.");
Point mousePos = e.GetPosition(MyViewPort);
PointHitTestParameters hitParams = new PointHitTestParameters(mousePos);
HitTestResult result = VisualTreeHelper.HitTest(MyViewPort, mousePos);
RayMeshGeometry3DHitTestResult rayMeshResult = result as
RayMeshGeometry3DHitTestResult;
if (rayMeshResult != null)
{
MeshGeometry3D mesh = new MeshGeometry3D(); mesh.Positions.Add(rayMeshResult.MeshHit.Positions[rayMeshResult.VertexIndex1]);
mesh.Positions.Add(rayMeshResult.MeshHit.Positions[rayMeshResult.VertexIndex2]);
mesh.Positions.Add(rayMeshResult.MeshHit.Positions[rayMeshResult.VertexIndex3]);
mesh.TriangleIndices.Add(0);
mesh.TriangleIndices.Add(1);
mesh.TriangleIndices.Add(2);
GeometryModel3D marker = new GeometryModel3D(mesh, new DiffuseMaterial(Brushes.Blue));
}
Console.WriteLine(result);
}
请参阅操纵器演示。helixtoolkit github源代码下有许多演示。