public void Complex_GenerateCutMesh(List <Vector2D> complexSlicerPointsList, float cutSize, Transform transform, float lineWidth, float zPosition) { ComplexCut complexCutLine = ComplexCut.Create(complexSlicerPointsList, cutSize); foreach (Pair2 pair in Pair2.GetList(complexCutLine.GetPointsList(), true)) { CreateLine(pair, transform.localScale, lineWidth, zPosition); } }
static public Mesh GenerateCutMesh(List <Vector2D> complexSlicerPointsList, float cutSize, Transform transform, float lineWidth, float zPosition) { Mesh2DMesh trianglesList = new Mesh2DMesh(); ComplexCut complexCutLine = ComplexCut.Create(complexSlicerPointsList, cutSize); foreach (Pair2D pair in Pair2D.GetList(complexCutLine.GetPointsList(), true)) { trianglesList.Add(Max2DMesh.CreateLine(pair, transform.localScale, lineWidth, zPosition)); } return(Max2DMesh.Export(trianglesList)); }
static public Mesh GenerateComplexCutMesh(List <Vector2D> complexSlicerPointsList, float cutSize, Transform transform, float lineWidth, float zPosition) { List <Mesh2DTriangle> trianglesList = new List <Mesh2DTriangle>(); ComplexCut complexCutLine = ComplexCut.Create(complexSlicerPointsList, cutSize); foreach (Pair2D pair in Pair2D.GetList(complexCutLine.GetPointsList(), true)) { trianglesList.Add(CreateLineNew(pair, transform, lineWidth, zPosition)); } return(ExportMesh2(trianglesList)); }
static public Slice2D ComplexCutSlice(Polygon2D polygon, ComplexCut complexCut) { List <Vector2D> slice = complexCut.GetPointsList(); Slice2D result = Slice2D.Create(complexCut); if (slice.Count < 1) { return(result); } if (Math2D.SliceIntersectItself(slice)) { if (Slicer2D.Debug.enabled) { Debug.LogWarning("Slicer2D: Complex Cut Slicer intersected with itself!"); } return(result); } Vector2D startPoint = null; foreach (Vector2D id in slice) { if (polygon.PointInPoly(id) == false) { startPoint = id; break; } } Polygon2D newPolygon = new Polygon2D(slice); slice = Vector2DList.GetListStartingPoint(slice, startPoint); slice.Add(startPoint); if (polygon.PolyInPoly(newPolygon)) { polygon.AddHole(newPolygon); result.AddPolygon(polygon); return(result); } result = ComplexSlicer.Slice(polygon, slice); return(result); }
public Slice2D ComplexCutSlice(ComplexCut slice) { Slice2D slice2D = Slice2D.Create(slice); if (isActiveAndEnabled == false) { return(slice2D); } Polygon2D colliderPolygon = GetPolygonToSlice(); if (colliderPolygon != null) { Polygon2D slicePoly = new Polygon2D(slice.GetPointsList(1.01f)); if (Math2D.PolyInPoly(slicePoly, colliderPolygon) == true) { Destroy(gameObject); return(slice2D); } else { Slice2D sliceResult = Slicer2D.API.ComplexCutSlice(colliderPolygon, slice); foreach (Polygon2D poly in new List <Polygon2D> (sliceResult.polygons)) { if (Math2D.PolyInPoly(slicePoly, poly)) { sliceResult.RemovePolygon(poly); } } PerformResult(sliceResult.polygons, sliceResult); return(sliceResult); } } return(Slice2D.Create(slice)); }
public void OnRenderObject() { Vector2D pos = GetMousePosition(); if (drawSlicer == false) { return; } Max2D.SetBorder(true); Max2D.SetLineMode(Max2D.LineMode.Smooth); Max2D.SetLineWidth(lineWidth * .5f); Max2D.SetScale(visualScale); if (mouseDown) { Max2D.SetColor(slicerColor); switch (sliceType) { case SliceType.Complex: if (complexSlicerPointsList.Count > 0) { if (startSliceIfPossible == false || startedSlice == true) { Max2D.SetColor(Color.black); Max2D.DrawLineSquare(complexSlicerPointsList.Last(), 0.6f * visualScale, zPosition); Max2D.DrawLineSquare(complexSlicerPointsList.First(), 0.6f * visualScale, zPosition); Max2D.DrawLineSquare(complexSlicerPointsList.Last(), 0.4f * visualScale, zPosition); Max2D.DrawLineSquare(complexSlicerPointsList.First(), 0.4f * visualScale, zPosition); Max2D.SetColor(slicerColor); Max2D.DrawStrippedLine(complexSlicerPointsList, minVertsDistance, zPosition); Max2D.DrawLineSquare(complexSlicerPointsList.Last(), 0.5f * visualScale, zPosition); Max2D.DrawLineSquare(complexSlicerPointsList.First(), 0.5f * visualScale, zPosition); } } break; case SliceType.ComplexTracked: if (complexSlicerPointsList.Count > 0) { Max2D.DrawLineSquare(pos, 0.5f * visualScale, zPosition); foreach (ComplexSlicerTrackerObject tracker in complexTracker.trackerList) { if (tracker.slicer != null && tracker.tracking) { Max2D.DrawSlice(Vector2DList.ToWorldSpace(tracker.slicer.transform, tracker.pointsList), tracker.slicer.transform.position.z - 0.001f); } } } break; case SliceType.Create: if (createType == CreateType.Slice) { if (complexSlicerPointsList.Count > 0) { Max2D.SetColor(Color.black); Max2D.DrawLineSquare(complexSlicerPointsList.Last(), 0.4f * visualScale, zPosition); Max2D.DrawLineSquare(complexSlicerPointsList.First(), 0.4f * visualScale, zPosition); Max2D.DrawLineSquare(complexSlicerPointsList.Last(), 0.6f * visualScale, zPosition); Max2D.DrawLineSquare(complexSlicerPointsList.First(), 0.6f * visualScale, zPosition); Max2D.SetColor(slicerColor); Max2D.DrawLineSquare(complexSlicerPointsList.Last(), 0.5f * visualScale, zPosition); Max2D.DrawLineSquare(complexSlicerPointsList.First(), 0.5f * visualScale, zPosition); Max2D.DrawStrippedLine(complexSlicerPointsList, minVertsDistance, zPosition, true); } } else { Max2D.DrawStrippedLine(Polygon2D.Create(polygonType, polygonSize).pointsList, minVertsDistance, zPosition, true, pos); } break; case SliceType.Linear: Max2D.SetColor(Color.black); Max2D.DrawLineSquare(linearPair.A, 0.6f * visualScale, zPosition); Max2D.DrawLineSquare(linearPair.B, 0.6f * visualScale, zPosition); Max2D.DrawLineSquare(linearPair.A, 0.4f * visualScale, zPosition); Max2D.DrawLineSquare(linearPair.B, 0.4f * visualScale, zPosition); Max2D.SetColor(slicerColor); Max2D.DrawLineSquare(linearPair.A, 0.5f * visualScale, zPosition); Max2D.DrawLineSquare(linearPair.B, 0.5f * visualScale, zPosition); Max2D.DrawLine(linearPair.A, linearPair.B, zPosition); break; case SliceType.LinearCut: linearCutLine = LinearCut.Create(linearPair, linearCutSize); Max2D.DrawStrippedLine(linearCutLine.GetPointsList(), 0, zPosition, true); break; case SliceType.ComplexCut: complexCutLine = ComplexCut.Create(complexSlicerPointsList, complexCutSize); Max2D.DrawStrippedLine(complexCutLine.GetPointsList(), 0, zPosition, true); break; case SliceType.Point: break; case SliceType.Explode: break; case SliceType.Polygon: slicePolygon = Polygon2D.Create(polygonType, polygonSize); Max2D.DrawStrippedLine(slicePolygon.pointsList, minVertsDistance, zPosition, true, pos); break; default: break; } } // Reset Graphics Max2D.SetScale(1f); }
public void DestroyByComplexCut(ComplexCut complexCut) { EraseBrush erase = new EraseBrush(null, new Polygon2D(complexCut.GetPointsList())); DestroyByPolygon(erase); }