tags:

views:

1060

answers:

3

Hi, I am working on a CAD application and thinking of using WPF for rendering my entities. But it seems like WPF doesnt support drawing 3D lines. Is there any ways for drawing 3D lines in WPF? I dont like to create a mesh for each line entity I need to draw as I am afraid, this would cause a major performance hitch for me as I would have to create number of line entities in my application. If this is not possible through WPF, will it be possible to do this in DriectX 9 or 10? Can I mix directX in WPF? I mean some way of interops?

Many Thanks,

+1  A: 

I seem to remember 3D Tools for WPF working rather well a few years back. I haven't worked on anything 3D in WPF for a long time now, so it's possible other libraries have surpassed this, but I can't say for sure.

If you aren't interested in working with that, you may also consider trying XNA inside of WPF. This way you'll keep your managed environment (as XNA has replaced managed DirectX). Here's an article about doing this, though I haven't actually tried it.

Ryan Versaw
+3  A: 

WPF does do 3D, and it does it well.

You'll need to use the Viewport3D class to create 3D.

As of WPF 3.5 SP1, you can compose DirectX and WPF so that you can do fairly sophisticated 3D applications.

codekaizen
Thanks Very much. I would highly appreciate if you can provide me with some sample code to show how I can do interop with WPF and DirectX. An example to draw a 3D line will be of much help.
CadPro
As for WPF 3D, the WPF SDK code samples are a great place to start. This site also has good samples: http://windowsclient.net/downloads/folders/wpfsamples/default.aspxAs for DX->WPF integration, Dr. WPF has a good example on CodeProject: http://www.codeproject.com/KB/WPF/D3DImage.aspx
codekaizen
Thank you.. I will try something with this and ask more questions later.
CadPro
A: 

I recently played a little bit with ScreenSpaceLine3D in 3DTools library. I found three problems:

  1. Lines are sometimes drawn as dashed lines if the thickness is 1. If I change the thickness to 2, they become solid.
  2. Lines don't show up using OrthographicCamera. It works fine using PerspectiveCamera.
  3. Poor performance. I have a 3D surface with lines. Eric Sink mentioned a solution (http://www.ericsink.com/wpf3d/1_ScreenSpaceLines3D_Performance.html), but it is still slow.

Anybody has better idea on those issues?

miliu