在 WPF 中绘制 3D 线条
我正在开发 CAD 应用程序,并考虑使用 WPF 来渲染我的实体。
但WPF似乎不支持绘制3D线条。有没有办法在WPF中绘制3D线条?
我不喜欢为我需要绘制的每个线实体创建一个网格,因为我担心这会给我带来重大的性能问题,因为我必须在我的应用程序中创建许多线实体。
如果通过 WPF 无法实现此操作,是否可以在 DirectX 9 或 10 中实现此操作?我可以在 WPF 中混合使用 DirectX 吗?我的意思是某种互操作方式?
非常感谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
WPF 确实支持 3D,
您需要使用 Viewport3D创建 3D 的类。
从 WPF 3.5 SP1 开始,您可以组合 DirectX 和 WPF,以便可以编写相当复杂的 3D 应用程序。
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.
我似乎记得几年前 3D Tools for WPF 运行得相当好。我已经很长时间没有在 WPF 中处理任何 3D 内容了,所以其他库可能已经超越了这个,但我不能肯定。
如果您对此不感兴趣,您也可以考虑在 WPF 内部尝试 XNA。这样您就可以保留托管环境(因为 XNA 已经取代了托管 DirectX)。 这里有一篇关于执行此操作的文章,尽管我还没有真正尝试过。
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.
除此之外,OpenTK(OpenGL 的包装器)也可以在 WPF 应用程序中使用,OpenTK 站点上有一个易于启动和运行的简单示例:
http://www.opentk.com/doc/chapter/2/glcontrol
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
3DTools 库实际上是一个糟糕的解决方案。这不仅仅是我的观点。
例如,通过从 3DTools 库添加到场景 100-150 个对象并尝试旋转场景来测试它。这是关于3D工具的答案。
如果您希望在 WPF 3D 中获得快速性能,则必须构建自己的网格。这并不是一项复杂的任务,因为您是 3D CAD 开发人员。此外,如果您的任务涉及场景中大约 1000-5000 个简单的 3D 对象,则使用 WPF 3D 也没有问题。如果更多(或非常复杂):XNA、DirectX 或 OpenGL 的 NET 包装器。
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.