Nevermind, I got it. Thanx everybody
Thanks all for your help, I followed Phikwe's implementation (thanks alot man) to come up with a routine to find which triangle I hit with the mouse (I'm drawing primitives). In this function I'm testing for just one triangle that's why my vectors zero, one and two are hard-coded.
I'm pasting my function here just in case anybody is interested:
private bool intersectedTriangle()
{
Point pt = Cursor.Position;
pt = this.PointToClient(pt);
Viewport vp;
Matrix world;
Matrix proj;
Matrix view;
IntersectInformation closeHit
Vector3 vIn, vNear, vFar, vDir;
vp = device.Viewport;
world = device.Transform.World;
proj = device.Transform.Projection;
view = device.Transform.View;
vIn.X = pt.X;
vIn.Y = pt.Y;
// Compute point on near clip plane at cursor
vIn.Z = 0;
vNear = Vector3.Unproject(vIn, vp, proj, view, world);
// Compute point on far clip plane at cursor
vIn.Z = 1;
vFar = Vector3.Unproject(vIn, vp, proj, view, world);
// Compute direction vector
vDir = Vector3.Subtract(vFar, vNear);
Vector3 zero, one, two;
// The vertexes of my triangle
zero = new Vector3(0.0f, 1.0f, 1.0f);
one = new Vector3(-1.0f, -1.0f, 1.0f);
two = new Vector3(1.0f, -1.0f, 1.0f);
if (Geometry.IntersectTri(zero, one, two, vNear, vDir, ref closeHit))
{
return true;
}
return false;
}