c# - 如何使用 Helix Toolkit 在 WPF 中导入 3D 模型?

标签 c# wpf 3d-modelling helix-3d-toolkit

我正在尝试使用 Helix Toolkit 导入 3D 模型。我不知道该怎么做。是否有任何关于使用此工具包导入 3D 模型的在线指南,或者是否有除 Helix 之外的其他更简单的导入 3D 模型的方法。

问候

这是我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System;
using System.IO;
using System.Windows.Media.Media3D;


namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{

    public MainWindow()
    {
        InitializeComponent();
    }

    Model3DGroup group = HelixToolkit.Wpf.ModelImporter.Load(@"C:\Jack_Shephard\Jack_Shephard.obj");
     public static Model3DGroup Load(string path)
    {
        if (path == null)
        {
            return null;
        }

        Model3DGroup model = null;
        string ext = System.IO.Path.GetExtension(path).ToLower();
        switch (ext)
        {
            case ".3ds":
                {
                    var r = new HelixToolkit.Wpf.StudioReader();
                    model = r.Read(path);
                    break;
                }

            case ".lwo":
                {
                    var r = new HelixToolkit.Wpf.LwoReader();
                    model = r.Read(path);

                    break;
                }

            case ".obj":
                {
                    var r = new HelixToolkit.Wpf.ObjReader();
                    model = r.Read(path);
                    break;
                }

            case ".objz":
                {
                    var r = new HelixToolkit.Wpf.ObjReader();
                    model = r.ReadZ(path);
                    break;
                }

            case ".stl":
                {
                    var r = new HelixToolkit.Wpf.StLReader();
                    model = r.Read(path);
                    break;
                }

            case ".off":
                {
                    var r = new HelixToolkit.Wpf.OffReader();
                    model = r.Read(path);
                    break;
                }

            default:
                throw new InvalidOperationException("File format not supported.");
        }

        return model;
    }

}
}

最佳答案

他们的文档仍在构建中,但在查看他们的源代码时,您似乎想要 ModelImporter方法。它返回 Model3dGroup它的用法如下所示。

 Model3DGroup group = HelixToolkit.Wpf.ModelImporter.Load(@"Your path here");

关于c# - 如何使用 Helix Toolkit 在 WPF 中导入 3D 模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14295195/

相关文章:

c# - 使用反射将值类型设置为 null 时出现奇怪的行为,为什么?

c# - 如何为 WPF ListView 禁用 XAML 中的某些项目

使用 Obj 模型的 C++ 碰撞

xcode - 有没有办法在场景工具包中添加轮廓?

c# - 带有 OAuthBase.cs 的雅虎 Oauth API

c# - Ajax控件工具包中缺少文件 list 错误?

c# - 在 asp.net 中分块 FileUpload

.net - 您可以在 Windows 应用程序中使用 asp.net 成员(member)资格提供程序吗?

c# - 具有最近邻居的位图会导致撕裂

ios - 如何在 Vuforia 增强现实 iOS SDK 中使用 .obj 和 .mtl 文件加载 3d 模型