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; }
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); }
protected void ComputePlane(Plane plane, LinkedListTriangle tri, Map map) { var point1 = tri.Point1; var point2 = tri.Point2; var point3 = tri.Point3; var vec1 = new Vector3(point1, map[point1.X, point1.Y]); var vec2 = new Vector3(point2, map[point2.X, point2.Y]); var vec3 = new Vector3(point3, map[point3.X, point3.Y]); plane.Init(vec1, vec2, vec3); }