Why the follow method don't work with Ab3d.Visuals.LineVisual3D as first parameter? 

public static void Subtract(
    ModelVisual3D modelVisual3D,
    MeshGeometry3D meshGeometry3D,
    Transform3D parentTransform3D = null
I'm trying to subtract some meshGeometry3D from a line, but without results.

Thank you.

3D lines are generated in such a way that for each line a rectangle (2 triangles) is generated so that the rectangle is facing the camera and that it has the specified line thickness on the screen. This means that on each camera change or change or the line positions, the line's MeshGeometry3D needs to be regenerated. Therefore you cannot do Boolean operations on the lines.

But instead of using LineVisual3D object (or any other Visual3D that is derived from BaseLineVisual3D) you can use TubeLineVisual3D - this object creates a tube MeshGeometry3D for each line. This MeshGeometry3D is fixed and therefore you can use Boolean operations on it. Also note, then for TubeLineVisual3D you do not specify the line thickness in screen coordinates but you specify the tube's Radius that is in world coordinates.

Anyway, I am curious why you need to use Boolean operations on 3D lines. Maybe you could split the line into multiple lines instead - using MultiLineVisual3D or multiple LineVisual3D objects to show parts of the line.
Andrej Benedik
Hi abenedik
Thank you for the tip.

To satisfy your curiosity: My software draw some mechanicals components with a custom wireframes created with LineVisual3D class (not wireframes provided from AB3D features).
Software users are enabled to create holes in those components, then, I use Boolean operations to create those holes.
Sometime, the holes can be positioned on wireframe, then, I need to cut the wireframe.

Thanks for the information.

So you probably also do Boolean operations on the solid model3D object. In this case you could also regenerate the lines for the wireframe.

One more tip: if have a lot of LineVisual3D objects and you want to improve the performance of your application, then you can use MultiLineVisual3D instead of multiple LineVisual3D objects. You are less flexible with a MultiLineVisual3D and also need to use a single color for all lines in MultiLineVisual3D, but the performance will be better.

Rendering many 3D lines with Ab3d.PowerToys and WPF 3D rendering can be slow because the geometry for all the lines need to be generated on the CPU. Consider using Ab3d.DXEngine as it can render millions of 3D lines because full hardware acceleration is used there. With Ab3d.DXEngine you can also set different colors for line positions - so you can render multiple lines with different colors with one object (draw call).
Andrej Benedik
Thank you Abenedik!
Hi, I've got a new question about MeshBooleanOperations.Subtract method.
If i've got a GeometryModel3D with transform edited and I subtract from it a MeshGeometry3D, the GeometryModel3D loss the transformation, why?


Boolean operations work on meshes and in order to correctly position the mesh from the GeometryModel3D, the MeshBooleanOperations.Subtract method needs to transform the mesh before doing the subtract operation.

This is done by using MeshUtils.TransformMeshGeometry3D method.

To give you more control on transformations and which mesh is transformed, I recommend that you use Subtract methods that take two MeshGeometry3D objects and if needed transform the meshes by yourself by MeshUtils.TransformMeshGeometry3D method.

You may also use Ab3d.Meshes.BooleanMesh3D class. See the ModelingWithBooleanOperations.xaml.cs sample file on how to use that.
Andrej Benedik
Thank you Abenedik, i will try.
This is my solution for the problem:

Dim gm3D As System.Windows.Media.Media3D.GeometryModel3D ' My model already transformed
Dim msh As System.Windows.Media.Media3D.MeshGeometry3D     ' Mesh to subtract

Dim bool As Ab3d.Meshes.BooleanMesh3D = Nothing
bool =
    New Ab3d.Meshes.BooleanMesh3D(

Call bool.Subtract(msh)

gm3D.Transform = New System.Windows.Media.Media3D.MatrixTransform3D

gm3D.Geometry = bool.Geometry

Forum Jump:

Users browsing this thread:
1 Guest(s)