public override Vector3 MapToWorldPosition(Vector2Int point) { var innerRadius = HexMeshUtility.GetInnerRadius(radius); var xOffset = point.x + point.y * 0.5f - (int)(point.y / 2); var pt = new Vector3 { x = xOffset * innerRadius * 2, y = _mapData == null || _heightMap == null ? 0 : GetElevation(_heightMap[point.y * _mapData.width + point.x]), z = point.y * radius * 1.5f }; return(pt); }
public HexMeshData(float radius, float border = 0.2f) { this._border = Mathf.Clamp01(border); _outerRadius = radius; _innerRadius = HexMeshUtility.GetInnerRadius(_outerRadius); _vertices = new List <Vector3>(); _triangles = new List <int>(); _colors = new List <Color>(); _uv = new List <Vector2>(); _corners = new [] { new Vector3(0f, 0f, _outerRadius), new Vector3(_innerRadius, 0f, 0.5f * _outerRadius), new Vector3(_innerRadius, 0f, -0.5f * _outerRadius), new Vector3(0f, 0f, -_outerRadius), new Vector3(-_innerRadius, 0f, -0.5f * _outerRadius), new Vector3(-_innerRadius, 0f, 0.5f * _outerRadius), new Vector3(0f, 0f, _outerRadius) }; }