I was wondering if it was possible to get the texture coordinate when ray casting?
For terrain is easy, since you just need know x/z on terrain and make x/width, z/height
For Models(idk if there is more simple way), you would need get into Mesh Buffer and find Tris that refer into contact point, then get TexCoord based on average distance to this 3 points. (each point have own texCoord)
I think the CollisionResult will even tell you the triangle.
Then you have to compute the barycentric coordinates, etc. use those to interpolate a texture coordinate and so on. Definitely doable but a bit non-trivial.
Yes, you will get the triangle index.
Also note, that the contactPoint on the CollisionResult is in world space, not model space.
Thanks for the replies. Luckily for now I’m just trying to get the texture coordinates from a terrain (so basically a quad) which is super easy.
Never thought to just get the mouse position in relation to the quad, a super obvious solution looking back on it.