Displaying 3D models in WPF - wpf

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?

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.

Related

WPF 3D Tutorial and example for Blend

i'm attempting to create a 3D dice control .
i'm having a hard time finding good tutorial's or source code on WPF 3D with 3D animations
preferably for Blend .
additionally are there any known tools for creating 3D templates with the corresponding triggers and animations which i could use to create a clickable interactive dice for my application .
though this question is quite general i still think it appropriate since materials on this particular subject seems to be hard to come by .
thanks in advance.
A while back i found a very good example here And also, you might want to see helix toolkit it works independent of WPF

How to Design a WPF Flow Document

Im making an wpf application and i need to generate reports and then to print them. I am using CodeReason.Reports library but it is very dificult to me to design the reports with out a designer.
Any one knows if there exist any Flow Document designer, or if there is any way to design it from blend?
Thanks
I don't know the library you are talking about, but I used WPF for creating some report, let's say a minimal report engine, so I think I can give some suggestion to you.
First, learn XAML. Visual studio has a good designer, but I use it just to see what's happening: writing XAML with the good Visual Studio intellisense is much more productive. I can't suggest how to operate with your lib, but with my strategy the document pages are wired by the engine in code, content are produced by user controls: they just live very well in VS designer. I also used an MVVM library to develop in a an code free view way.
So what I learn in y WPF experience: it is a great and powerful environment, you can present thing the way you want, but don't look for a cutting edge designer. The WPF designer is XAML, mastering it is necessary.
I used flow documents in a regex tool I created. I ended up creating a programmatic wrapper over the flow document library which once done was easy to use because it had my target look and feel.
No, AFAIK there is no design tool for flow documents nor does Blend support it. Create a document and provide a wrapper which speaks to that design is your best option if you use flow documents.

Is WPF required to learn XAML

I am planning to learn XAML. I wanted to know if I should first learn about WPF and then start XAML?
Please advice.
It depends on what your future plans are with XAML/WPF. If you want to get up and running and use it as quick as possible you might consider starting with XAML and WPF at the same time (but note that you can't learn or use WPF just be learning about XAML).
If you plan to work with XAML/WPF for a long time and you will have a lot of WPF projects ahead you probably should consider starting with "pure" WPF.
I belong to the latter camp and it helped me a lot to first get to know the WPF object model, rendering and layout system and then start with XAML, styles, templates etc. For me it made thinks easier to understand (and there is a lot to understand). I understood that XAML is just another way to represent/serialize a .NET object graph that is built as a layer on top.
This is also the way Charles Petzold's book is structured and I think it is the perfect book to start with when you want to get to know WPF really well.
Its not a good question but WPF applications are is built on XAML. I started learning from WPFTUTORIAL
You will find that you will are likely to learn both at the same time. That said, XAML is a designed to be a mark-up language and is used for several technologies, e.g. WPF and WCF et. al.
As #bitbonk mentions, several books on the subject first give you an introduction to WPF (Dependency Objects, Visual Tree and Logical Tree, Controls, etc) before showing any XAML markup.
Whatever you do make sure that your first 2 or 3 applications are throw away apps (not production code). I have seen way too many developers code themselves into a hole when learning to code with WPF. I would recommend studying the MVVM pattern as well. This is critical to building stable WPF applications.
Here are some blog posts I have written that may be of some assistance.
http://tsells.wordpress.com/category/mvvm/

Is there a library to display a Virtual Human [WPF]

While there are a lot of 3D libraries out there, I'm in struggle to find one suitable for WPF.
Basically, I want a Character Animation engine, which loads bone hierarchy and allows me to manipulate the skinned mesh.
I know, this is a classic topic for all the 3D engines. And they are made for building games.
How do I display a Skinned Character in a WPF application?
Depends on how broadly you want to distribute your app, provide installation support for it - and how much work you want to do
1) You can always do it yourself - but you've probably already decided you don't want to spend 2 years of your life building a render pipeline, learning the vagaries of IK, etc
2) You could target XNA - this is sort of WPF, will run on windows, and the xbox to boot - one package you could consider for XNA is Visual 3D - you can find a list of engines here
3) IFF you either can access the target machines directly, or can release your app as a standalone WPF application, you've got a lot of options - all you need is a C# wrapper that allows you to call a native implementation - the one thing you'll loose is WPF ability to superimpose controls, because your render surface will most likely be a winform control embedded in a WPF UI - you will need to get the wrapper DLL into the GAC if you want to distribute the app broadly -
3a) check out the Blender community - the entire tool is open source, and there's a lot of smart people playing in that space
4) I'd tout my own engine but it's undergoing a thorough revision and won't be out again for quite a few months - we'd provide WPF/Silverlight support via option 3 - .Net wrapper over C++ core directly installed into GAC - which makes it available for WPF/Silverlight - I believe we'll still have to pretend to be a winform control to allow the D3D render surfaces to punch through onto the screen
Hope this helps
PS - one side question - You capitalized Virtual Human -- you aren't referencing the NIH Visible Human Project, are you ? If so, last I knew you had to assemble the geometry/bones yourself , all it supplies is the tomagraphic slices
Well you could try this:
OGRE Game engine in WPF
If that OGRE engine supports bones, you should be good to go.
More about the OGRE Engine
Good Luck!
There is no support for skinned meshes in WPF. But you can animate other things like robots well in WPF (see the ape walk example at www.okino.com ).
You can make meshes deform in WPF by changing the position values. I have done this by creating a control which exposes properties to the WPF animation system. It just takes a lot of effort.
Here is my unfinished WPF app. Notice the ball joints in the robot. The only place I really need mesh deformations is in the face, so she can talk.
Since MS dropped support for WPF 3D in Visual Studio its really hard to make realistic animations. Although with UIElement3D you could write an app that allows you to let people drag the robots limbs around and then take a snapshot. An animation system on top of the WPF animation system.
I have written a plugin for blender which allows you to export 3D models from Blender.
So if you want to write a skinned mesh for WPF, you will have to write your own. Bones are really just transforms which work on part of the mesh.

Silverlight - Perspective 3D

I am considering using Silverlight for a project I am working on. This project will need to show a 3-Dimensional cube. Is this possible in Silverlight?
I see a lot of examples that a basically 2-sides of one item. Kind of like a sheet of paper. Is this what "perspective" 3D is? How is perspective 3D different than normal 3D?
Thank you!
You should look at Kit3D for Silverlight. Someone also created a silverlight3d.com site, but it current just has three reference articles and a link to Kit3D.
It is also possible to emulate 3D as demonstrated by this MSDN article.
The feature that was added in Silverlight 3 is referred to as "perspective 3D" to avoid confusion that might arise with someone expecting it be some kind of full scale 3d rendering API (like DirectX or OpenGl etc.) or something like WPFs UIElement3D.
The "perspective 3D" feature in Silverlight allows you to take any regular 2D UIElement and rotate it in 3D dimensions; you can think of it like a more powerful RenderTransform. There are two ways of setting a "Projection" on a UIElement, with a PlaneProjection (simple) or with a Matrix3DProjection (more complex).
You could certainly use this feature to create a 3D cube, where each face of the cube is a UIElement with a Projection applied to it. However you would not use this feature to create something that required complex 3d models such as a 3D game.

Resources