Topic: Altitude of 3d marker with elevation

Hi

I'm spawning 3D marker at runtime.

If i don't use elevation, i'm able to set an altitude value by doing :
waypointMarker = OnlineMapsControlBase3D.instance.AddMarker3D(lng,lat, waypointPrefab);
waypointMarker.altitude = 50;

This will properly display my marker at 50m over the ground.

If i try to use elevation, then doing "waypointMarker.altitude = 50;" is not the correct way (it will be underground if i try to spawn my marker on top of a mountain per example)

if i just don't set an altitude, my marker will appear at the top of the mountain (great !). But now if i try to "add" the altitude i want with "waypointMarker.altitude = waypointMarker.altitude + 50;" It will be back underground.

What is the correct way to set an altitude "as an offset" of the marker position ?

Can you explain me why waypointMarker.altitude won't return anything if i don't set myself this altitude ?

Re: Altitude of 3d marker with elevation

Hello.

Altitude of the marker is absolute (above sea level).

Example of how to make a relative altitude, you can find in Aircraft.cs.

I think in the next version we will add the ability to specify the type altitude: absolute or relative.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Altitude of 3d marker with elevation

Hi
Based on the Aircraft.cs example, i tried to set up my 3D markers with :

public void addWaypoint(double x, double y)
    {
        OnlineMapsMarker3D waypointMarker = controlBase3D.AddMarker3D(x, y, waypointPrefab);
        waypointMarker.altitude = RS.altitude * tileSetControl.GetBestElevationYScale(api.topLeftPosition, api.bottomRightPosition) * tileSetControl.elevationScale;
    }

But the result are not what i expected :

https://gph.is/2yRvX63

But again, if i don't try to set an altitude, my waypoints are perfectly following the topography :

https://ibb.co/iNqySf

The fact that the waypoints are all at the same altitude in the GIF (and not disposed relatively to the ground shape) make me think that using "tileSetControl.GetBestElevationYScale" is valid only if i want the altitude at the center of the tileset. Am i right ? How should i proceed then ?
Thanks
Thibault

Re: Altitude of 3d marker with elevation

How it should work:
1. You wrap your marker prefab in a new empty GameObject.
2. Create a new prefab from an external GameObject, and use this as a marker prefab.
3. You do not use altitude of the marker at all.
4. You set transform.localPosition.y of the internal GameObject, instead of waypointMarker.altitude.

Or just wait for a relative altitude opportunity.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Altitude of 3d marker with elevation

I followed your advice, and it's almost working.


The problem i had by following your instruction was:

When using zoom, the localposition of the gameobject (child of the marker prefab) does'nt change.

So i attached a script to this gameobject, which suscribe to the "OnMapZoom" event, in order to set the correct transform.localposition.y value.

tileSetControl.OnMapZoom += updateAltitude;
tileSetControl.OnSmoothZoomProcess += updateAltitude;

private void updateAltitude()
{
        float alt = 0.001f * altitude *tileSetControl.GetElevationValue(lng, lat, tileSetControl.GetBestElevationYScale(api.topLeftPosition, api.bottomRightPosition), api.topLeftPosition, api.bottomRightPosition);
        transform.localPosition = new Vector3(0, altitude, 0);
}

And it is working ! But now, if i destroy my markers by calling

"OnlineMapsControlBase3D.instance.RemoveMarkers3DByTag("Waypoint");"

(at this point the waypoints seems to be removed correctly)

And then if i try to change the zoom level, the current error appear:

MissingReferenceException: The object of type 'Waypoint' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
Waypoint.updateAltitude () (at Assets/Waypoint.cs:29)
OnlineMapsControlBase.ZoomOnPoint (Int32 zoomOffset, Vector2 screenPosition) (at Assets/Infinity Code/Online maps/Scripts/Controls/OnlineMapsControlBase.cs:992)
OnlineMapsControlBase.UpdateZoom () (at Assets/Infinity Code/Online maps/Scripts/Controls/OnlineMapsControlBase.cs:926)
OnlineMapsControlBase.Update () (at Assets/Infinity Code/Online maps/Scripts/Controls/OnlineMapsControlBase.cs:781)

The line causing the error is

 transform.localPosition = new Vector3(0, altitude, 0);

So it look like the script of the marker prefab child is still existing somewhere after the destruction of the marker.

I though that setting a relative altitude would be an easy task, but the more i try the more problems i meet yikes

Re: Altitude of 3d marker with elevation

You have subscribed to OnMapZoom and OnSmoothZoomProcess events, so you need to unsubscribe from these events first.

tileSetControl.OnMapZoom -= updateAltitude;
tileSetControl.OnSmoothZoomProcess -= updateAltitude;

In your case, the easiest way to use MonoBehaviour.OnDestroy to unsubscribe from events when a GameObject is destroyed.
https://docs.unity3d.com/ScriptReferenc … stroy.html

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.