Exemple #1
0
    public static PlaningGridCell CreateCell(Vector3 pos, float size = 2)
    {
        Vector3    scale = new Vector3(size, size, size);
        GameObject o     = GameObject.CreatePrimitive(PrimitiveType.Cube);

        o.transform.position   = pos;
        o.transform.localScale = scale;
        PlaningGridCell pgc = o.AddComponent <PlaningGridCell>() as PlaningGridCell;

        return(pgc);
    }
Exemple #2
0
    public PlaningGrid(Vector3[] boundary, float cellGap = 6, float h = 1)
    {
        cells  = new List <PlaningGridCell>();
        height = h;
        BoundingBox bbox = BoundingBox.CreateFromPoints(boundary);

        countW = (int)(Mathf.Round(bbox.size[0] / cellGap));
        countD = (int)(Mathf.Round(bbox.size[2] / cellGap));

        for (int i = 0; i < countD; i++)
        {
            for (int j = 0; j < countW; j++)
            {
                float skip = 0;
                //float skip = (j % 2) * cellSize;
                Vector3 pos = new Vector3((j * cellGap) + skip, height, i * cellGap);
                pos += bbox.position;
                PlaningGridCell cell = PlaningGridCell.CreateCell(pos, 0.1f);
                cells.Add(cell);
            }
        }
    }
Exemple #3
0
 public static PlaningGridCell CreateCell()
 {
     return(PlaningGridCell.CreateCell(Vector3.zero, 2));
 }