In the scanning example, where is the mesh saved, and in what format? (Is there further documentation on the specifics here?)
Hi,
Here’s the detailed documentation: Getting Started with the Scanning Framework — Niantic Lightship Augmented Reality Developer Kit release-2.5.1 documentation
Specifically, step 4 has the information to handle processed scan mesh results. Please let me know if you have further questions.
im stuck at step 4 at the start method where _scanManager.OnScanResult += ScanResultHandler; is showing an error at OnScanResult
This is my code
using Niantic.ARDK.AR;
using Niantic.ARDK.AR.Scanning;
using Niantic.ARDK.Extensions;
using Niantic.ARDK.Extensions.Scanning;
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
using UnityEngine.UI;
using System;
using System.Collections.Generic;
public class ScanningExampleManager : MonoBehaviour
{
[SerializeField]
[Tooltip(“The scene’s ARScanManager”)]
private ARScanManager _scanManager;
// …
[SerializeField]
private PointCloudVisualizer _pointCloudVisualizer;
void Start()
{
// Set default visualizer
_scanManager.SetVisualizer(_pointCloudVisualizer);
_scanManager.OnScanResult += ScanResultHandler;
}
public void ScanButtonPressed()
{
_scanManager.StartScanning();
}
public void StopButtonPressed()
{
_scanManager.StopScanning();
}
public void ProcessButtonPressed()
{
IScanner.State state = _scanManager.ScannerState;
if (state == IScanner.State.ScanCompleted)
{
// Start processing scan
_scanManager.StartProcessing();
}
}
public Slider _progressBar;
private void Update()
{
IScanner.State state = _scanManager.ScannerState;
if (state == IScanner.State.Processing)
{
_progressBar.gameObject.SetActive(true);
_progressBar.value = _scanManager.GetScanProgress();
}
else
{
_progressBar.gameObject.SetActive(false);
}
}
public void CancelProcessButtonPressed()
{
_scanManager.CancelProcessing();
}
private GameObject scannedObject;
private GameObject _scannedObjectPrefab;
public Transform _scannedObjectParent;
private void ScanResultHandler(TexturedMesh texturedMesh, IScanner.State state, Vector3 centerPosition)
{
if (texturedMesh != null)
{
if (scannedObject == null)
{
scannedObject = Instantiate(_scannedObjectPrefab, _scannedObjectParent);
}
Bounds meshBoundary = texturedMesh.mesh.bounds;
scannedObject.transform.localPosition = -1 * meshBoundary.center;
scannedObject.transform.localScale = Vector3.one / meshBoundary.extents.magnitude;
scannedObject.GetComponent<MeshFilter>().sharedMesh = texturedMesh.mesh;
if (texturedMesh.texture != null)
scannedObject.GetComponent<Renderer>().material.mainTexture = texturedMesh.texture;
}
}
}
Hello Shoib,
Sorry for the confusion, that event has been replaced with ScanProcessed (you can find it in the C# script the the ARScanManager) so instead of _scanManager.OnScanResult += ScanResultHandler, you will want to do _scanManager.ScanProcessed += ScanResultHandler
The arguments are also a little different so in your ScanResultHandler function, the signature should look like private void ScanResultHandler(IScanner.ScanProcessedArgs args) and **args **will contain the TexturedMesh.
If you have any additional questions, please open a separate topic and provide descriptions of your issues so that we can look into them.