Ejemplo n.º 1
0
        public GreedySubdivision(Map map, FloatMask mask)
        {
            Mask      = mask;
            HeightMap = map;
            heap      = new Heap(128);

            var w = HeightMap.Width;
            var h = HeightMap.Height;

            PointStates = new PointState[w, h];
            for (var x = 0; x < w; x++)
            {
                for (var y = 0; y < h; y++)
                {
                    PointStates[x, y] = PointState.Unused;
                }
            }

            InitMesh(new Vector2(0.0f, 0.0f),
                     new Vector2(0.0f, h - 1.0f),
                     new Vector2((w - 1.0f), (h - 1.0f)),
                     new Vector2((w - 1.0f), 0.0f));

            PointStates[0, 0]             = PointState.Used;
            PointStates[0, (h - 1)]       = PointState.Used;
            PointStates[(w - 1), (h - 1)] = PointState.Used;
            PointStates[(w - 1), 0]       = PointState.Used;

            PointCount = 4;
        }
Ejemplo n.º 2
0
        public GreedySubdivision(Map map, FloatMask mask)
        {
            Mask = mask;
            HeightMap = map;
            heap = new Heap(128);

            var w = HeightMap.Width;
            var h = HeightMap.Height;

            PointStates = new PointState[w,h];
            for (var x = 0; x < w; x++)
            {
                for (var y = 0; y < h; y++)
                {
                    PointStates[x, y] = PointState.Unused;
                }
            }

            InitMesh(new Vector2(0.0f, 0.0f),
                     new Vector2(0.0f, h - 1.0f),
                     new Vector2((w - 1.0f), (h - 1.0f)),
                     new Vector2((w - 1.0f), 0.0f));

            PointStates[0, 0] = PointState.Used;
            PointStates[0, (h - 1)] = PointState.Used;
            PointStates[(w - 1), (h - 1)] = PointState.Used;
            PointStates[(w - 1), 0] = PointState.Used;

            PointCount = 4;
        }
Ejemplo n.º 3
0
 public Terra(float errorThreshold, int pointCountLimit, float heightScale, float[,] heightValues, float[,] importanceMask)
 {
     ErrorThreshold = errorThreshold;
     HeightScale = heightScale;
     heightMap = Map.LoadFromArray(heightValues);
     PointCountLimit = (pointCountLimit > -1)? pointCountLimit : (heightMap.Width*heightMap.Height);
     mask = importanceMask.IsNullOrEmpty()
                ? new DefaultMask(heightMap.Width, heightMap.Height)
                : FloatMask.LoadFromArray(importanceMask);
     mesh = new GreedySubdivision(heightMap, mask);
 }