/// <summary> /// Gets the request URL for the given face given the API parameters. /// </summary> /// <param name="face">The <see cref="Face"/> whose texture is to be downloaded.</param> /// <returns>The URL for downloading the texture of this <see cref="Face"/></returns> public string GetURL(StreetView.Face face) { var sb = new StringBuilder(k_BaseURL).Append("key=").Append(options.key); switch (options.mode) { case StreetView.Mode.Coordinates: sb.Append("&location=").Append(options.location.lat).Append(",").Append(options.location.lng); break; case StreetView.Mode.PanoID: sb.Append("&pano=").Append(options.panoID); break; case StreetView.Mode.Location: sb.Append("&location=").Append(options.place); break; } sb.Append("&size=").Append(options.resolution).Append("x").Append(options.resolution) .Append("&fov=").Append(options.fov) .Append("&heading=").Append((options.heading % 360) + EnumUtility.HeadingFrom(face) + options.heading) .Append("&pitch=").Append(EnumUtility.PitchFrom(face) + options.pitch) .Append("&radius=").Append(options.radius) .Append("&source=").Append(EnumToString.From(options.source)); return(sb.ToString()); }
void AddToCubemap(StreetView.Face face, Texture2D tex) { if (cubemap == null) cubemap = new Cubemap(downloader.options.resolution, TextureFormat.ARGB32, false); CubemapFace cubemapFace = CubemapFace.PositiveX; switch (face) { case StreetView.Face.Up: cubemapFace = CubemapFace.NegativeY; break; case StreetView.Face.Down: cubemapFace = CubemapFace.PositiveY; break; case StreetView.Face.Front: cubemapFace = CubemapFace.PositiveZ; break; case StreetView.Face.Back: cubemapFace = CubemapFace.NegativeZ; break; case StreetView.Face.Left: cubemapFace = CubemapFace.NegativeX; break; case StreetView.Face.Right: cubemapFace = CubemapFace.PositiveX; break; } cubemap.SetPixels(tex.GetPixels(), cubemapFace); cubemap.Apply(); material.SetTexture("_Cubemap", cubemap); targetRenderer.material = material; }
/// <summary> /// Downloads a single face texture /// </summary> /// <param name="face"></param> public void DownloadFace(StreetView.Face face) { var url = GetURL(face); var client = new RestClient(); var request = new RestRequest(url); client.ExecuteAsync(request, response => { Dispatcher.Enqueue(() => { if (m_Disposed) { return; } if (response.IsSuccessful()) { var tex = new Texture2D(1, 1, TextureFormat.RGB565, false); tex.LoadImage(response.RawBytes, false); tex.Apply(); SetFaceTexture(face, tex); OnFaceTextureDownloaded?.Invoke(face, tex); } else { OnFaceTextureFailed?.Invoke(face, response.GetException().ToString()); } }); }); }
public static int PitchFrom(StreetView.Face face) { switch (face) { case StreetView.Face.Up: return(90); case StreetView.Face.Down: return(-90); default: return(0); } }
/// <summary> /// Gets the Texture2D corresponding to a <see cref="Face"/> /// </summary> /// <param name="face">The <see cref="Face"/> whose Texture2D is to be fetched.</param> /// <returns>The Texture2D corresponding to the passed <see cref="Face"/></returns> public Texture2D GetFaceTexture(StreetView.Face face) { if (textures.ContainsKey(face)) { return(textures[face]); } else { return(null); } }
/// <summary> /// Sets a Texture2D to the given <see cref="Face"/> /// </summary> /// <param name="face">The <see cref="Face"/> whose texture is to be set.</param> /// <param name="texture">The texture to be set.</param> public void SetFaceTexture(StreetView.Face face, Texture2D texture) { if (textures.ContainsKey(face)) { MonoBehaviour.Destroy(textures[face]); textures[face] = texture; } else { textures.Add(face, texture); } }
public static int HeadingFrom(StreetView.Face face) { switch (face) { case StreetView.Face.Right: return(90); case StreetView.Face.Back: return(180); case StreetView.Face.Left: return(270); default: return(0); } }