# Wavefront mesh: determine which face a point belongs to?

I have a 3D mesh Wavefront .obj file.

Is there any algorithm that takes an arbitrary point coordinates as input and determines which face of the mesh that point belongs to ??

The mesh is rendered on the screen, then the user clicks on it, I want to determine which part of the mesh the user has clicked on ?

Here's the code using LibGDX:

Vector3 intersection=new Vector3();
Ray ray=camera.getPickRay(x, y);
//vertices is an array that hold the coordinates of the mesh
boolean ok=Intersector.intersectRayTriangles(ray, vertices, intersection);


Thanks

In the most general case you store a list of Triangle objects and iterate over each to do a ray-triangle test. You can optimize this heavily by using a smarter data structure, such as a model-local BSP tree (or some other spatial partitioning as appropriate for the kinds of shapes you're using).