示例#1
0
        static void MakePerlinNoise3D(double[, ,] toFill, Vector3i fillStart, PerlinNoiseSettings3D settings)
        {
            int width;
            int height;
            int length;

            int effectiveX;
            int effectiveY;
            int effectiveZ;

            Vector3 regionSize = new Vector3();

            double frequency;
            double amplitude;

            width  = settings.size.X;
            height = settings.size.Y;
            length = settings.size.Z;

            regionSize.X = width / settings.zoom;
            regionSize.Y = width / settings.zoom;
            regionSize.Z = width / settings.zoom;

            for (int x = fillStart.X; x < fillStart.X + width; x++)
            {
                for (int y = fillStart.Y; y < fillStart.Y + height; y++)
                {
                    for (int z = fillStart.Z; z < fillStart.Z + length; z++)
                    {
                        effectiveX = x + settings.startingPoint.X;
                        effectiveY = y + settings.startingPoint.Y;
                        effectiveZ = z + settings.startingPoint.Z;

                        frequency = 1;
                        amplitude = 1;

                        for (int oct = 0; oct < settings.octaves; oct++)
                        {
                            double noise = SimpleNoise3D.GenInterpolatedNoise(effectiveX / settings.zoom * frequency,
                                                                              effectiveY / settings.zoom * frequency,
                                                                              effectiveZ / settings.zoom * frequency,
                                                                              settings.seed);
                            toFill[x, y, z] += amplitude * noise;

                            frequency *= settings.frequencyMulti;
                            amplitude *= settings.persistence;
                        }
                    }
                }
            }
        }
示例#2
0
        private void populatePremutations()
        {
            flatPremutationList = new float[premutationSize * premutationSize * premutationSize];
            int index;

            for (int x = 0; x < premutationSize; x++)
            {
                for (int y = 0; y < premutationSize; y++)
                {
                    for (int z = 0; z < premutationSize; z++)
                    {
                        index = x * premutationSize * premutationSize + y * premutationSize + z;
                        flatPremutationList[index] = SimpleNoise3D.GenFloatNoise(rng.Next(), rng.Next(), rng.Next(), settings.seed);
                    }
                }
            }
        }