public void Reverse(Vector2 location)
    {
        meshTransform.ScaleUnrestricted(new Vector2(-1, 1));
        MoveTo(location);

        if (child)
        {
            child.GetComponent <Limb>().Reverse(jointVert);
        }
    }
Ejemplo n.º 2
0
    void ReshapeStar(int points)
    {
        //Reject values too low or high
        if (points < 3 || points > 50)
        {
            Debug.LogErrorFormat("{0} is an invalid number of sides for the shape to have.", points);
            return;
        }

        Reshape(points);

        Vector2 offset = mesh.vertices[0];

        meshTransform.Translate(-offset);
        meshTransform.ScaleUnrestricted(Vector2.one * 0.5f);

        int newStart = mesh.vertexCount;

        List <Vector3> verts = new List <Vector3>(mesh.vertices);

        //Add point vertices
        for (int i = 0; i < points; i++)
        {
            verts.Add(new Vector3(Mathf.Sin((i + 0.5f) * 2 * Mathf.PI / points), Mathf.Cos((i + 0.5f) * 2 * Mathf.PI / points), 1));
        }

        List <int> tris = new List <int>(mesh.triangles)
        {
            //Add initial (outlier) tri
            verts.Count - 1,
            1,
            newStart - 1
        };

        //Add fanning out tris
        for (int i = 0; i < points - 1; i++)
        {
            tris.Add(newStart + i);
            tris.Add(i + 1);
            tris.Add(i + 2);
        }

        RecreateMesh(verts.ToArray(), tris.ToArray());

        meshTransform.Translate(offset);
    }