Yes, the uv coordinates can help, but you may end up doing a lot of work…
What you can do is:
- loop over all the triangles of your mesh
- for each triangle
- retrieve the uv coordinates of the 3 vertices
- determine if the point you want to check is inside the 2D triangle delimited by the uv coordinates
It can be quite involved if your mesh has a lot of vertices/faces.
An easier way would be to provide a texture where the “inside” is painted in full red (for eg), and the “outside” in black. Then, the check is only a matter of retrieving the pixel in the texture and verify if it’s red or black.
You could build this texture at runtime, by looping over all the triangles as described above and drawing the 2D triangles in the texture in red.