コード例 #1
0
        /// <inheritdoc />
        public override Vector3 GetOffset(IModule3D noise, BlockCoordinates position)
        {
            var noise1 = noise.GetValue(position.X, position.Y, position.Z);
            var noise2 = MathF.Abs(noise.GetValue(-position.X, -position.Y, position.Z));
            var noise3 = noise.GetValue(-position.X, -position.Y, -position.Z);

            return(new Vector3(noise1 * 0.25f, -(noise2) * 0.25f, noise3 * 0.25f));
        }
コード例 #2
0
        public float GetValue(float x, float y, float z)
        {
            var value = Source.GetValue(x, y, z);

            if (value < LowerBound)
            {
                return(LowerBound);
            }
            return(value > UpperBound ? UpperBound : value);
        }
コード例 #3
0
        // public VerticalFill(IModule3D m1, IModule3D m2, float lower_cutoff, float upper_cutoff)
        // {
        //   this.m1 = m1;
        //   this.m2 = m2;
        // }

        public float GetValue(float x, float y, float z)
        {
            if (y < cutoff)
            {
                return(m1.GetValue(x, y, z));
            }
            else
            {
                return(m2.GetValue(x, y, z));
            }
        }
コード例 #4
0
        /// <summary>
        /// Generates an cube of values within a specified range based on the coordinates of the specified start values.
        /// <para>Caution: the <see cref="OutOfMemoryException"/> arrives quickly</para>
        /// </summary>
        /// <param name="module"><see cref="IModule3D"/> represent a noise generator.</param>
        /// <param name="width">The width of the cube (x-axis).</param>
        /// <param name="height">The height of the cube (y-axis).</param>
        /// <param name="depth">The depth" of the cube (z-axis).</param>
        /// <param name="scaleFactor">The scale factor of the cube.</param>
        /// <param name="range">Target range to convert the cube.</param>
        /// <param name="start_x">The start coordinate on the x-axis.</param>
        /// <param name="start_y">The start coordinate on the y-axis.</param>
        /// <param name="start_z">The start coordinate on the z-axis.</param>
        /// <returns>The resulting cube in target range.</returns>
        static public float[,,] GetCube(this IModule3D module, int width, int height, int depth, float scaleFactor, NoiseRange range, int start_x, int start_y, int start_z)
        {
            float[,,] rslt = new float[width, height, depth];
            for (int w = 0; w < width; w++)
            {
                for (int h = 0; h < height; h++)
                {
                    for (int d = 0; d < depth; d++)
                    {
                        rslt[w, h, d] = module.GetValue((start_x + w) * scaleFactor, (start_y + h) * scaleFactor, (start_z + d) * scaleFactor, range);
                    }
                }
            }

            return(rslt);
        }
コード例 #5
0
        private float[] GetThresholdMap(int cx, int cz, Biome[] biomes)
        {
            cx *= 16;
            cz *= 16;

            float[] thresholdMap = new float[16 * 16 * 256];

            for (int x = 0; x < 16; x++)
            {
                float rx = cx + x;
                for (int z = 0; z < 16; z++)
                {
                    float rz = cz + z;

                    for (int y = 255; y > 0; y--)
                    {
                        thresholdMap[x + ((y + (z << 8)) << 4)] = _depthNoise.GetValue(rx, y, rz);
                    }
                }
            }
            return(thresholdMap);
        }
コード例 #6
0
 /// <summary>
 /// Generates an output value within a specified range based on the coordinates of the specified inputs values.
 /// </summary>
 /// <param name="module"><see cref="IModule3D"/> represent the noise generator.</param>
 /// <param name="x">The input coordinate on the x-axis.</param>
 /// <param name="y">The input coordinate on the y-axis.</param>
 /// <param name="z">The input coordinate on the z-axis.</param>
 /// <param name="range">Target range to convert the output value.</param>
 /// <returns>The resulting output value in target range.</returns>
 static public float GetValue(this IModule3D module, float x, float y, float z, NoiseRange range)
 {
     return(ToRange(module.GetValue(x, y, z), range));
 }
コード例 #7
0
ファイル: OreDecorator.cs プロジェクト: kennyvv/MiNET-1.2
        public override void Decorate(ChunkColumn column, Biome biome, float[] thresholdMap, int x, int y, int z, bool surface,
                                      bool isBelowMaxHeight)
        {
            if (surface || column.GetBlock(x, y, z) != 1 && isBelowMaxHeight)
            {
                return;
            }

            if (isBelowMaxHeight && !surface)
            {
                int rx = column.x * 16 + x;
                int rz = column.z * 16 + z;

                var noise = _simplex.GetValue(rx, y, rz);

                foreach (var ore in Ores.Where(o => o.MinY <y && o.MaxY> y))
                {
                    var weightOffsets = (ore.MaxY > 30) ? HighWeightOffset : LowWeightOffset;

                    if (MathHelpers.Abs(noise) * 3f < ore.Rarity)
                    {
                        double weight = 0;
                        for (int i = 0; i < 4; i++)
                        {
                            weight += _random.NextDouble();
                        }

                        weight /= ore.Rarity;
                        weight  = weightOffsets[0] - MathHelpers.Abs((float)weight - weightOffsets[1]);

                        if (noise > weight)
                        {
                            int xOffset = 0;
                            int zOffset = 0;
                            int yOffset = 0;
                            for (int i = 0; i < _random.Next(0, ore.Abundance); i++)
                            {
                                int    offset  = _random.Next(0, 3);
                                double offset2 = _random.NextDouble();
                                if (offset.Equals(0) && offset2 < 0.4)
                                {
                                    xOffset += 1;
                                }
                                else if (offset.Equals(1) && offset2 >= 0.4 && offset2 < 0.65)
                                {
                                    yOffset += 1;
                                }
                                else
                                {
                                    zOffset += 1;
                                }

                                var mX = Math.Min(x + xOffset, x);
                                var my = Math.Min(y + yOffset, ore.MaxY);
                                var mz = Math.Min(z + zOffset, z);

                                if (column.GetBlock(mX, my, mz) != 1)
                                {
                                    return;
                                }
                                column.SetBlock(mX, my, mz, ore.ID);
                            }
                        }
                    }
                }
            }
        }
コード例 #8
0
ファイル: Abs.cs プロジェクト: CloneDeath/LibNoise
 public float GetValue(float x, float y, float z)
 {
     return(Math.Abs(Source.GetValue(x, y, z)));
 }
コード例 #9
0
 public float GetAlt2DValue(float x, float z)
 {
     return(altNoise2DModule.GetValue(x, 0f, z));
 }
コード例 #10
0
 public float GetRidgedMultiFractalValue(float x, float y, float z)
 {
     return(noiseModule.GetValue(x, y, z));
 }
コード例 #11
0
 public float GetValue(float x, float y, float z)
 {
     return(Source.GetValue(x, y, z) * Scale + Bias);
 }