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

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

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.

Comments

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

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

# Topics about Models » Archive » Daily Tip: How to import 3D model to WPF from 3D Max - Maxim

Pingback from  Topics about Models  » Archive   » Daily Tip: How to import 3D model to WPF from 3D Max - Maxim

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

Wednesday, April 01, 2009 11:49 AM by Steve K.

You've kicked a really good thing!

I've been looking for this feature for a long time.

Many Thanks :)

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

Saturday, April 04, 2009 3:11 AM by flucrallusy

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 :)

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

Friday, April 10, 2009 9:56 PM by Shooneenig

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 :)

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

Saturday, May 02, 2009 5:55 PM by TheCat

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

:-)

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

Sunday, May 03, 2009 12:52 AM by Maxim

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: www.segevsystems.tv/.../handball .

# Daily Tip: How to import 3D model to WPF from Blender

Tuesday, May 05, 2009 12:47 AM by Maxim

In resumption to my previous post “ How to import 3D model to WPF from 3D Max ” I want to present the

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

Wednesday, May 06, 2009 2:19 PM by Helge

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

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

Monday, November 09, 2009 11:39 AM by boy

hello

why my model for export Xaml is error

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

my mail Supachoke_boy@hotmail.com

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

Tuesday, December 22, 2009 3:16 PM by david stubbs

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.

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

Wednesday, December 23, 2009 10:38 PM by Maxim

david stubbs,

of course you can import 3d models by using OBJ files.

months ago i uploaded a post about this option: blogs.microsoft.co.il/.../daily-tip-how-to-import-3d-model-to-wpf-in-couple-clicks.aspx

:)

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

Friday, January 15, 2010 9:14 PM by Robinson

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!

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

Friday, April 16, 2010 9:59 AM by cue

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!

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: