Displaying 3D models in WPF
I would like to display a 3D model in a WPF application (the model is prepared i开发者_如何学运维n an external tool such as blender). What is the best practice? Are there any tools to facilitate this? How about rotation/transform performance?
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.
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.
Moreover it will be very good to change materials in model by the compatible (for further adequate WPF presentation) way.
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 is Helix 3D Toolkit
Recipe is very simple. For example, in 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
Zam3d is was 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.
You can import and convert OBJ-Files to XAML using "Blend for Visual Studio" please take a look here:
alternative-to-zam-3d-editor
You can use 3dsmax and convert your model by Xaml exporter for 3D Studio Max.
精彩评论