Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Last active May 27, 2018 13:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save flushpot1125/532fe9f658eba341d45a6a88ac34d9cd to your computer and use it in GitHub Desktop.
/*You can get full source from here
https://github.com/google-ar/arcore-unity-sdk/releases/download/v1.2.0/arcore-unity-sdk-v1.2.0.unitypackage
*/
private const int k_MaxPointCount = 61440;
private Mesh m_Mesh;
private Vector3[] m_Points = new Vector3[k_MaxPointCount];
private int[] indices = new int[k_MaxPointCount];//add by Limes
public void Start(){
m_Mesh = GetComponent<MeshFilter>().mesh;
m_Mesh.Clear();
}
public void Update(){
// Fill in the data to draw the point cloud.
if (Frame.PointCloud.IsUpdatedThisFrame){
// Copy the point cloud points for mesh verticies.
for (int i = 0; i < Frame.PointCloud.PointCount; i++){
m_Points[i] = Frame.PointCloud.GetPoint(i);
}
// Update the mesh indicies array.
// int[] indices = new int[Frame.PointCloud.PointCount]; //deleted from Limes
for (int i = 0; i < Frame.PointCloud.PointCount; i++){
indices[i] = i;
}
m_Mesh.Clear();
m_Mesh.vertices = m_Points;
m_Mesh.SetIndices(indices, MeshTopology.Points, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment