Ejemplo n.º 1
0
        // Will be able to use this algorithm for:
        // Land - This is the equivelent of ExtendLand
        // Towns - This is the equivelent of ExtendTowns
        // Landmarks/Terrain - We can spread landmarks over the world, we can create mountain landmarks by spreading their size out then modifying the terrain.
        // Monsters - We can spread monster villages out, simmilar to towns.
        // Dungeons - We can use this to smooth dungeons out, so that there are less or more pointy bits. Alternatively we can also use this to spread out some side sections.
        // Anything else?
        public override void ProcessCell(IRuntimeContext context, int[] input, int[] output, long x, long y, long z, int i, int j, int k, int width, int height, int depth, int ox, int oy, int oz)
        {
            int selected = context.GetRandomRange(x, y, 0, 8, context.Modifier);

            switch (selected)
            {
            case 0:
                output[(i + ox) + (j + oy) * width + (k + oz) * width * height] = input[((i + ox) + 1) + ((j + oy) + 1) * width + (k + oz) * width * height];
                break;

            case 1:
                output[(i + ox) + (j + oy) * width + (k + oz) * width * height] = input[((i + ox) - 1) + ((j + oy) - 1) * width + (k + oz) * width * height];
                break;

            case 2:
                output[(i + ox) + (j + oy) * width + (k + oz) * width * height] = input[((i + ox) - 1) + ((j + oy) + 1) * width + (k + oz) * width * height];
                break;

            case 3:
                output[(i + ox) + (j + oy) * width + (k + oz) * width * height] = input[((i + ox) + 1) + ((j + oy) - 1) * width + (k + oz) * width * height];
                break;

            case 4:
                output[(i + ox) + (j + oy) * width + (k + oz) * width * height] = input[((i + ox) + 0) + ((j + oy) + 1) * width + (k + oz) * width * height];
                break;

            case 5:
                output[(i + ox) + (j + oy) * width + (k + oz) * width * height] = input[((i + ox) + 1) + ((j + oy) + 0) * width + (k + oz) * width * height];
                break;

            case 6:
                output[(i + ox) + (j + oy) * width + (k + oz) * width * height] = input[((i + ox) + 0) + ((j + oy) - 1) * width + (k + oz) * width * height];
                break;

            case 7:
                output[(i + ox) + (j + oy) * width + (k + oz) * width * height] = input[((i + ox) - 1) + ((j + oy) + 0) * width + (k + oz) * width * height];
                break;
            }
        }
Ejemplo n.º 2
0
        public override void ProcessCell(IRuntimeContext context, int[] input, int[] output, long x, long y, long z, int i, int j, int k, int width, int height, int depth, int ox, int oy, int oz)
        {
            int ocx = ((x - Math.Abs(i)) % 2 == 0 ? 0 : Math.Abs(i % 2)) - (i % 2 == -1 ? 1 : 0);
            int ocy = ((y - Math.Abs(j)) % 2 == 0 ? 0 : Math.Abs(j % 2)) - (j % 2 == -1 ? 1 : 0);

            //int ocx_e = ((x - i) % 2 == 0 ? 0 : ((i + 1) % 2));
            //int ocx_e = (x % 2 != 0) ? (int)((i + 1) % 2) : 0;
            //int ocy_s = (y % 2 != 0) ? (int)((j + 1) % 2) : 0;

            int ocz = 0;

            int current = input[
                (i / 2) + ox + ocx +
                ((j / 2) + oy + ocy) * width +
                (k + oz + ocz) * width * height];

            if (this.Mode == ZoomType.Square)
            {
                output[i + ox + (j + oy) * width + (k + oz) * width * height] = current;
            }
            else
            {
                int selected;

                bool ymod = (y) % 2 == 0;
                bool xmod = (x) % 2 == 0;

                if (!xmod && !ymod)
                {
                    if (this.Mode == ZoomType.Fuzzy)
                    {
                        selected = context.GetRandomRange(x, y, 0, 4);
                    }
                    else
                    {
                        selected = context.GetRandomRange(x, y, 0, 3);
                    }
                }
                else if (xmod && ymod)
                {
                    selected = 4;
                }
                else
                {
                    selected = context.GetRandomRange(x, y, 0, 2);
                }

                int ocx_e = ((x - Math.Abs(i)) % 2 == 0 ? 0 : Math.Abs((i + 1) % 2)) - ((i + 1) % 2 == -1 ? 1 : 0);
                int east  = input[((i + 1) / 2 + ox + ocx_e) + (j / 2 + oy + ocy) * width + ((k) + oz + ocz) * width * height];

                switch (selected)
                {
                case 0:
                    output[i + ox + (j + oy) * width + (k + oz) * width * height] = current;
                    break;

                case 1:

                    int ocy_s = ((y - Math.Abs(j)) % 2 == 0 ? 0 : Math.Abs((j + 1) % 2)) - ((j + 1) % 2 == -1 ? 1 : 0);
                    int south = input[(i / 2 + ox + ocx) + ((j + 1) / 2 + oy + ocy_s) * width + (k + oz + ocz) * width * height];

                    if (xmod)
                    {
                        output[i + ox + (j + oy) * width + (k + oz) * width * height] = south;
                    }
                    else if (ymod)
                    {
                        output[i + ox + (j + oy) * width + (k + oz) * width * height] = east;
                    }
                    else
                    {
                        output[i + ox + (j + oy) * width + (k + oz) * width * height] = south;
                    }
                    break;

                case 2:
                    output[i + ox + (j + oy) * width + (k + oz) * width * height] = east;
                    break;

                case 3:
                    int southEast = input[((i + 2) / 2 + ox + ocx) + ((j + 2) / 2 + oy + ocy) * width + (k + oz + ocz) * width * height];
                    output[i + ox + (j + oy) * width + (k + oz) * width * height] = southEast;
                    break;

                case 4:
                    output[i + ox + (j + oy) * width + (k + oz) * width * height] = current;
                    break;
                }
            }
        }