public void Update(Vector2D pos) { float scroll = Input.GetAxis("Mouse ScrollWheel"); float newCutSize = cutSize + scroll; if (newCutSize > 0.05f) { cutSize = newCutSize; } if (input.GetInputClicked()) { linearPair.A.Set(pos); } if (input.GetInputHolding()) { linearPair.B.Set(pos); } if (input.GetInputReleased()) { LinearCut linearCutLine = LinearCut.Create(linearPair, cutSize * visuals.visualScale); Slicer2D.LinearCutSliceAll(linearCutLine, sliceLayer); } }
public void Linear_GenerateCutMesh(Pair2 linearPair, float cutSize, Transform transform, float lineWidth, float zPosition) { LinearCut linearCutLine = LinearCut.Create(linearPair, cutSize); foreach (Pair2 pair in Pair2.GetList(linearCutLine.GetPointsList(), true)) { CreateLine(pair, transform.localScale, lineWidth, zPosition); } }
public void Draw(Transform transform) { if (mouseDown) { linearCutLine = LinearCut.Create(linearPair, cutSize); visuals.GenerateLinearCutMesh(linearPair, cutSize, transform); visuals.Draw(); } }
static public Mesh GenerateCutMesh(Pair2D linearPair, float cutSize, Transform transform, float lineWidth, float zPosition) { Mesh2DMesh trianglesList = new Mesh2DMesh(); LinearCut linearCutLine = LinearCut.Create(linearPair, cutSize); foreach (Pair2D pair in Pair2D.GetList(linearCutLine.GetPointsList(), true)) { trianglesList.Add(Max2DMesh.CreateLine(pair, transform.localScale, lineWidth, zPosition)); } return(Max2DMesh.Export(trianglesList)); }
static public Mesh GenerateLinearCutMesh(Pair2D linearPair, float cutSize, Transform transform, float lineWidth, float zPosition) { List <Mesh2DTriangle> trianglesList = new List <Mesh2DTriangle>(); LinearCut linearCutLine = LinearCut.Create(linearPair, cutSize); foreach (Pair2D pair in Pair2D.GetList(linearCutLine.GetPointsList(), true)) { trianglesList.Add(CreateLineNew(pair, transform, lineWidth, zPosition)); } return(ExportMesh2(trianglesList)); }
private void UpdateLinearCut(Vector2D pos) { if (Input.GetMouseButtonDown(0)) { linearPair.A.Set(pos); } if (Input.GetMouseButton(0)) { linearPair.B.Set(pos); mouseDown = true; } if (mouseDown == true && Input.GetMouseButton(0) == false) { mouseDown = false; LinearCut linearCutLine = LinearCut.Create(linearPair, cutSize * visualScale); Slicer2D.LinearCutSliceAll(linearCutLine, sliceLayer); } }
public void Update(Vector2D pos) { float scroll = Input.GetAxis("Mouse ScrollWheel"); float newCutSize = cutSize + scroll; if (newCutSize > 0.05f) { cutSize = newCutSize; } if (Input.GetMouseButtonDown(0)) { linearPair.A = pos; } if (Input.GetMouseButton(0)) { mouseDown = true; Vector2D posMove = linearPair.A; linearPair.B = pos; if ((Vector2D.Distance(posMove, pos) > visuals.minVertexDistance * visuals.visualScale)) { linearCutLine = LinearCut.Create(linearPair, cutSize); Destruction2D.DestroyByLinearCutAll(linearCutLine, destructionLayer); linearPair.A = pos; } } else { mouseDown = false; } }
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); }