我尝试使用打开的文件对话框加载 3d 模型,因此单击按钮我可以选择一个 .obj 文件并显示它:
Model3DGroup groupLoad = HelixToolkit.Wpf.ModelImporter.Load("C:....");
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.Load(string,Dispatcher,bool)”需要对象引用
我已经添加了这个:
var importer = new HelixToolkit.Wpf.ModelImporter();
var groupLoad = importer.Load("C:....");
任何想法,这里可能有什么问题?
相关分类