简体   繁体   中英

How to switch to wireframe display mode for a Viewport3D control in WPF?

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?

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.

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. ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM