Question : How to calculate transform after subtract
PrashantKT opened this issue · comments
I want to translate polygon to center ,
let's say I have Mesh 1 - with transform (rotate , scale , transalte )
Mesh2 (BOX) with transform
Now When I subtract both meshes with Following code
func subtractPolygon(_ mesh: Mesh, isCancelled: CancellationHandler = { false }) -> ([Polygon],[Polygon],[Polygon])? {
let intersection = bounds.intersection(mesh.bounds)
guard !intersection.isEmpty else {
return nil
}
var aout: [Polygon]? = [], bout: [Polygon]?
let ap = BSP(mesh, isCancelled).clip(
boundsTest(intersection, polygons, &aout),
.greaterThan,
isCancelled
)
let bp = BSP(self, isCancelled).clip(
boundsTest(intersection, mesh.polygons, &bout),
.lessThan,
isCancelled
)
return (aout!,ap,bp)
}
When we create the mesh with this polygons
because the result polygon are as per the transform of the original mesh ( translated as per original mesh) the new mesh created is also at the same position
My Goal I need to transform the result that it will be always in the center
I can apply transform with mesh.transformed(by:transform) - But I don't know how to calculate the transform
For example :
Mesh 1 at POSITION 10,10,10
Mesh 2 at POSITION 10,10,10
Result : Polygon are at the same place of the original mesh (10,10,10)
I need to be in 0,0,0
Oh I am so stupid - It was just translate -Vector(node.position)