Пример #1
0
        public NoiseControl()
        {
            InitializeComponent();

            var map = new NoiseMap();
            var builder = new PlaneNoiseMapBuilder()
            {
                DestNoiseMap = map,
            };
            builder.SetDestSize(pictureBox.Width, pictureBox.Height);
            m_noiseBuilder = builder;

            var image = new SharpNoise.Utilities.Imaging.Image();
            var renderer = new ImageRenderer()
            {
                SourceNoiseMap = map,
                DestinationImage = image,
            };

            if (greyRadioButton.Checked)
                renderer.BuildGrayscaleGradient();
            else if (terrainRadioButton.Checked)
                renderer.BuildTerrainGradient();
            else
                throw new Exception();

            m_imageRenderer = renderer;
        }
Пример #2
0
        public void PlanarRenderTest()
        {
            var plane = new PlaneNoiseMapBuilder();
            plane.SetBounds(-1, 1, -1, 1);
            plane.SetDestSize(256, 256);
            plane.SourceModule = module;
            plane.DestNoiseMap = noiseMap;
            plane.EnableSeamless = true;
            plane.Build();

            renderer.SourceNoiseMap = noiseMap;
            renderer.DestinationImage = textureImage;
            renderer.Render();

            // TODO: Add some asserts
        }
Пример #3
0
        void SetupNoiseMapBuilder()
        {
            // Set up noise module tree
            // TranslatePoint is used to shift the generated noise over time
            TimeTranslator = new TranslatePoint
            {
                // Scales the generated noise values down to 80%
                Source0 = new ScaleBias
                {
                    Scale = 0.8,
                    Bias = 0,
                    // Scale coordinates down to get some rougher structures
                    Source0 = new ScalePoint
                    {
                        // Scale down xz-plane
                        XScale = 0.0375,
                        ZScale = 0.0375,
                        // Scale down "time"
                        YScale = 0.625,
                        Source0 = new Billow(),
                    },
                },
            };

            // Set up target noise map and noise map builder
            NoiseMap = new NoiseMap();
            NoiseMapBuilder = new PlaneNoiseMapBuilder
            {
                DestNoiseMap = NoiseMap,
                SourceModule = TimeTranslator,
            };
            NoiseMapBuilder.SetBounds(0, LongitudeBands, 0, LatitudeBands);
            NoiseMapBuilder.SetDestSize(LongitudeBands, LatitudeBands);
        }