# IntersectInformation Problem

Date: 10/09/04

```Date: Sun, 10 Oct 2004 00:16:22 +1000

```

Hi all

I'm a relative newcomer to DirectX, and am having some troubles. I have two
questions - both to do with the age old question of picking a mesh with the
mouse. Going through old newsgroup posts, I can see this problem listed
many times and many answers given, which have allowed me to actually work
out what mesh the user has selected (by projecting a ray in the direction of
the mouse coordinates and using the mesh.Intersect to determine whether a
specified mesh intersects with this ray or not). So that isn't the actual
problem I'm having. What I then need to be able to do (and this is my
problem) is determine exactly at what point in 3D world space the
intersection with the mesh was (ie. as a Vector3). Now the mesh.Intersect
function returns an IntersectInformation structure (I'm programming in C# by
the way), that returns a FaceIndex, intersection Distance along the ray, and
the Bayesian coordinates U and V. Now these coordinates are probably what I
need, but I don't know how to translate them into the world space. Then
with the second problem I want to do the same sort of thing, picking a point
in world space, but this time not necessarily on a mesh. However, I will
have a reference point (the point from the previous question) as a ground
reference.

I'll give an example of what I am trying to do to maybe make it a bit
clearer:

I want the user to be able to select a point on a mesh representing the
ground, using the mouse. That point is to be my launch point for a
projectile. Ideally, I would then like the user to be able to select a
point somewhere above this (ie. in the sky where there is no mesh)
specifying a point which the projectile should pass through on its flight (I
will then calculate its direction and launch velocity). While this is a 3D
world, I will assume that the second point has the same z value as the first
point, and I am merely specifying the x and y values.

I think the second problem should fall into place if I can work out the
first (hopefully at least anyway). My mathematics isn't so flash, so the
more detailed your anwer is (code would be ideal), the better. I've pretty
much exhausted all my knowledge on this one and searches on Google have also
come up with nothing, so any help you can provide would be much appreciated.

Chris

## Relevant Pages

• Re: IntersectInformation Problem
... Thanks for your help ZMan. ... the intersection test had been done (I would need to convert to C#, ... pIntersection->tv results give me a point on the texture overlaying the mesh ... Then with the second problem I ...
(microsoft.public.win32.programmer.directx.managed)
• Re: Merging Triangular Meshes
... > The Union of two triangle meshes is not, unfortunately, a usable ... > triangle mesh any more. ... intersection it would even generate a well formed tri-mesh. ...
(comp.graphics.algorithms)
• Re: DragNDrop
... The code you supplied seems like an odd way to calculate the intersection ... To pick my mesh is ... > rayObjOrigin = Vector3.TransformCoordinate(rayOrigin, matInverse); ... > rayObjDirection = Vector3.Normalize; ...
(microsoft.public.win32.programmer.directx.managed)
• Re: BaryCentric for meshes
... > the intersection was? ... Is any method for the class mesh that does the same ... which contains the distance along the ray to the ... reflect the official views of the Microsoft Corporation. ...
(microsoft.public.win32.programmer.directx.managed)
• Re: IntersectInformation Problem
... If you have a triangle v0, v1, v2 then u and v are barycentric coordinates ... > two questions - both to do with the age old question of picking a mesh ... > determine whether a specified mesh intersects with this ray or not). ... Then with the second problem I want to do the ...
(microsoft.public.win32.programmer.directx.managed)