EasyAR_稀疏空间图
EasyAR4.6.3 丨 Unity2020.3.15f2
1.创建稀疏空间地图
在EasyAR开发中心后台创建Scene许可证密钥,并且使用稀疏空间地图
2.设置稀疏空间地图库名,对稀疏空间地图进行管理,设置密钥
3.复制密钥到Unity中
添加Spatial Map AppId
添加APIKey & API Secret
4.Build Sparse Spatial Map
- MainCamera 设置为 Solid Color
编写代码,扫描保存Sparse Spatial Map,上传到云端
private ARSession session;
private SparseSpatialMapWorkerFrameFilter mapWorker;
public TextMeshProUGUI uiText;
public TextMeshProUGUI btnText;
public Button btnSave;
private void Start()
{
session = FindObjectOfType<ARSession>();
mapWorker = FindObjectOfType<SparseSpatialMapWorkerFrameFilter>();
btnText.text = "Build Map";
btnSave.onClick.AddListener(SaveMap);
}
private void SaveMap()
{
mapWorker.BuilderMapController.Host("EasyARScene01",null);
uiText.text = "Start Build Map";
}
在EasyAR开发中心查看存储的Spatial Map
设置横屏竖屏的效果
Portrait 竖屏
Portrait 竖屏,手机倒着
Landscape Right 横屏,屏幕在home键右侧
Landscape Left 横屏,屏幕在home键左侧
Auto Rotation 自动旋转屏幕
5.Read Sparse Spatial Map
通过远端Spatial Map库中将ID和Name赋值到其中
稀疏地图会保留存储地图的稀疏图的空间位置,并不会保存模型数据,记录的之前保存的Sparse Spatial Map的信息位置数据
编写代码,读取远程的SpriteMap
private ARSession session;
private SparseSpatialMapWorkerFrameFilter mapWorker;
public TextMeshProUGUI uiText;
public TextMeshProUGUI btnText;
private Button btnSave;
private void Start()
{
session = FindObjectOfType<ARSession>();
mapWorker = FindObjectOfType<SparseSpatialMapWorkerFrameFilter>();
btnSave = FindObjectOfType<Button>();
btnText.text = "Read Map";
btnSave.onClick.AddListener(ReadMap);
}
private void ReadMap()
{
mapWorker.Localizer.startLocalization();
uiText.text = "Start Read Map";
}