示例#1
0
        private void Heightmap_HeightInput(object sender, HeightmapEventArgs e)
        {
            var height = Math.Sin(_sin + _movement)*2;

            e.Height = (float)height;
            var highlight = (byte)((height*16f)+32f);

            e.Color = Color.FromArgb(0xff, highlight, highlight, highlight);

            _sin += 0.03;

            if( e.GridX == HeightMap.LengthSegments &&
                e.GridY == HeightMap.HeightSegments )
            {
                _sin = 0;
                _movement += 0.05;
            }
        }
示例#2
0
        private void Heightmap_HeightInput(object sender, HeightmapEventArgs e)
        {
            var n = 0f;
            var x = e.GridX;
            var z = e.GridY;
            if (x <= 0 || z <= 0 || x >= HeightMap.LengthSegments-1 || z >= HeightMap.HeightSegments-1)
            {
                return;
            }

            var frame1 = _frameNumber;
            var frame0 = _frameNumber ^ 1;

            n = ((_waveMap[frame1, x - 1, z] +
                _waveMap[frame1, x + 1, z] +
                _waveMap[frame1, x, z - 1] +
                _waveMap[frame1, x, z + 1]) / 2) -
                _waveMap[frame0, x, z];
            n = n - n / 16;
            _waveMap[frame0, x, z] = n;

            e.Height = n;
        }