Archived

This topic is now archived and is closed to further replies.

DarkZoulz

Get vector at intersection point?

Recommended Posts

I am checking for intersections on my mesh with D3DXIntersect(), and that works great now. But I would like to get the vector at the point where the intersection is occuring. D3DXIntersect() only returns the number of the face that was intersected. Any ideas?

Share this post


Link to post
Share on other sites
quote:
Original post by DarkZoulz
I am checking for intersections on my mesh with D3DXIntersect(), and that works great now. But I would like to get the vector at the point where the intersection is occuring. D3DXIntersect() only returns the number of the face that was intersected.


Which vector do you mean? Do you want the normal of the surface that has been hit? If so, this is what you do:

You need to lock the index and vertex buffers of the model, access the vertices of the particular face that has been intersected, and then use the barycentric coordinates that the D3DXIntersect function returned to calculate the normal at the point of intersection using the three triangle vertex normals.

neneboricua

Share this post


Link to post
Share on other sites