0

I have been working on UnityARworldMap scene.Trying to load two or more worldmaps(.worldmap extension) which I saved earlier.Starting I load one worldmap,after covering some distance I load second worldmap and the next worldmap after some distance.

I successfully loaded the first arworldmap and prefabs are coming at accurate positions in real world.The problem I faced is when I load the second worldmap the prefabs loaded on the first map changes their position (resets) and loaded at different positons.The reason I believe is that the second map does not contain any position of the prefabs in the first map.Without resetting how to load the other maps along with the first map?

public void Load(string flname)
{


    //Loading file from persistent path


    Debug.LogFormat("Loading ARWorldMap {0}", Loadpath);
    var worldMap = ARWorldMap.Load(Loadpath);


    if (worldMap != null)
    {
        m_LoadedMap = worldMap;
        Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

        UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;

        var config = m_ARCameraManager.sessionConfiguration;
        config.worldMap = worldMap;
       UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        Debug.Log("Restarting session with worldMap");
       session.RunWithConfigAndOptions(config, runOption);
       // StopPlaneDetection();


    }
    else
    {
        Debug.Log("No World Map loaded");
    }




}

This is how I load maps after different intervals (given below) .

Load(path+FileName2);//for second world map
Load(path+FileName3);//for third world map
zyonneo
  • 1,319
  • 5
  • 25
  • 63

1 Answers1

0

Currently, ARWorldTrackingConfiguration accepts a single world map object only, and to apply it to the scene you reset the session and remove all existing anchors. For that reason, when you apply the second world map, all anchors from the previous one get removed.

A possible workaround would be to retrieve both world maps and copy all anchors and feature points from one to another and then load the new world map into the scene. But still, this would not be accurate since there are two different snapshots, centers, and extents for each world map which makes relocalization process difficult.

So probably the best option at the moment is to save all anchors in the same world map and prevent loading multiple ones.

M Reza
  • 18,350
  • 14
  • 66
  • 71
  • Reza... I have done using different maps is because if it is done using single map,the size of the map will be huge.Any idea how much area does a single map support? – zyonneo May 22 '19 at 12:18
  • @zyonneo I don't think if there's a limitation, but as your map gets bigger, performance might be affected. – M Reza May 22 '19 at 12:54
  • Reza I came across this code.... UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;................SO is it possible to load the ARworldmap without resetting/remove the existing Anchors? That is load another ARworldmap on the same session. – zyonneo May 24 '19 at 12:06
  • @zyonneo When you are going to load your new world map, the session does not continue device position and motion tracking from the previous configuration, so you need to reset/remove the existing anchors. If not, I guess the anchors will not be positioned correctly and cause unexpected behavior! – M Reza May 24 '19 at 18:50