![]() |
|
Boolean subtraction over a transformed distance - Printable Version +- AB4D Forum (https://forum.ab4d.com) +-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4) +--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9) +--- Thread: Boolean subtraction over a transformed distance (/showthread.php?tid=4483) |
Boolean subtraction over a transformed distance - geometry3d - 05-20-2025 Hi. I am interested in this product. I need to do boolean subtractions on a mesh and display them. I need the subtraction to be done over a distance. I think this would be done using a transform. However, the code : TranslateTransform3D translateTransform3D = new TranslateTransform3D(); translateTransform3D.Transform(new Vector3D(0, 0, 200)); var subtractedMesh1 = Ab3d.Utilities.MeshBooleanOperations.Subtract(boxMesh, combinedMesh, translateTransform3D, processOnlyIntersectingTriangles: true, generateInnerTriangles: generateInnerTriangles); ShowMesh(subtractedMesh1, -120); Starts to get confused between MeshGeometry3D, Geometry3D and ModelVisual3D. Is it possible? I need to be able to have a pointed cone like a pencil tip, and the drag this across a the surface of a cube mesh. RE: Boolean subtraction over a transformed distance - abenedik - 05-20-2025 The MeshBooleanOperations.Subtract method that takes two MeshGeometry3D objects does not take the Transform3D as a parameter (Transform3D is only available when the first parameter is GeometryModel3D, Model3D or ModelVisual3D). So you need to manually transform the mesh before the Subtract: Code: var transformedMesh = Ab3d.Utilities.MeshUtils.TransformMeshGeometry3D(boxMesh, transform, transformNormals: false);Similar code (calling MeshUtils.TransformMeshGeometry3D) is also part of the Subtract method that take Transform3D as a parameter. RE: Boolean subtraction over a transformed distance - geometry3d - 05-21-2025 Thankyou very much for that helpful reply. I have a large cube that has a side of 6 units long. If I have a small cube mesh of side 1, move it to (x=-3,y=0,z=3) I can subtract it from the edge of the large cube. Is it possible to also transform the small cube by (x=6,y=0,z=0) at the same time, so I get a long trench across the top? See the attached image. I could possibly do the subtract 6 times in different locations, but I would prefer to do it once. Many thanks. RE: Boolean subtraction over a transformed distance - abenedik - 05-21-2025 It is highly recommended to use as few boolean operations as possible. This would work much faster and produce results with fewer triangles. You can combine multiple transformations by using WPF's Transform3DGroup object, for example: Code: var transform3DGroup = new Transform3DGroup();Then you can pass the transform3DGroup to the MeshUtils.TransformMeshGeometry3D. Note that the order of transformation is important. First, you need to add scale, then rotate and then translate. Scale and Rotation happen from (0, 0, 0). So if your mesh is centered at (0, 0, 0), then scale and rotate will also around object's center. But if you first translate the model, then the scale and rotation would have a different effect (still rotating around (0,0,0) but this is not the center of the mesh anymore). |