public void SetPatternType(int size, Size count, int[] xList, bool keepCorners) { _patternSize = size; _patternCount = count; var eckenVorher = ControlPoints.Where(c => c.ControlPointType == ControlPointType.IsEcke).ToArray(); ControlPoints.Clear(); BoundingControlPoints.Clear(); Enumerable.Range(0, count.Width * count.Height).ToList().ForEach(p => ControlPoints.Add(new ControlPoint())); var dy = _resolution.Height / (count.Height - 1); var y = 0; for (var i = 0; i < ControlPoints.Count; i++) { if (i > 0 && i % count.Width == 0) { y += dy; if (y >= _resolution.Height) { y = _resolution.Height - 1; } } ControlPoints[i].Y = ControlPoints[i].V = y; } for (var iy = 0; iy < count.Height; iy++) { for (var ix = 0; ix < count.Width; ix++) { var index = iy * count.Width + ix; ControlPoints[index].X = ControlPoints[index].U = xList[ix]; } } BoundingControlPoints.AddRange(ControlPoints.Take(count.Width)); for (var iy = 1; iy < count.Height; iy++) { BoundingControlPoints.Add(ControlPoints[iy * count.Width + (count.Width - 1)]); } for (var ix = 1; ix < count.Width - 1; ix++) { BoundingControlPoints.Add(ControlPoints[count.Height * count.Width - ix - 1]); } for (var iy = count.Height - 1; iy > 0; iy--) { BoundingControlPoints.Add(ControlPoints[iy * count.Width]); } ControlPoints[0].ControlPointType = ControlPointType.IsEcke; ControlPoints[count.Width - 1].ControlPointType = ControlPointType.IsEcke; ControlPoints[count.Width * (count.Height - 1)].ControlPointType = ControlPointType.IsEcke; ControlPoints[count.Width * count.Height - 1].ControlPointType = ControlPointType.IsEcke; foreach (var cp in BlacklevelControlPoints) { cp.X = cp.U; cp.Y = cp.V; } if (keepCorners && eckenVorher.Any()) { var ecken = ControlPoints.Where(c => c.ControlPointType == ControlPointType.IsEcke).ToArray(); for (var i = 0; i < eckenVorher.Length; i++) { ecken[i].X = eckenVorher[i].X; ecken[i].Y = eckenVorher[i].Y; } } Interpolate(ControlPoints); MakeTriangleStrip(); DetermineControlPointDirections(); }