Daily Tip: How to import 3D model to WPF from 3D Max

31 במרץ 2009

I want to present very useful feature “XAML exporter for 3D Studio Max”. This feature contains number of MAX-Script files with code that allows exporting 3D scenes from 3D Studio Max to XAML files. “Max2Xaml” Project on Codeplex website: http://max2xaml.codeplex.com.

I’ll try to present a simple guide for this feature with some useful example.

Software requirements for this guide: 3D Studio Max 2007 or later (I use 3D Studio Max 2009), Microsoft Expression Blend 2.0 (Final Release).
SDK and Framework requirements: Microsoft .Net 3.0 or 3.5.

Let’s start:

(1) Download ZIP File from here and extract it to some directory on your hard drive.

image001

(2) Open/build scene with 3D objects in 3ds Max.

image002

(3) Ensure that each object has definition of material (this required by “Max2Xaml”).

image003

(4) Go to “MAXScript” sub-menu and click on “Run Script … ”.

image004

(5) Select “Main.ms” script file from extracted directory and click on “Open”.

image005

(6) Click on “Export” in dialog-box.

image006

(7) Type file name (with “xaml” extension) and click on “Save”.

image007

(8) This is “MAXScript” Editor window with XAML output of current scene:

image008

The output contains XAML code for “ResourceDictionary” that contains data for definitions of all scene models/objects,

image009

materials,

image010

and other data.

image011

(9) Open/create new WPF project in Blend.

image012

(10) Add existing item to project tree.

image013

(11) Selected created XAML file and click “Open”.

image014

(12) After addition of new resource dictionary merge it with resource dictionary in target window.

image015

(13) Add “Viewport3D” object into main grid (this object is used to display 3D scenes/objects).

image016

(14) Added “Viewport3D” already contains default camera. Add “ModelVisual3D” objects for each 3D model from the scene.

image017

(15) Link each model’s geometry to resource from merged dictionary.

image018

image019

(16) Material of each model can be linked to resource from merged dictionary.

image020

(17) Probably we’ll not see the 3D models.

image021

(18) We can adjust camera’s position and other parameters, and then we’ll see the models.

image022

(19) If models are black or still invisible, add new “ModelVisual3D” with light (can be “DirectionalLight”) that will “radiate” on scene objects.

image023

(20) After some adjustments of camera and light we’ll see imported models from 3ds Max.

image024

The example project with code can be downloaded from hereimage025.

Summary: Some WPF projects require complex 3D models in 3D scenes, these complex models can be made in 3D modeling software like 3ds Max and imported into WPF. This post shows how to port 3D models from 3ds Max to WPF. See next post(s) with guide for porting 3D models from “Blender” to WPF.

PS
I’m not responsible for any damage that may be caused by using this post or its content. Any materials in this post were provided AS IS without any changes and other meanings.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

17 comments

  1. Steve K.1 באפריל 2009 ב 11:49

    You've kicked a really good thing!
    I've been looking for this feature for a long time.
    Many Thanks 🙂

    Reply
  2. flucrallusy4 באפריל 2009 ב 3:11

    Great site this blogs.microsoft.co.il and I am really pleased to see you have what I am actually looking for here and this this post is exactly what I am interested in. I shall be pleased to become a regular visitor 🙂

    Reply
  3. Shooneenig10 באפריל 2009 ב 21:56

    great site this blogs.microsoft.co.il great to see you have what I am actually looking for here and this this post is exactly what I am interested in. I shall be pleased to become a regular visitor 🙂

    Reply
  4. TheCat2 במאי 2009 ב 17:55

    Hi, Max!
    Thank you for suggestion.
    Can you post a simple but detailed example,
    done using Kit3D INSTEAD OF WPF?

    Using Kit3D, I have discovered that there are some little subtle bugs/problems with XAML markup.
    I'm not sure I can simply copy and paste this code, "as is".
    Thanks in advance
    🙂

    Reply
  5. Maxim3 במאי 2009 ב 0:52

    Hi "TheCat",
    The "Kit3D" doesn't support (yet) the XAML, means that all programming can be done (for now) in code-behind (C# or VB.Net).
    You're right, you can't copy-paste the code for WPF to Silverlight-Kit3D. I hope I'll get some time to write post about porting 3ds models into "Kit3D", that I do for now: I copy mesh-geometry data (Positions, Texture Coords and other stuff) from output-XAML file into some resource dic. and compile them into XAP pachage, see my future post about this issue.
    Here some example of "Kit3D" using 3ds models: http://www.segevsystems.tv/test/handball/ .

    Reply
  6. Helge6 במאי 2009 ב 14:19

    It seems not to work with Multi/Sub Materials. It says "Unknown property diffuseMap".

    Reply
  7. boy9 בנובמבר 2009 ב 11:39

    hello

    why my model for export Xaml is error

    "Type error : call need function or class got : undefined"

    my mail Supachoke_boy@hotmail.com

    Reply
  8. david stubbs22 בדצמבר 2009 ב 15:16

    I've found exporting a scene from 3ds Max as an OBJ (Maya Preset Export settings) and then importing it into Blend to be very competent. Blend has an inbuilt Obj->XAML converter which works pretty much on par with any exporter I've seen.

    Reply
  9. Maxim23 בדצמבר 2009 ב 22:38

    david stubbs,
    of course you can import 3d models by using OBJ files.
    months ago i uploaded a post about this option: http://blogs.microsoft.co.il/blogs/maxim/archive/2009/05/24/daily-tip-how-to-import-3d-model-to-wpf-in-couple-clicks.aspx
    🙂

    Reply
  10. Robinson15 בינואר 2010 ב 21:14

    What about animations? Actually, I've got an animation that keys in a bend modifier, as well as rotation. Is there any way I can `flatten' the animation in 3ds, so that it's just changing mesh vertices and then export the animation as xaml? I'm presuming that the xaml converter doesn't know anything about modifiers!

    Reply
  11. cue16 באפריל 2010 ב 9:59

    Please someone help me solve this problem. I got this while exporting.

    "–Unknown property "name" in undefined"

    another error when i export the second time.
    "–Type error: closeRolloutFloater requires RolloutFloater, got :undefined"

    Please!

    Reply
  12. oqoelksr@gmail.com24 באוקטובר 2012 ב 1:19

    Appreciate your this content. I tried this specific and yes it beautifully worked well.

    Reply
  13. Sidharth_P17 בדצמבר 2012 ב 2:22

    Really great article thanks a lot… keep posting..!!

    Reply
  14. Lambert30 בדצמבר 2012 ב 4:32

    One place that you can check would be on the internet. This episode introduces three people who
    are embracing creative solutions to the looming shortage of drinking water
    – be it desalinating the ocean, catching rainwater or cleaning up our rivers.

    Chlorine and volatile organic compounds, or "VOCs" are not removed
    in steam distillation, because they vaporize at a lower temperature than
    water does, and they end up in the condensation chamber along with the steam.

    Reply
  15. Mclendon13 בינואר 2013 ב 1:29

    Hi to every body, it's my first pay a quick visit of this web site; this website carries amazing and actually good stuff for readers.

    Reply
  16. Matheson5 בפברואר 2013 ב 11:39

    Find all of your favorite designs and designers only at Lollipop – Moon.
    This day, minimum of 100 lamps and maximum of 1 lakh lamps are lighted.

    Favorite thing about the Holidays.

    Reply