/// <summary> /// A polyline path is computed from the coordinates, and then elevation values at both endpoints and equally-spaced locations along the polyline are returned. /// </summary> /// <param name="key">A Bing Maps Key.</param> /// <param name="points"> /// A set of coordinates on the Earth to use in elevation calculations.\n /// IEnumerable values can be float, double or Vector2. /// </param> /// <param name="samples">Specifies the number of equally-spaced elevation values to provide along a polyline path.</param> /// <param name="heights">Specifies which sea level model to use to calculate elevation.</param> /// <param name="output">Output format: JSON or XML</param> /// <returns>Instance of request.</returns> public static OnlineMapsBingMapsElevation GetElevationByPolyline(string key, IEnumerable points, int samples, Heights heights = Heights.sealevel, Output output = Output.json) { return(new OnlineMapsBingMapsElevation(new PolylineParams(key, heights, output, points, samples))); }
private void BuildingDimensions() { EditorGUILayout.LabelField("Dimensions", EditorStyles.boldLabel); choice1 = (Area) EditorGUILayout.EnumPopup("Area", choice1); switch (choice1) { case Area.dimensions: _building.startingPoints = null; _width = EditorGUILayout.FloatField("Width", _width); _depth = EditorGUILayout.FloatField("Depth", _depth); _building.width0 = _width; _building.width1 = _depth; break; case Area.points: _building.width0 = 0f; _building.width1 = 0f; _p1 = EditorGUILayout.Vector2Field("point 1", _p1); _p2 = EditorGUILayout.Vector2Field("point 2", _p2); _p3 = EditorGUILayout.Vector2Field("point 3", _p3); _p4 = EditorGUILayout.Vector2Field("point 4", _p4); if (_p1 != _p2 && _p1 != _p3 && _p1 != _p4 && _p2 != _p3 && _p2 != _p4 && _p3 != _p4) { _building.startingPoints = new Vector3[4]; _building.startingPoints[0] = new Vector3(_p1.x, 0f, _p1.y); _building.startingPoints[1] = new Vector3(_p2.x, 0f, _p2.y); _building.startingPoints[2] = new Vector3(_p3.x, 0f, _p3.y); _building.startingPoints[3] = new Vector3(_p4.x, 0f, _p4.y); } break; default: _building.width0 = 0f; _building.width1 = 0f; _building.startingPoints = null; break; } choice2 = (Heights) EditorGUILayout.EnumPopup("Height", choice2); switch (choice2) { case Heights.floorCount: _floors = EditorGUILayout.IntField("Floor Count", _floors); _building.floorCount = _floors; _building.floorHeight = 0f; break; case Heights.floorHeight: _height = EditorGUILayout.FloatField("Floor Height", _height); _building.floorHeight = _height; _building.floorCount = 0; break; case Heights.floorCountAndHeight: _floors = EditorGUILayout.IntField("Floor Count", _floors); _height = EditorGUILayout.FloatField("Floor Height", _height); _building.floorHeight = _height; _building.floorCount = _floors; break; default: _building.floorHeight = 0f; _building.floorCount = 0; break; } }
public Params(string key, Heights heights, Output output) { this.key = key; this.heights = heights; this.output = output; }
public PointsParams(string key, Heights heights, Output output, IEnumerable points) : base(key, heights, output) { this.points = points; }
/// <summary> /// The rectangular area defined by the four bounding box coordinates is divided into rows and columns. \n /// The edges of the bounding box account for two of the rows and two of the columns. /// Elevations are returned for the vertices of the grid created by the rows and columns. /// </summary> /// <param name="key">A Bing Maps Key.</param> /// <param name="leftLongitude">Left longitude</param> /// <param name="topLatitude">Top latitude</param> /// <param name="rightLongitude">Right longitude</param> /// <param name="bottomLatitude">Bottom latitude</param> /// <param name="rows">Number of rows to use to divide the bounding box area into a grid.</param> /// <param name="cols">Number of columns to use to divide the bounding box area into a grid.</param> /// <param name="heights">Specifies which sea level model to use to calculate elevation.</param> /// <param name="output">Output format: JSON or XML</param> /// <returns>Instance of request.</returns> public static OnlineMapsBingMapsElevation GetElevationByBounds(string key, double leftLongitude, double topLatitude, double rightLongitude, double bottomLatitude, int rows, int cols, Heights heights = Heights.sealevel, Output output = Output.json) { return(new OnlineMapsBingMapsElevation(new BoundsParams(key, heights, output, leftLongitude, topLatitude, rightLongitude, bottomLatitude, rows, cols))); }
public SeaLevelParams(string key, Heights heights, Output output, IEnumerable points) : base(key, heights, output, points) { }
public PolylineParams(string key, Heights heights, Output output, IEnumerable points, int samples) : base(key, heights, output, points) { this.samples = samples; }
public int height(Heights type) { double r; switch (type) { case Heights.Base: { r = 0.5*this.base_.size_.h; r = Math.Round(r); return (int) r; } case Heights.Sup: { r = 0.8*this.supInfo.size_.h; r = Math.Round(r); return (int) r; } case Heights.Sub: { r = 0.8*this.subInfo.size_.h; r = Math.Round(r); return (int) r; } case Heights.Subsup: { r = 0.3*this.subInfo.size_.h; r = Math.Round(r); return (int) r; } } return 0; }
public override Blocks GenerateBlock2(Vector2i position, Heights macroHeight) { var block = base.GenerateBlock2(position, macroHeight); if (Zone.Biome.Type == BiomeType.TestWaves) { var height = Mathf.Sin(position.X / 5f) * 5; var heights = new Heights(macroHeight.Main + height, macroHeight.Underground + height, macroHeight.Base + height); block = block.MutateHeight(heights); } else if (Zone.Biome.Type == BiomeType.TestBaseOreAndGround) { var baseHeight = _generator.GetSimplex(position.X / 20f, position.Z / 20f) * 3 + macroHeight.Base; var resourcesHeight = Interpolation.SmoothestStep(Mathf.Clamp01((float)_generator.GetSimplex(position.X / 10f, position.Z / 10f))) * 10 + macroHeight.Underground - 1; var groundHeight = Interpolation.SmoothestStep((_generator.GetSimplex(position.Z / 40f, position.X / 40f) + 1) / 2) * 10 - 12 + macroHeight.Main; //var groundHeight = -1; //var underground = resourcesHeight > baseHeight ? BlockType.GoldOre : BlockType.Empty; var underground = BlockType.GoldOre; BlockType ground; /* * if (groundHeight > resourcesHeight && groundHeight > baseHeight) * ground = BlockType.Grass; * else * ground = BlockType.Empty; */ ground = BlockType.Grass; block = new Blocks(ground, underground, new Heights((float)groundHeight, resourcesHeight, (float)baseHeight)); } else if (Zone.Biome.Type == BiomeType.TestBaseCavesAndGround) { //"Hourglass" shaped hole to the base layer // //-\ /--- // \ / // \ / // / \ // / \ //-/--------\-- var distance = Vector2.Distance(Vector2.Zero, position); if (distance < 15) { var baseHeight = -10; var underHeight = distance < 10 ? -10 + (10 - distance) : -10; var groundHeight = distance < 10 ? -10 + distance : 0; /* * var baseHeight = _generator.GetSimplex(position.X / 30f, position.Z / 30f) * 3 + macroHeight.BaseHeight; * var undergroundHeight = (_generator.GetSimplex(position.X / 20f, position.Z / 20f) + 1); * undergroundHeight = Math.Pow(undergroundHeight, 4) + macroHeight.UndergroundHeight; * var groundHeight = _generator.GetSimplex(position.X / 5f, position.Z / 5f) + macroHeight.Layer1Height; */ BlockType underground; if (underHeight > groundHeight || underHeight <= baseHeight) { underground = BlockType.Empty; } else { underground = BlockType.Cave; } BlockType ground = groundHeight >= underHeight ? BlockType.Grass : BlockType.Empty; block = new Blocks(ground, underground, new Heights(groundHeight, underHeight, baseHeight)); } else { block = Blocks.Empty; } } else if (Zone.Biome.Type == BiomeType.TestBaseOreGroundColumn) { //Column made from ground and ore, to test very steep slopes (vertical) //Column has half-circle form if (position.X < 0 && Vector2i.Distance(position, Vector2i.Zero) < 5) { //All blocks the same //blocks = new Blocks(BlockType.Grass, BlockType.GoldOre, new Heights(10, 5, -5)); //All block has different heights var baseHeight = _random.Range(0, 5); var underHeight = baseHeight + _random.Range(0, 5); var groundHeight = underHeight + _random.Range(0, 5); block = new Blocks(BlockType.Grass, BlockType.GoldOre, new Heights(groundHeight, underHeight, baseHeight)); } else { block = new Blocks(BlockType.Empty, BlockType.Empty, new Heights(-10, -10, -10)); } } else if (Zone.Biome.Type == BiomeType.TestBaseOrePyramidGround) { //Special test case if (position == (3, -21)) { return(new Blocks(Zone.Biome.DefaultMainBlock.Block, Zone.Biome.DefaultUndergroundBlock.Block, new Heights(0, 1, -5))); } if (position == (-15, -13) || position == (-15, -14)) { return(new Blocks(Zone.Biome.DefaultMainBlock.Block, Zone.Biome.DefaultUndergroundBlock.Block, new Heights(0, 1, -5))); } if (position == (-18, 12) || position == (-18, 13) || position == (-17, 13)) { return(new Blocks(Zone.Biome.DefaultMainBlock.Block, Zone.Biome.DefaultUndergroundBlock.Block, new Heights(0, 1, -5))); } if (position == (13, 14) || position == (13, 15) || position == (12, 14) || position == (12, 15)) { return(new Blocks(Zone.Biome.DefaultMainBlock.Block, Zone.Biome.DefaultUndergroundBlock.Block, new Heights(0, 1, -5))); } var distance = Vector2.Distance(Vector2.Zero, position); var baseHeight = -5f; var oreHeight = 7 - distance; var grassHeight = 0; block = new Blocks(Zone.Biome.DefaultMainBlock.Block, Zone.Biome.DefaultUndergroundBlock.Block, new Heights(grassHeight, oreHeight, baseHeight)); } else { if (Zone.Biome.Type == BiomeType.TestTunnel) { //Tunnel is line defined by ax + by + c = 0 const float a = 2f, b = -1f, c = 5f; const float tunnelWidth = 15; const float tunnelCenterHeight = 0; //Mountain defined as cone Vector2 mountCenter = Vector2.Zero; const float mountSize = 20; var distanceToTunnel = Mathf.Abs(a * position.X + b * position.Z + c) / Mathf.Sqrt(a * a + b * b); var distanceToMount = Vector2.Distance(position, mountCenter); var tunnelTurbulence = (float)(_generator.GetSimplex(position.X / 10d, position.Z / 10d) * 2 + _generator.GetSimplex(position.Z / 70d, position.X / 70d) * 5); //Make tunnel floor var baseHeight = 0f; if (distanceToTunnel < tunnelWidth) { baseHeight += tunnelCenterHeight - Mathf.Sqrt(tunnelWidth * tunnelWidth - distanceToTunnel * distanceToTunnel) + tunnelTurbulence; } var underHeight = 0f; if (distanceToTunnel < tunnelWidth) { underHeight += tunnelCenterHeight + Mathf.Sqrt(tunnelWidth * tunnelWidth - distanceToTunnel * distanceToTunnel) + tunnelTurbulence; } var groundHeight = 5f; if (distanceToMount < mountSize) { groundHeight += mountSize - distanceToMount; } block = new Blocks(Zone.Biome.DefaultMainBlock.Block, Zone.Biome.DefaultUndergroundBlock.Block, new Heights(groundHeight, underHeight, baseHeight)); } } return(block); }