Exemplo n.º 1
0
    public List <Vector3> GetVerticies()
    {
        List <Vector3> points = new List <Vector3>();


        Vector3 positionPoly = poly.transform.position;

        if (poly.transform.eulerAngles.z != 0)
        {
            float angle = poly.transform.eulerAngles.z * Mathf.Deg2Rad;

            foreach (Vector2 v in poly.points)
            {
                Vector3 rotatedPoint = Light_Tools.RotatePoint(new Vector2(v.x * poly.transform.localScale.x, v.y * poly.transform.localScale.y), angle);
                points.Add(rotatedPoint + positionPoly);
            }
        }
        else
        {
            foreach (Vector2 v in poly.points)
            {
                points.Add(new Vector3(v.x * poly.transform.localScale.x + positionPoly.x, v.y * poly.transform.localScale.y + positionPoly.y));
            }
        }
        return(points);
    }
Exemplo n.º 2
0
    //récupère les points d'un box collider
    public List <Vector3> GetVertices()
    {
        List <Vector3> points = new List <Vector3>();

        if (box.transform.eulerAngles.z != 0)
        {
            float   angle = box.transform.eulerAngles.z * Mathf.Deg2Rad;
            Vector2 vect  = new Vector2(box.transform.localScale.x / 2, box.transform.localScale.y / 2);
            for (int i = -1; i < 2; i += 2)
            {
                for (int j = -1; j < 2; j += 2)
                {
                    Vector3 rotatedPoint = new Vector3(vect.x * i, vect.y * j);
                    rotatedPoint = Light_Tools.RotatePoint(rotatedPoint, angle);
                    points.Add(center + rotatedPoint);
                }
            }
        }
        else
        {
            points.Add(new Vector3(center.x - size.x, center.y - size.y, 0));
            points.Add(new Vector3(center.x - size.x, center.y + size.y, 0));
            points.Add(new Vector3(center.x + size.x, center.y + size.y, 0));
            points.Add(new Vector3(center.x + size.x, center.y - size.y, 0));
        }
        return(points);
    }