public static void CallBack(ROSBridgeMsg msg) //after receiving the ros message { PointCloud2Msg cloudm = (PointCloud2Msg)msg; //point cloud message PointCloud <PointXYZRGB> points = cloudm.GetCloud(); // get data, the data has point location and point color information PointXYZRGB point; //variable to access information of single point in the list of points //voxel mesh with triangles numPoints = points.Size; //number of points received mpoints = new Vector3[numPoints]; colors = new Color[numPoints]; //store points and colors of the point cloud separately in arrays for (int i = 0; i < numPoints; i++) { point = points.At(i); //point at index i in the list mpoints[i] = new Vector3(point.X, point.Z, point.Y); colors[i] = new Color(point.R / 255.0f, point.G / 255.0f, point.B / 255.0f); } // generate child meshes total_meshes = Mathf.CeilToInt(numPoints * 1.0f / Points_limit * 1.0f); //calculate the number of child meshes required main_mesh = GameObject.Find(Mesh_name); //find the mesh in unity environment if (main_mesh == null) { main_mesh = new GameObject(Mesh_name); //if no mesh found, create one } else { //do nothing } //initialize the mesh for (int i = 0; i < total_meshes - 1; i++) { Mesh_initialization(i, Points_limit); } Mesh_initialization(total_meshes - 1, numPoints - (total_meshes - 1) * Points_limit); }