Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying 3D models in WPF

Tags:

wpf

3d

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?

like image 286
adrin Avatar asked Jun 27 '10 15:06

adrin


3 Answers

Good question! The result-answer is depending from your goals.

  1. 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
  2. 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:

  1. 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.
  2. 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

My sample in WPF 3D scene. Fast full managed object

like image 187
Sergey Orlov Avatar answered Nov 19 '22 19:11

Sergey Orlov


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.

like image 14
Kris Erickson Avatar answered Nov 19 '22 18:11

Kris Erickson


You can import and convert OBJ-Files to XAML using "Blend for Visual Studio" please take a look here:

alternative-to-zam-3d-editor

like image 1
HHenn Avatar answered Nov 19 '22 17:11

HHenn