如何在 WPF 中将 Viewport3D 控件切换到线框显示模式?
有办法做到这一点吗?我正在寻找这样的东西:
viewport3dControl.DisplayMode = DisplayMode.Wireframe;
而不是当前的阴影。
或者我是否必须为每个要显示为线框的对象设置此项?如果是这样,怎么办?
Is there a way to do this? I am looking for something like this:
viewport3dControl.DisplayMode = DisplayMode.Wireframe;
Instead of the current shaded one.
Or do I have to set this for each object I want to display as wireframe? If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这并不像您希望的那么容易,但可以通过一些图书馆的帮助来完成。请参阅:
具体来说,ModelViewer 示例有一个“View -> Wireframe”复选框这就是你想要的。示例并不大,因此您可以了解如何将其应用到您的情况。
It's not as easy as you would wish but it can be done with some library help. See:
Specifically, the ModelViewer sample has a "View -> Wireframe" checkbox that does what you want. The sample is not large so you can see how you can apply it to your situation.
此处也发布了相同的答案:
WPF中的线框渲染
我看到了很多回复参考此问题的第三方解决方案。
对于纯 WPF 解决方案,我从现有的 Model3D 创建一个新的 Model3D,其中每个面都创建有一个孔。即分成 6 个新的面,每条“线”的宽度与原始面的大小成比例。
这样做的原因是它看起来比固定线宽更好,但如果需要,您可以使用固定线宽。
可以选择将中心孔填充为黑色的新面(组中单独的 Model3D),并且您可以删除隐藏线。
对于面中的三个点 A0、B0 和 C0,计算 AB、AC 和 BC 的中点。新点 A1 位于 BC 方向的 1/20 处。对接下来的两个点 B1 和 C1 重复上述操作。
“线”的 6 个新面由以下组合表示:
A0、B0、B1
A0、B1、A1
A0、C1、C0
A0、A1、C1
B0、C0、C1
B0、C1、B1
将 A1、B1 和 C1 添加到另一个模型以实现隐藏线去除变体。
Same answer also posted here:
Wireframe rendering in WPF
I've seen many replies referring to 3rd party solutions for this problem.
For a pure WPF solution, I create a new Model3D from the existing Model3D, where each facet is created with a hole in it. i.e. split into 6 new facets, with the width of each 'line' proportional to the original facet size.
Reason for this is that it looks better than fixed line width, but you can use fixed line width if required.
Optionally fill in the centre hole as a new facet in black (separate Model3D in the group), and you have hidden line removal.
For three points in the facet, A0, B0 and C0, calculate the mid points of AB, AC and BC. the new point A1 is 1/20th along the line towards BC. Repeat for next two points B1 and C1.
The 6 new facets for the 'lines' are represented by the following combinations:
A0, B0, B1
A0, B1, A1
A0, C1, C0
A0, A1, C1
B0, C0, C1
B0, C1, B1
Add A1, B1 and C1 to another model for the hidden line removal variant.