public static void fillStripe2D(Vector2 position, float r1, float r2, int stepsCount) { List <Vector3> steps = new List <Vector3>(); List <Vector3> steps2 = new List <Vector3>(); for (float angle = 0; angle < Math.PI * 2; angle += (float)Math.PI * 2 / stepsCount) { steps.Add((position + new Vector2(MyMath.cos(angle), MyMath.sin(angle)) * r1).withZ(0.5f)); steps2.Add((position + new Vector2(MyMath.cos(angle), MyMath.sin(angle)) * r2).withZ(0.5f)); } steps.Add(steps[0]); steps2.Add(steps2[0]); drawStrip(steps, steps2); }
public static void fillArcStripe2D(Vector2 position, float r1, float r2, int stepsCount, float from, float to) { List <Vector3> steps = new List <Vector3>(); List <Vector3> steps2 = new List <Vector3>(); float stepSize = (to - from) / stepsCount; for (float angle = from; angle < to; angle += stepSize) { steps.Add((position + new Vector2(MyMath.cos(angle), MyMath.sin(angle)) * r1).withZ(0.5f)); steps2.Add((position + new Vector2(MyMath.cos(angle), MyMath.sin(angle)) * r2).withZ(0.5f)); } steps.Add((position + new Vector2(MyMath.cos(to), MyMath.sin(to)) * r1).withZ(0.5f)); steps2.Add((position + new Vector2(MyMath.cos(to), MyMath.sin(to)) * r2).withZ(0.5f)); drawStrip(steps, steps2); }
public static void fillCircle2D(Vector2 position, float r) { Vector3 center = Camera.current.ScreenToWorldPoint(position.withZ(0.5f)); Vector3 normal = Camera.current.transform.rotation.rotate(new Vector3(0, 0, 1)); List <Vector3> steps = new List <Vector3>(); for (float angle = 0; angle < Math.PI * 2; angle += (float)Math.PI / 5f) { Vector2 newPos = position + new Vector2(MyMath.cos(angle), MyMath.sin(angle)) * r; Vector3 sec = Camera.current.ScreenToWorldPoint(newPos.withZ(0.5f)); steps.Add(sec); } GeoData gd = new GeoData(); for (int i = 0; i < steps.Count; i++) { Vector3 m1 = steps[i]; Vector3 m2 = steps[(i + 1) % steps.Count]; gd.addTriangle(center, m2, m1, normal); } Gizmos.DrawMesh(gd.getMesh()); }