Google's Project Tango provides a point cloud, i.e. a floatBuffer with the positions xyz of a set of points in meters. I would like to be able to select one of such points by touching it on the screen.
What would be the best/easiest way to achieve this?
UPDATE
I include the code so far, as suggested I tried getting the projection of points on the screen, however after displaying the points I find I get values that are too small (i.e. 0.5,0.7 etc). I'm not working with unity but with android studio and therefore I don't have the method cam.WorldToScreenPoint(m_points[it]), I do however have a projection matrix, but I guess this is incorrect (maybe because we should go from meters to pixels). What would be the correct matrix to achieve this?
private void selectClosestCloundPoint(float x, float y) {
//Get the current rotation matrix
Matrix4 projMatrix = mRenderer.getCurrentCamera().getProjectionMatrix();
//Get all the points in the pointcloud and store them as 3D points
FloatBuffer pointsBuffer = mPointCloudManager.updateAndGetLatestPointCloudRenderBuffer().floatBuffer;
Vector3[] points3D = new Vector3[pointsBuffer.capacity()/3];
int j =0;
for (int i = 0; i < pointsBuffer.capacity() - 3; i = i + 3) {
points3D[j]= new Vector3(
pointsBuffer.get(i),
pointsBuffer.get(i+1),
pointsBuffer.get(i+2));
j++;
}
//Get the projection of the points in the screen.
Vector3[] points2D = new Vector3[points3D.length];
for(int i =0; i < points3D.length-1;i++)
{
Log.v("Points", "X: " +points3D[i].x + "\tY: "+ points3D[i].y +"\tZ: "+ points3D[i].z );
points2D[i] = points3D[i].multiply(projMatrix);
Log.v("Points", "pX: " +points2D[i].x + "\tpY: "+ points2D[i].y +"\tpZ: "+ points2D[i].z );
}
}
I use a vector3 since that's the return type, but as I understand, the third component of it is not important.