在 WPF 中显示 3D 模型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3127753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Displaying 3D models in WPF
提问by adrin
I would like to display a 3D model in a WPF application (the model is prepared in an external tool such as blender). What is the best practice? Are there any tools to facilitate this? How about rotation/transform performance?
我想在 WPF 应用程序中显示 3D 模型(该模型是在搅拌机等外部工具中准备的)。最佳做法是什么?是否有任何工具可以促进这一点?旋转/变换性能如何?
回答by Sergey Orlov
Good question! The result-answer is depending from your goals.
好问题!结果答案取决于您的目标。
- Approach. You are in interest to put some .3ds(.obj,..) model object as stationary part of your scene without any interactive transformations (moving, scaling and so on). This approach is for simple playing (learning WPF3D) as a rule
- Approach. You are thinking to have full interactive part with support any WPF3D transformations within your Viewport3D. This approach is for rich 3D scene manipulations in professional application as a rule.
- 方法。您有兴趣将一些 .3ds(.obj,..) 模型对象作为场景的静止部分,而无需任何交互式转换(移动、缩放等)。这种方法是为了简单的播放(学习WPF3D)作为规则
- 方法。您正在考虑在 Viewport3D 中拥有支持任何 WPF3D 转换的完整交互部分。这种方法通常用于专业应用中丰富的 3D 场景操作。
There are relatively many tools for solve this task, but there is no any case universal solution. There are two troubles to do this task:
解决这个任务的工具比较多,但没有任何情况下通用的解决方案。做这个任务有两个麻烦:
- Incompatible formats between tools. For example, one tool creates .3ds(.obj,..) model, but second tool for translating it into .xaml (reading .3ds, .obj, ...) do not understand this model.
- The model you are prepared in professional tool like 3DMax, ...not seems so fine in WPF3D.
- 工具之间的格式不兼容。例如,一个工具创建 .3ds(.obj,..) 模型,但将其转换为 .xaml 的第二个工具(读取 .3ds, .obj, ...)不理解此模型。
- 您在 3DMax 等专业工具中准备的模型,...在 WPF3D 中似乎不太好。
Moreover it will be very good to change materials in model by the compatible (for further adequate WPF presentation) way.
此外,通过兼容(为了进一步充分的 WPF 演示)方式更改模型中的材料将是非常好的。
Be ready experimenting many times for best results... It seems that you are about 2 point - Approach. So, best tool for reading .3ds, .obj file isHelix 3D Toolkit
准备好多次尝试以获得最佳结果......似乎你大约是 2 点 - 方法。 因此,阅读 .3ds、.obj 文件的最佳工具是Helix 3D Toolkit
Recipe is very simple. For example, in VB
食谱很简单。例如,在 VB 中
Dim CurrentHelix3DSStudioReader As New StudioReader()
Dim MyToyModel3DGroup as Model3DGroup = CurrentHelix3DSStudioReader.Read("MyToy.3ds")
Or
或者
Dim CurrentHelixObjReader As New ObjReader()
Dim MyToyModel3DGroup as Model3DGroup = CurrentHelixObjReader.Read("MyToy.obj")
Best tool for manipulation .3ds, .obj, ... models including saving in .xaml is Deep Exploration. My sample in WPF 3D scene. Fast full managed object
操作 .3ds、.obj、... 模型(包括保存在 .xaml 中)的最佳工具是 Deep Exploration。我在 WPF 3D 场景中的示例。快速全托管对象
回答by Kris Erickson
Zam3d iswas a great tool for converting 3D Models into Xaml, but it looks like Electric Rain has gone defunct, you may be able to find a copy somewhere by Googling for it. I highly recomend Petzold's book 3D Programming for Windows. There are also a ton of tutorials online, I would google for some modern ones.
Zam3d是将 3D 模型转换为 Xaml 的好工具,但看起来 Electric Rain 已经不复存在了,您可以通过谷歌搜索在某处找到副本。我强烈推荐 Petzold 的书3D Programming for Windows。网上也有很多教程,我会谷歌搜索一些现代教程。
回答by Ievgen Naida
You can download trial version of 3dsmax and convert you model by Xaml exporter for 3D Studio Maxthis tool helps me a lot.
您可以下载 3dsmax 的试用版并通过Xaml 导出器为 3D Studio Max转换模型, 此工具对我有很大帮助。
回答by HHenn
You can import and convert OBJ-Files to XAML using "Blend for Visual Studio" please take a look here:
您可以使用“Blend for Visual Studio”将 OBJ 文件导入和转换为 XAML,请看这里: