public static void DrawBezier2(Vector3 startPosition, Vector3 endPosition, Vector3 control, Color color, Texture2D texture, float width) { Bezier2 curve = new Bezier2(startPosition, control, endPosition); Vector2 lineStart = startPosition; Handles.color = color; for (int i = 1; i <= 32; i++) { Vector2 lineEnd = curve.GetQuadraticPoint(i / (float)16); Handles.DrawAAPolyLine(texture, width, lineStart, lineEnd); lineStart = lineEnd; } }
private void GetDashedCurvePointsNormals(out List <Vector2> points, out List <Vector2> normals) { points = new List <Vector2>(); normals = new List <Vector2>(); float curveLength = 0; float param = 0; float s = 0; if (type == CurveType.Quadratic) { points.Add(start); normals.Add(quadraticBezier.GetQuadraticFirstDerivativeNormal(0)); curveLength = quadraticBezier.GetQuadraticArcLength(0, 1); while (s <= curveLength) { s += stripLenght; if (curveLength <= s) { for (int i = subdivisions; i > 0; i--) { param = quadraticBezier.GetQuadraticArcParameterAtLength(s - i * stripLenght / (subdivisions + 1)); points.Add(quadraticBezier.GetQuadraticPoint(param)); normals.Add(quadraticBezier.GetQuadraticFirstDerivativeNormal(param)); } points.Add(quadraticBezier.GetQuadraticPoint(1)); normals.Add(quadraticBezier.GetQuadraticFirstDerivativeNormal(1)); } else { for (int i = subdivisions; i >= 0; i--) { param = quadraticBezier.GetQuadraticArcParameterAtLength(s - i * stripLenght / (subdivisions + 1)); points.Add(quadraticBezier.GetQuadraticPoint(param)); normals.Add(quadraticBezier.GetQuadraticFirstDerivativeNormal(param)); } s += emptyStripLenght; if (s < curveLength) { param = quadraticBezier.GetQuadraticArcParameterAtLength(s); points.Add(quadraticBezier.GetQuadraticPoint(param)); normals.Add(quadraticBezier.GetQuadraticFirstDerivativeNormal(param)); } } } } else { points.Add(start); normals.Add(cubicBezier.GetCubicFirstDerivativeNormal(0)); curveLength = cubicBezier.GetCubicArcLength(0, 1); while (s <= curveLength) { s += stripLenght; if (curveLength <= s) { for (int i = subdivisions; i > 0; i--) { param = cubicBezier.GetCubicArcParameterAtLength(s - i * stripLenght / (subdivisions + 1)); points.Add(cubicBezier.GetCubicPoint(param)); normals.Add(cubicBezier.GetCubicFirstDerivativeNormal(param)); } points.Add(cubicBezier.GetCubicPoint(1)); normals.Add(cubicBezier.GetCubicFirstDerivativeNormal(1)); } else { for (int i = subdivisions; i >= 0; i--) { param = cubicBezier.GetCubicArcParameterAtLength(s - i * stripLenght / (subdivisions + 1)); points.Add(cubicBezier.GetCubicPoint(param)); normals.Add(cubicBezier.GetCubicFirstDerivativeNormal(param)); } } s += emptyStripLenght; if (s < curveLength) { param = cubicBezier.GetCubicArcParameterAtLength(s); points.Add(cubicBezier.GetCubicPoint(param)); normals.Add(cubicBezier.GetCubicFirstDerivativeNormal(param)); } } } }