public void Initialize() { // //Debug.Log("Tile == NULL ?" + (tile == null)); List <Vector3> positions = this.tile.MapBounds.WorldCoordsCorners(); Vector3 origin = GeographicCoordinates.ConvertLonLatToXY(TileManager.OriginLongitude, TileManager.OriginLatitude, 0f).Vector3FromVector2XZ(); Vector3 heightVector = new Vector3(0f, height, 0f); corners.Add(positions[0] - origin + heightVector); corners.Add(positions[1] - origin + heightVector); corners.Add(positions[2] - origin + heightVector); corners.Add(positions[3] - origin + heightVector); MeshRenderer meshRenderer = gameObject.GetComponent <MeshRenderer>(); MeshFilter meshFilter = gameObject.GetComponent <MeshFilter>(); //Debug.Log("Origin : " + origin); //Debug.Log("Position0 : " + positions[0]); mesh = new Mesh(); //mesh.CreateQuad(positions[0] - origin, positions[1] - origin, positions[2] - origin, positions[3] - origin); mesh.CreateQuad(corners[0], corners[1], corners[2], corners[3]); meshFilter.mesh = mesh; meshRenderer.sharedMaterial = new Material(Shader.Find("Transparent/Diffuse")); meshRenderer.sharedMaterial.mainTexture = tile.Image; //transform.position = positions[0] - origin; //Debug.Log(tile.ToString()); }
/// <summary> /// 1 3 /// /// 0 2 /// </summary> /// <returns></returns> public List <Vector3> WorldCoordsCorners() { List <Vector3> corners = new List <Vector3>(); corners.Add(GeographicCoordinates.ConvertLonLatToXY(west, south, 0).Vector3FromVector2XZ()); corners.Add(GeographicCoordinates.ConvertLonLatToXY(west, north, 0).Vector3FromVector2XZ()); corners.Add(GeographicCoordinates.ConvertLonLatToXY(east, south, 0).Vector3FromVector2XZ()); corners.Add(GeographicCoordinates.ConvertLonLatToXY(east, north, 0).Vector3FromVector2XZ()); return(corners); }