Exemplo n.º 1
0
        public virtual void InitGrid(int cellsPerXAxis, int cellsPerYAxis, int cellsPerZAxis, float cellSize, CreateCellDelegate cellCreateFunc)
        {
            this.cellsPerXAxis  = cellsPerXAxis;
            this.cellsPerYAxis  = cellsPerYAxis;
            this.cellsPerZAxis  = cellsPerZAxis;
            this.cellSize       = cellSize;
            this.cellCreateFunc = cellCreateFunc;

            cells = new T[cellsPerXAxis, cellsPerYAxis, cellsPerZAxis];

            for (int y = 0; y < cellsPerYAxis; ++y)
            {
                for (int z = 0; z < cellsPerZAxis; ++z)
                {
                    for (int x = 0; x < cellsPerXAxis; ++x)
                    {
                        T cell = cellCreateFunc(this, x, y, z);
                        cells[x, y, z] = cell;
                    }
                }
            }

            bounds = BoundsExt.New(Vector3.zero, new Vector3(
                                       cellSize * (float)cellsPerXAxis,
                                       cellSize * (float)cellsPerYAxis,
                                       cellSize * (float)cellsPerZAxis));
        }
Exemplo n.º 2
0
        public Bounds GetCellBounds(int x, int y, int z)
        {
            var min = new Vector3(x * CellSize, y * CellSize, z * CellSize) + Position;
            var max = min + Vector3Ext.New(CellSize);

            return(BoundsExt.New(min, max));
        }