http://xbox.create.msdn.com/en-US/education/catalog/sample/picking_triangle
I found a second link(below) that was helpful but wasnt sure how to modify the ray triangle method according to the instructions(modify the RayIntersectsModel method that does the triangle test so it will output the indices of the closest intersecting triangle's vertices -- right now it just outputs the vertex positions. This is in the inner most block of the method, where it stores the information for the closest detected intersection:
| // If so, is it closer than any other previous triangle? |
| if ((closestIntersection == null) || (intersection < closestIntersection)) |
| { |
| // .... |
You just need to add an integer output parameter for the method and store the value of the i counter. If RayIntersectsModel returns with a hit, you use i, i+1, and i+2 as the indices into the texcoord list you have stored in the model's tag data. ), so I came
here for help. THANKYOU
http://xboxforums.create.msdn.com/forums/p/81663/495156.aspx
RayIntersectsTriangle(ref ray,
ref vertices[i],
ref vertices[i + 1],
ref vertices[i + 2],
out intersection);
// Does the ray intersect this triangle?
if (intersection != null)
{
// If so, is it closer than any other previous triangle?
if ((closestIntersection == null) ||
(intersection < closestIntersection))
{
// Store the distance to this triangle.
closestIntersection = intersection;
// Transform the three vertex positions into world space,
// and store them into the output vertex parameters.
Vector3.Transform(ref vertices[i],
ref modelTransform, out vertex1);
Vector3.Transform(ref vertices[i + 1],
ref modelTransform, out vertex2);
Vector3.Transform(ref vertices[i + 2],
ref modelTransform, out vertex3);
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.