Created
June 25, 2024 18:05
-
-
Save Venkat-Swaraj/ce403d331b70e253555848887089731b to your computer and use it in GitHub Desktop.
This script can be used to save point cloud data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.XR.ARFoundation; | |
public class PointCloudParser : MonoBehaviour | |
{ | |
public ARPointCloudManager pointCloudManager; | |
private void OnEnable() | |
{ | |
pointCloudManager.pointCloudsChanged += PointCloudManager_pointCloudsChanged; | |
} | |
private void PointCloudManager_pointCloudsChanged(ARPointCloudChangedEventArgs obj) | |
{ | |
List<ARPoint> addedPoints = new List<ARPoint>(); | |
foreach (var pointCloud in obj.added) | |
{ | |
foreach (var pos in pointCloud.positions) | |
{ | |
ARPoint newPoint = new ARPoint(pos); | |
addedPoints.Add(newPoint); | |
} | |
} | |
List<ARPoint> updatedPoints = new List<ARPoint>(); | |
foreach (var pointCloud in obj.updated) | |
{ | |
foreach (var pos in pointCloud.positions) | |
{ | |
ARPoint newPoint = new ARPoint(pos); | |
updatedPoints.Add(newPoint); | |
} | |
} | |
} | |
} | |
public class ARPoint | |
{ | |
public float x; | |
public float y; | |
public float z; | |
public ARPoint(Vector3 pos) | |
{ | |
x = pos.x; | |
y = pos.y; | |
z = pos.z; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment