Drawing 3D lines in WPF

南楼画角 提交于 2019-11-29 03:11:23

问题


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:


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.




回答2:


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.




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/2112034/drawing-3d-lines-in-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!