public void InsertControlPoint(ControlPointPair controlPoints, Vector3 position) { var targetPosition = position - transform.position; var direction = Quaternion.Slerp(controlPoints.First.Direction, controlPoints.Second.Direction, 0.5f); var controlPoint = new SplineControlPoint { Position = targetPosition, Direction = direction }; var insertIndex = Mathf.Max(ControlPoints.IndexOf(controlPoints.First), ControlPoints.IndexOf(controlPoints.Second)); ControlPoints.Insert(insertIndex, controlPoint); UpdateMesh(); }
public void AddPoint(Vector2 newPoint) { Vector2 lastAnchorPoint = AnchorPoints[AnchorPoints.Count - 1]; ControlPointPair lastControlPoint = ControlPoints[ControlPoints.Count - 1]; Vector2 distance = lastAnchorPoint - lastControlPoint.leftControlPoint; lastControlPoint.rightControlPoint = lastAnchorPoint + distance; ControlPoints[ControlPoints.Count - 1] = lastControlPoint; AnchorPoints.Add(newPoint); ControlPointPair newLastControlPointPair = new ControlPointPair(newPoint - distance, NULL); ControlPoints.Add(newLastControlPointPair); }
public void InsertControlPoint(ControlPointPair controlPoints, Vector3 position) { var targetPosition = position - transform.position; var direction = Quaternion.Lerp(controlPoints.First.Direction, controlPoints.Second.Direction, 0.5f); var width = Mathf.Lerp(controlPoints.First.Width, controlPoints.Second.Width, 0.5f); var controlPoint = new RiverControlPoint { Position = targetPosition, Direction = direction, Width = width }; var insertIndex = Mathf.Max(ControlPoints.IndexOf(controlPoints.First), ControlPoints.IndexOf(controlPoints.Second)); ControlPoints.Insert(insertIndex, controlPoint); UpdateRiverMesh(); }
public void RenderPoint(Vector2 anchorPointPosition, ControlPointPair controlPointPair) { lineRenderer.SetPosition(1, anchorPointPosition); transform.position = anchorPointPosition; anchorPoint.gameObject.SetActive(true); anchorPointSpriteRenderer.enabled = true; ControlPointLeft.IsRight = true; SwitchControlPointOn(controlPointPair.leftControlPoint, anchorPointPosition, controlPointLeftSpriteRenderer, 0); ControlPointLeft.IsRight = false; SwitchControlPointOn(controlPointPair.rightControlPoint, anchorPointPosition, controlPointRightSpriteRenderer, 2); }
public void AddCPP(ControlPointPair cpp) { ControlPoints.Add(cpp); //initialize lastPoint with the very first baked point lastPoint = ControlPoints[0].bakedPoints[0]; }