microsoft / MapsSDK-Unity

This repository contains samples, documentation, and supporting scripts for Maps SDK, a Microsoft Garage project.
MIT License
648 stars 127 forks source link

LocalMapDimension #79

Closed bredok2 closed 3 years ago

bredok2 commented 4 years ago

Hi community, I'm working on a flight simulator video game project, but LocalMapDimension reaches a maximum of 3, this is too small in my case, how can I implement this? Thank you all

TerraSame commented 4 years ago

I have done very similar to what you are attempting... What I have done is create different scenes where you can start with a big terrain level by zooming out and scaling the map as you see fit. Then create buttons where you want over the terrain that launch other levels where you have a different map terrain and zoom in and scale again as you see fit with different latitude and longitude... Then add another button to do the same thing and also to go back to the previous big original level... You can do this with the Example level that comes with the holotoolkit and use the scene change system... This was difficult to get working as I desired so when you use the example level be very careful to use it exactly as it is designed... Best of luck! Paul

On Sun, Aug 2, 2020, 9:20 AM bredok2 notifications@github.com wrote:

Hi community, I'm working on a flight simulator video game project, but LocalMapDimension reaches a maximum of 3, this is too small in my case, how can I implement this? Thank you all

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/microsoft/MapsSDK-Unity/issues/79, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMY7RAEFUFFWFX5VJIAHPTR6V73BANCNFSM4PSTAXGQ .

bredok2 commented 4 years ago

Thank you Paul, have you a link for this example? i do not see it in the holotoolkit

TerraSame commented 4 years ago

Hi... It is a free download... Do a search for: MRTK Example Hub It is in a package specifically for Unity... The Example HUB is what you want!

On Sun, Aug 2, 2020, 12:19 PM bredok2 notifications@github.com wrote:

Thank you Paul, have you a link for this example? i do not see it in the holotoolkit

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/microsoft/MapsSDK-Unity/issues/79#issuecomment-667707597, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMY7RAGFFVFWXWWPUXLSV3R6WUZRANCNFSM4PSTAXGQ .

bredok2 commented 4 years ago

Hello, I have this script that work for my project, but the conversion seems to not be correct, Some help?

using System.Collections; using System.Collections.Generic; using UnityEngine; using Microsoft.Maps.Unity; using Microsoft.Geospatial;

public class MapTravel : MonoBehaviour { [Header("Connections")] public MapRenderer mapPlate; public Transform connectedAircraft;

public float mapSize = 10000f;//2piR
private float worldRadius;

float lat, lon; LatLon basePosition;
public float latitude, longitude;

private void Update()
{
    if (connectedAircraft != null)
    {
        worldRadius = mapSize / 6.2832f;
        Vector3 craftPosition = connectedAircraft.position;

        // ------------------ Calculate
        lat = (float)Mathf.Acos(craftPosition.y / worldRadius); //theta
        lon = (float)Mathf.Atan(craftPosition.x / craftPosition.z); //phi
        if (!float.IsNaN(lat) && !float.IsNaN(lon)) { basePosition = new LatLon(lat * Mathf.Rad2Deg, lon * Mathf.Rad2Deg); }

        // ------------------ Move
        latitude = lat * Mathf.Rad2Deg;
        longitude = lon * Mathf.Rad2Deg;
        mapPlate.Center = basePosition;
    }
}

}

kircher1 commented 3 years ago

Apologies for missing this issue. It seems like you're trying to transform the world position (in Unity's coordinate space) of the craft to a LatLon on the map. There are some helper transformation methods that can be used to do this that are part of the SDK already. Specifically look at TransformWorldPointToLatLonAlt.

That is an extension method to the MapRenderer component itself, so it can be called like this:

var latLonAlt = mapPlate.TransformWorldPositionToLatAlot(craftPosition);

Hope that helps!