public void Update() { // Do not update if huaweiAR is not tracking. if (ARFrame.GetTrackingState() != ARTrackable.TrackingState.TRACKING) { m_mesh.Clear(); return; } // Fill in the data to draw the point cloud. ARPointCloud pointCloud = ARFrame.AcquirePointCloud(); pointCloud.GetPoints(ref m_points); pointCloud.Release(); if (m_points.Count > 0) { // Update the mesh indicies array. m_pointIndex.Clear(); for (int i = 0; i < Mathf.Min(m_points.Count, k_maxPointCount); i++) { m_pointIndex.Add(i); } m_mesh.Clear(); m_mesh.vertices = m_points.ToArray(); m_mesh.SetIndices(m_pointIndex.ToArray(), MeshTopology.Points, 0); } }
// Update is called once per frame void Update() { if (PointCloud != null && ParticleSystem != null) { List <Vector3> pointsInCloud = new List <Vector3>(); PointCloud.GetPoints(pointsInCloud, Space.Self); ParticleSystem.Particle[] particles = new ParticleSystem.Particle[pointsInCloud.Count]; int index = 0; foreach (Vector3 currentPoint in pointsInCloud) { particles[index].position = currentPoint; particles[index].startColor = new Color(1.0f, 1.0f, 1.0f); particles[index].startSize = 0.02f; index++; } ParticleSystem.SetParticles(particles, pointsInCloud.Count); } }