Sign in to follow this  
EnochDagor

Mesh.Intersect Issue

Recommended Posts

Alright, I am trying to use Mesh.Intersect with an Origin Vector3, Direction Vector3 and the out of the IntersectionInformation. I know that the vectors passed in have to be in Model space. Here is what I have coming into the function that I am working on... i need to know what to do with each element in order to get the final result: * vFrom - Point in World Space where I am casting my ray from - some arbitrary point * vTo - Point in Model Space where I am casting my ray to - just a random vertex on the mesh * TargetMatrix - The World Matrix of the target Mesh * FromMatrix - The World matrix of the origin point Here's what I need... I need to translate vTo based on where the ray cast from vFrom to vTo actually ends up hitting the mesh. The result needs to be in model space. For example: vFrom -------ray------- [ vTo If there is a part of the mesh between vFrom and vTo, I want the resulting coordinate position in Model Space of that intersection. I've tried a lot of different items but I am getting my butt kicked on this. I can read any language that uses DX so all comments are welcome. Editted for spelling and clarification.

Share this post


Link to post
Share on other sites

So basically you want the exact point of intersection on the intersected triangle, right?

You could obtain the three vertices making up this triangle (last part of this) and then use these vertices with the barycentric coordinates from the IntersectionInformation to determine the exact point on the triangle. I haven't used it myself before, but Vector3.BaryCentric looks like it will take care of that for you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this