Beispiel #1
0
 public override void Draw()
 {
     Vector2[] shapeAnchors    = new Vector2[2 * smoothness];
     float[]   shapeRadii      = new float[2 * smoothness];
     int[]     radiiSmoothness = new int[2 * smoothness];
     float[]   angles          = ShapeRenderer.LinSpace(-90 * Mathf.Deg2Rad, 90 * Mathf.Deg2Rad, smoothness);
     for (int i = 0; i < smoothness; i++)
     {
         float anchorAngle = angles[i];
         shapeAnchors[i]    = new Vector2(length * 0.5f, 0) + new Vector2(Mathf.Cos(anchorAngle), Mathf.Sin(anchorAngle)) * radius;
         shapeRadii[i]      = 0;
         radiiSmoothness[i] = 0;
     }
     angles = ShapeRenderer.LinSpace(90 * Mathf.Deg2Rad, 270 * Mathf.Deg2Rad, smoothness);
     for (int i = smoothness; i < smoothness * 2; i++)
     {
         float anchorAngle = angles[i - smoothness];
         shapeAnchors[i]    = new Vector2(-length * 0.5f, 0) + new Vector2(Mathf.Cos(anchorAngle), Mathf.Sin(anchorAngle)) * radius;
         shapeRadii[i]      = 0;
         radiiSmoothness[i] = 0;
     }
     sr.shapeAnchors    = shapeAnchors;
     sr.shapeRadii      = shapeRadii;
     sr.radiiSmoothness = radiiSmoothness;
 }
Beispiel #2
0
    public override void Draw()
    {
        float halfWidth = width * 0.5f;

        Vector2[] shapeAnchors    = new Vector2[2 * smoothness];
        float[]   shapeRadii      = new float[2 * smoothness];
        int[]     radiiSmoothness = new int[2 * smoothness];
        float[]   angles          = ShapeRenderer.LinSpace(0, angle * Mathf.Deg2Rad, smoothness);
        for (int i = 0; i < smoothness; i++)
        {
            shapeAnchors[i]    = new Vector2(Mathf.Cos(angles[i]), Mathf.Sin(angles[i])) * (radius + halfWidth);
            shapeRadii[i]      = 0;
            radiiSmoothness[i] = 0;
        }
        Array.Reverse(angles);
        for (int i = 0; i < smoothness; i++)
        {
            shapeAnchors[i + smoothness]    = new Vector2(Mathf.Cos(angles[i]), Mathf.Sin(angles[i])) * (radius - halfWidth);
            shapeRadii[i + smoothness]      = 0;
            radiiSmoothness[i + smoothness] = 0;
        }
        sr.shapeAnchors    = shapeAnchors;
        sr.shapeRadii      = shapeRadii;
        sr.radiiSmoothness = radiiSmoothness;
    }