Esempio n. 1
0
        public static Color[] ToColorsA(RayTraceChunkManager rtc, int bits)
        {
            int dcx = rtc.getChunkSize().x;
            int dcy = rtc.getChunkSize().y;
            int dcz = rtc.getChunkSize().z;
            int dgx = rtc.getSizeX();
            int dgy = rtc.getSizeY();
            int dgz = rtc.getSizeZ();

            Color[,,] colors = new Color[dgx, (dgy / bits), dgz];
            for (int cx = 0; cx < dcx; cx++)
            {
                for (int cy = 0; cy < dcy; cy++)
                {
                    for (int cz = 0; cz < dcz; cz++)
                    {
                        RayTraceChunk chunk = rtc.getChunk(cx, cy, cz);
                        for (int bx = 0; bx < Const.ChunkSize; bx++)
                        {
                            for (int by = 0; by < Const.ChunkSize / bits; by++)
                            {
                                for (int bz = 0; bz < Const.ChunkSize; bz++)
                                {
                                    int iv = 0;
                                    for (int n = 0; n < bits; n++)
                                    {
                                        iv |= chunk.testBlock(bx, by * bits + n, bz) ? (1 << n) : 0;
                                    }
                                    float a  = iv / (float)((1 << bits) - 1);
                                    int   gx = cx * Const.ChunkSize + bx;
                                    int   gy = cy * Const.ChunkSize / bits + by;
                                    int   gz = cz * Const.ChunkSize + bz;
                                    colors[gx, gy, gz] = new Color(0, 0, 0, a);
                                }
                            }
                        }
                    }
                }
            }

            int sizeX = colors.GetLength(0);
            int sizeY = colors.GetLength(1);
            int sizeZ = colors.GetLength(2);

            Color[] rlt = new Color[sizeX * sizeY * sizeZ];
            for (int x = 0; x < sizeX; x++)
            {
                for (int y = 0; y < sizeY; y++)
                {
                    for (int z = 0; z < sizeZ; z++)
                    {
                        rlt[z * sizeY * sizeX + y * sizeX + x] = colors[x, y, z];
                    }
                }
            }
            return(rlt);
        }