问题
I would like to display any MeshElement3D (for example BoxVisual3d) in helix-toolkit as wireframe. How can this be accomplished?
EDIT:
Thanks to Erno de Weerd's answer I was able to write the following code
Class that extends BoxVisual3D
public class GeometryBoxVisual3D : BoxVisual3D { public MeshGeometry3D Geometry() { return Tessellate(); } }
Add the instance of box to the Viewport:
GeometryBoxVisual3D box = new GeometryBoxVisual3D(); box.Fill = new SolidColorBrush(Colors.Red); Viewport3D.Children.Add(box); MeshGeometry3D geometry3 = box.Geometry(); LinesVisual3D lines = new LinesVisual3D(); lines.Thickness = 3; lines.Points = geometry3.Positions; lines.Transform = new TranslateTransform3D(3,1,1); Viewport3D.Children.Add(lines);
This results in the following display:
If I hide the original box and place LinesVisual3D on top of the box, I can get the wirefrime displayed as if it was original object, but it is still missing the edges on the side.
回答1:
By calling MeshElement3D.Tesselate()
you can get the MeshGeometry3D
(mesh).
Next create a LinesVisual3D
object.
Copy the Points of the mesh to the Points of the LinesVisual3D
.
This will create the internal mesh (see the sources: LinesVisual3D.cs in helix toolkit)
Finally, make sure you set the thickness of the LinesVisual3D
and add it to the scene.
来源:https://stackoverflow.com/questions/28596130/how-to-display-meshelement3d-as-wireframe