Drawing 3D lines in WPF
Asked Answered
K

4

10

I am working on a CAD application and thinking of using WPF for rendering my entities.

But it seems like WPF doesn't support drawing 3D lines. Is there any ways for drawing 3D lines in WPF?

I don't 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 DirectX 9 or 10? Can I mix DirectX in WPF? I mean some way of interop?

Many Thanks

Kithara answered 21/1, 2010 at 19:5 Comment(0)
N
3

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.

Nickey answered 21/1, 2010 at 19:34 Comment(5)
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.Kithara
As for WPF 3D, the WPF SDK code samples are a great place to start. This site also has good samples: windowsclient.net/downloads/folders/wpfsamples/default.aspx As for DX->WPF integration, Dr. WPF has a good example on CodeProject: codeproject.com/KB/WPF/D3DImage.aspxNickey
Thank you.. I will try something with this and ask more questions later.Kithara
I don't see how this answers the question about line drawing.Corse
That's because the question isn't about line drawing.Nickey
H
0

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.

Holmes answered 21/1, 2010 at 19:22 Comment(4)
A much improved, expanded and actively developed library for WPF 3D is the Helix Toolkit (helixtoolkit.codeplex.com).Moreno
the helixtoolkit is moved to github github.com/helix-toolkit/helix-toolkitLanellelanette
Update: XNA is deprecated now (gamasutra.com/view/news/185894/Its_official_XNA_is_dead.php)Vigil
I don't see how this answers the question about line drawing.Corse
A
-1

Just adding to this that OpenTK, which is a wrapper around OpenGL, is usable as well from a WPF application, there is a simple example that's easy to get up and running on the OpenTK site:

http://www.opentk.com/doc/chapter/2/glcontrol

Aleurone answered 3/8, 2011 at 15:27 Comment(2)
I don't see how this answers the question about line drawing.Corse
Maybe, but there's also more than one question asked.Aleurone
B
-1

3DTools library in fact is bad solution. It is not simply my opinion. For example, test it by adding to scene 100-150 objects from 3DTools library and try to rotate the scene. It is the answer concerning 3D Tools. If you wish fast performance in WPF 3D you must build own meshes. It is not complicated task as you are 3D CAD developer. And also if your task is concerning approx 1000-5000 simple 3D objects within scene use WPF 3D, no problem. If more (or very complex): XNA, NET Wrappers of DirectX or OpenGL.

Bovid answered 21/11, 2012 at 23:18 Comment(1)
I don't see how this answers the question about line drawing.Corse

© 2022 - 2024 — McMap. All rights reserved.