コード例 #1
0
    public void Load(IProgress progress, IUpdateHandler updateHandler, IDialog dialog)
    {
        _progress      = progress;
        _updateHandler = updateHandler;
        _dialog        = dialog;

        _coRoutines.Clear();
        Handlers.Clear();

        updateHandler.HookUpdate(EditorUpdate);
        UpdateProgress(0.02f, "Initialising..");

        string urlBase  = "http://localhost:8165";
        string urlPath  = "api/mapping/";
        string urlQuery = string.Format("maxLat={0}&maxLon={1}&minLat={2}&minLon={3}", maxLat, maxLon, minLat, minLon);

        string geomUrl = urlBase + "/" + urlPath + "geoJson?" + urlQuery;

        var geomCoroutine = new EditorCoroutine("Geom Loader", geomUrl);

        _coRoutines.Add(geomCoroutine);

        string imgUrl = urlBase + "/" + urlPath + "image?" + urlQuery;

        var imageCoroutine = new EditorCoroutine("Satellite Image Loader", imgUrl);

        _coRoutines.Add(imageCoroutine);

        string mdUrl = urlBase + "/" + urlPath + "metadata?" + urlQuery;
        var    imageMetadataCoroutine = new EditorCoroutine("Image Metadata Loader", mdUrl);

        _coRoutines.Add(imageMetadataCoroutine);

        // If we are using the texture projector then these can be done in parallel
        //WhenDone("Load Geom", LoadGeoJSON, geomCoroutine);
        WhenDone("Load Map Image", LoadMapImage, imageCoroutine);
        //WhenDone("Load Map Metadata", LoadMapMetadata, imageMetadataCoroutine);

        // For UV texturing we need to load the metadata image up before we can load
        // the building geometry so we can generate the UVs inside the mesh building
        // routines
        WhenDone("Geom and Metadata", LoadGeomAndMapImageMetadata, imageMetadataCoroutine, geomCoroutine);
        WhenDone("All Loading", LoadingComplete, imageCoroutine, imageMetadataCoroutine, geomCoroutine);

        RecreateMapContainer();

        // Create the tile plane..
        _tilePlane      = new GameObject();
        _tilePlane.name = "Tile Plane";
        _tilePlane.AddComponent(typeof(MeshFilter));
        _tilePlane.AddComponent(typeof(MeshRenderer));
        var shader = Shader.Find("HoloToolkit/Unlit Configurable");

        if (shader == null)
        {
            Debug.Log("Error: HoloToolkit/Unlit Configurable Shader not available.");
            return;
        }

        _mapMaterial = new Material(shader);
        _tilePlane.GetComponent <MeshRenderer>().material = _mapMaterial;

        UpdateProgress(0.04f, "Initialising..");
    }