夜風のMixedReality

xRと出会って変わった人生と出会った技術を書き残すためのGeekなHoloRangerの居場所

Microsoft Map-SDK for Unityを使用する その2 City Tour

本日はツールの調査枠です。

MicrosoftからはMixedRealityToolkit以外にも多くの開発者向けのSDKが公開されています。

 その一例として[Microsoft Map-SDK for Unity(以下Map-SDK)]を調査しています。

 前回はMap-SDKを導入しました。

redhologerbera.hatenablog.com

〇Exampleを読み解く

Map-SDKにはExamplesとしてサンプルシーンが同梱されており、Map-SDKを用いたデモを体験できます。

f:id:Holomoto-Sumire:20200830164000j:plain

各シーンごとに[Map]オブジェクト内の[Map Session]コンポーネントの[Developer Key]を入力する必要があります。

この[Developer Key]は前回の導入の記事で紹介しています。

redhologerbera.hatenablog.com

〇CityTourExample

f:id:Holomoto-Sumire:20200830164131j:plain

[CityTourExample]ではシーンを実行すると約2分ほどかけてシアトルの各所を移り変わりながらみていくことができるサンプルです。

[Map]オブジェクトには[Seattle tour]コンポーネント

f:id:Holomoto-Sumire:20200830165030j:plain

public class SeattleTour : MonoBehaviour
{
...
    void Start()
    {
        StartCoroutine(RunTour());
    }

    private IEnumerator RunTour()
    {
        yield return new WaitForSeconds(5.0f);

        while (isActiveAndEnabled) // loop the tour as long as we are running.
        {
            foreach (var scene in MapScenes)
            {
                yield return _map.SetMapScene(scene);

                yield return new WaitForSeconds(3.0f);
            }
        }
    }
}

[SeattleTour]コンポーネントはStart関数でコルーチンを実行しています。

 private IEnumerator RunTour()
    {
        yield return new WaitForSeconds(5.0f);

        while (isActiveAndEnabled) // loop the tour as long as we are running.
        {
            foreach (var scene in MapScenes)
            {
                yield return _map.SetMapScene(scene);

                yield return new WaitForSeconds(3.0f);
            }
        }
    }

コルーチン内では3秒ごとに[MapScenes(scene)]を変えています。

[MapScenes()]関数は[MapRenderer]の[Latitude][Longitude]とスケールを与えることができます。

github.com

 この[scene]の[MapScene]はList型で宣言されています。

    private static readonly List<MapScene> MapScenes =
        new List<MapScene>
        {
            // Space Needle -> zoom out to Seattle Center
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.620365, -122.349305), 17.0f),
            // MOHAI/wooden boats
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.626872, -122.336026), 17.0f),
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.627584, -122.336609), 18.0f),
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.628131, -122.336676), 19.0f),
            // Gas Works
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.644556, -122.335012), 16.0f),
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.645065, -122.334899), 18.0f),
            // St Marks
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.631862, -122.321263), 16.0f),
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.631862, -122.321263), 18.0f),
            // Volunteer Park
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.630118, -122.314719), 16.75f),
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.628994, -122.31457), 18.0f),
            // Cal Anderson Park
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.618389, -122.319168), 17.0f),
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.615401, -122.318979), 18.0f),
            // Columbia Center -> Downtown
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.603035, -122.331509), 16.0f),
            // Stadiums
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.595005, -122.331778), 17.0f),
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.591358, -122.332373), 17.0f),
            // Waterfront
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.606085, -122.342533), 18.5f),
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.607588, -122.343334), 18.5f),
            // Pike Place Market
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.61043, -122.343521), 19.5f),
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.608699, -122.340571), 19.5f),
            // Zoom out
            new MapSceneOfLocationAndZoomLevel(new LatLon(47.608699, -122.340571), 15f),
        };

〇シアトルツアー

・ スペースニードル⇒シアトルセンター

 スペースニードルはシアトルの有名なタワーです。1962年の万博で建てられたもので日本でいうところの太陽の塔のような象徴的建物です。

 f:id:Holomoto-Sumire:20200830171259g:plain

・MOHAI 木製ボート

 MOHAIはシアトルの歴史産業博物館です。

mohai.org

 港に隣接しており、ツアーでは木製ボートまで見ることができます。

f:id:Holomoto-Sumire:20200830171810g:plain

・ガス工場

シアトルのガス工場です。

f:id:Holomoto-Sumire:20200830172630g:plain

・セント・マークス・イピスコパル大聖堂

シアトルの大きな協会です。

f:id:Holomoto-Sumire:20200830172752g:plain

f:id:Holomoto-Sumire:20200830173247g:plain

・ボランティア公園

f:id:Holomoto-Sumire:20200830173524g:plain

f:id:Holomoto-Sumire:20200830173758g:plain

・カル・アンダーソン公園

 カル・アンダーソン公園は高台にあるシアトルの公園です。

f:id:Holomoto-Sumire:20200830174006g:plain

・コロンビアセンター→シアトルダウンタウン

コロンビアセンターはシアトルダウンタウン超高層ビルです。 76階建てで完成当時アメリカ西海岸で最も高い建物でした。現在は4番目に高いビルのようです。

f:id:Holomoto-Sumire:20200830174228g:plain

・スタジアム

 シアトルのスタジアムです。

f:id:Holomoto-Sumire:20200830174411g:plain

ウォーターフロント

ウォーターフロントとは湾岸部の開発区域のことを指す言葉です。

シアトルのウォーターフロントの観覧車から湾岸部の通りをめぐります。

f:id:Holomoto-Sumire:20200830174626g:plain

f:id:Holomoto-Sumire:20200830174742g:plain

・パイクプレイスマーケット

最後にパイクプレイスマーケットをめぐります。

www.pikeplacemarket.org

パイクプレイスマーケットはシアトルの市場で1907年に始まった最も古い市場の一つです。

f:id:Holomoto-Sumire:20200830175223g:plain

以上がMicrosoft Map-SDK for Unity Examplesの[city tour]でした。