Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Boolean Operations on Distant Meshes
#1
Good day.

I would like to know what would the best practices for the following scenario:

I have an object with a size bigger than 10k units (basically far away).
I want to subtract from it a few smaller objects using boolean operations.
The mesh of the big object gets corrupted.

Example: A big cube, from which we subtract a few smaller cylinders. The cylinders pass fully through the cube.

My Approach on fixing this: Downscaling the objects, performing the subtraction, upscaling back.

Questions:
1. Is AB4D optimised more for smaller numbers ( smaller than 1 ) when making boolean operations?
2. Are boolean operations the best way of subtracting one object from another in AB4D ?

Thanks a lot!
Code:
var downScale = new StandardTransform(scale: MeshCalculatorConstants.ScalingFactor);
mesh = MeshUtils.TransformMesh(mesh, downScale);

var holesMeshes = _holeMeshCalculator.CalculateHolesMeshes(piece, pieceXDirection);
holesMeshes = MeshUtils.TransformMesh(holesMeshes, downScale);

mesh = MeshBooleanOperations.Subtract(mesh, holesMeshes, true, true);

var upScale = new StandardTransform(scale: 1 / MeshCalculatorConstants.ScalingFactor);
mesh = MeshUtils.TransformMesh(mesh, upScale);
#2
The Ab4d.SharpEngine uses float values for vertex coordinates. If you use very big float numbers with very small float numbers, then some floating-point inprecisions may produce invalid results.

Boolean operations do a lot of floating-point operations and this may be the reason for the problems.

I would need to have the exact code to reproduce this issue and then I could say if this is actually caused by floating point errors.

But if you say, that scaling the model down solves this issue, then this also indicates that this is the cause of the problems.


When you want to subtract the holes from a 3D box / cube, then you can also use the triangulater where you provide a 2D shape of the rectangle and then define the 2D shapes as holes in the rectangle. The Ab4d.SharpEngine.Utilities.Triangulator can be used to generate the triangles from that. Then you can use the MeshFactory.CreateExtrudedMesh to extrude the triangles to generate a 3D object.

See the "Advanced 3D models / Triangulates & Extruded Shape" sample and then select the "Rectangle with simple holes" or "Circle with circular holes" option. See screenshot:

   
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)