Hi guys

Ive been working on a project involving ray collision with a multitextured terrain(2D heightmap) the ray method(below) not only returns the triangle intersected but the uv(barycentric) coordinates as well but during research for my project I came across a post from the unity website(link below) that had to do with ray pixel intersection and wondered if I should implement that instead, so the question that Im asking is which of the two is better. should I stick with the ray uv coordinate method or go with an XNA version of the ray pixel collision.

Thankyou

unity ray pixel post

http://forum.unity3d.com/threads/131062-Terrain-and-footsteps

the intersect method Ive been working with

public bool RayTriangleIntersect(Vector3 ray_origin, Vector3 ray_direction, Vector3 vert0, Vector3 vert1, Vector3 vert2, out float? t, out float u, out float v) { t = 0; u = 0; v = 0; Vector3 edge1 = vert1 - vert0; Vector3 edge2 = vert2 - vert0; Vector3 tvec, pvec, qvec; float det, inv_det; pvec = Vector3.Cross(ray_direction, edge2); det = Vector3.Dot(edge1, pvec); if (det > -0.00001f) return false; inv_det = 1.0f / det; tvec = ray_origin - vert0; u = Vector3.Dot(tvec, pvec) * inv_det; if (u < -0.001f || u > 1.001f) return false; qvec = Vector3.Cross(tvec, edge1); v = Vector3.Dot(ray_direction, qvec) * inv_det; if (v < -0.001f || u + v > 1.001f) return false; t = Vector3.Dot(edge2, qvec) * inv_det; if (t <= 0) return false; return true; }

also a youtube link to a project called rigs of rods to give a visual of the effect Im working on,

which is to have a vehicle shoot out certain particles(dirt debris,grass debris,etc,..) based on

the texture its riding over.