UpdatePointsBuffer() public method

public UpdatePointsBuffer ( ) : void
return void
Example #1
0
		public static LinesGisLayer GenerateDistanceGrid(Game Game, DVector2 lonLatLeftBottomCorner, double step, int xStepsCount, int yStepsCount, Color color)
		{

			List<Gis.GeoPoint> points = new List<Gis.GeoPoint>();

			// Too lazy
			//var yPoint = lonLatLeftBottomCorner;
			
			//for (int row = 0; row < yStepsCount; row++) {
			//
			//	yPoint = GeoHelper.RhumbDestinationPoint(yPoint, 0, step);
			//
			//	for (int col = 0; col < xStepsCount; col++)
			//	{
			//		var coords0 = GeoHelper.RhumbDestinationPoint(yPoint, 90, step * col);
			//		//var coords1 = GeoHelper.RhumbDestinationPoint(coords0, 90, step);
			//
			//		points.Add(new Gis.GeoPoint {
			//			Lon = DMathUtil.DegreesToRadians(coords0.X),
			//			Lat = DMathUtil.DegreesToRadians(coords0.Y),
			//			Color = color
			//		});
			//		//points.Add(new Gis.GeoPoint {
			//		//	Lon = DMathUtil.DegreesToRadians(coords1.X),
			//		//	Lat = DMathUtil.DegreesToRadians(coords1.Y),
			//		//	Color = color
			//		//});
			//	}
			//}

			for (int col = 0; col < xStepsCount; col++) {
				var xPoint = GeoHelper.RhumbDestinationPoint(lonLatLeftBottomCorner, 90, step * col);
				
				for (int row = 0; row < yStepsCount; row++) {
					var coords0 = GeoHelper.RhumbDestinationPoint(xPoint, 0, step * row);
					//var coords1 = GeoHelper.RhumbDestinationPoint(xPoint, 0, step * (row + 1));
			
					points.Add(new Gis.GeoPoint {
						Lon = DMathUtil.DegreesToRadians(coords0.X),
						Lat = DMathUtil.DegreesToRadians(coords0.Y),
						Color = color
					});
					//points.Add(new Gis.GeoPoint
					//{
					//	Lon = DMathUtil.DegreesToRadians(coords1.X),
					//	Lat = DMathUtil.DegreesToRadians(coords1.Y),
					//	Color = color
					//});
				}
			}


			var indeces = new List<int>();

			for (int col = 0; col < xStepsCount-1; col++) {
				for (int row = 0; row < yStepsCount; row++) {
					indeces.Add(row + (col+1) * yStepsCount);
					indeces.Add(row + col*yStepsCount);
				}
			}

			for (int row = 0; row < yStepsCount-1; row++)
			{
				for (int col = 0; col < xStepsCount; col++)
				{
					indeces.Add(col * yStepsCount + row);
					indeces.Add((col) * yStepsCount + row + 1);
				}
			}

			var newPoints = new List<Gis.GeoPoint>();
			foreach (var ind in indeces) {
				newPoints.Add(points[ind]);
			}

			var linesLayer = new LinesGisLayer(Game, newPoints.Count);
			Array.Copy(newPoints.ToArray(), linesLayer.PointsCpu, newPoints.Count);
			linesLayer.UpdatePointsBuffer();
			linesLayer.Flags = (int)(LineFlags.THIN_LINE);

			return linesLayer;
		}
Example #2
0
		public static LinesGisLayer GenerateGrid(Game Game, DVector2 leftTop, DVector2 rightBottom, int dimX, int dimY, Color color, MapProjection projection, bool keepQuad = false)
		{
			var lt = projection.WorldToTilePos(leftTop.X,		leftTop.Y, 0);
			var rb = projection.WorldToTilePos(rightBottom.X,	rightBottom.Y, 0);

			if (keepQuad) {
				rb.Y = lt.Y + (rb.X - lt.X);
			}

			double stepX = Math.Abs(rb.X - lt.X) / (dimX - 1);
			double stepY = Math.Abs(rb.Y - lt.Y) / (dimY - 1);


			List<Gis.GeoPoint> points = new List<Gis.GeoPoint>();
			
			// Too lazy
			for (int row = 1; row < dimY-1; row++) {
				for (int col = 0; col < dimX-1; col++) {
					var coords0 = projection.TileToWorldPos(lt.X + stepX * col,		lt.Y + stepY * row, 0);
					var coords1 = projection.TileToWorldPos(lt.X + stepX * (col+1), lt.Y + stepY * row, 0);

					points.Add(new Gis.GeoPoint {
						Lon		= DMathUtil.DegreesToRadians(coords0.X),
						Lat		= DMathUtil.DegreesToRadians(coords0.Y),
						Color	= color
					});
					points.Add(new Gis.GeoPoint {
						Lon		= DMathUtil.DegreesToRadians(coords1.X),
						Lat		= DMathUtil.DegreesToRadians(coords1.Y),
						Color	= color
					});
				} 
			}
			for (int col = 1; col < dimX-1; col++) {
				for (int row = 0; row < dimY-1; row++) {
					var coords0 = projection.TileToWorldPos(lt.X + stepX * col,	lt.Y + stepY * row, 0);
					var coords1 = projection.TileToWorldPos(lt.X + stepX * col, lt.Y + stepY * (row+1), 0);

					points.Add(new Gis.GeoPoint {
						Lon		= DMathUtil.DegreesToRadians(coords0.X),
						Lat		= DMathUtil.DegreesToRadians(coords0.Y),
						Color	= color
					});
					points.Add(new Gis.GeoPoint {
						Lon		= DMathUtil.DegreesToRadians(coords1.X),
						Lat		= DMathUtil.DegreesToRadians(coords1.Y),
						Color	= color
					});
				} 
			}

			var linesLayer = new LinesGisLayer(Game, points.Count);
			Array.Copy(points.ToArray(), linesLayer.PointsCpu, points.Count);
			linesLayer.UpdatePointsBuffer();
			linesLayer.Flags = (int)(LineFlags.THIN_LINE);

			return linesLayer;
		}