# IntersectInformation Problem

**From:** Chris Anderson (*cmanders_at_nospamplease.swiftdsl.com.au*)

**Date:** 10/09/04

**Next message:**Jarred Nicholls: "Re: SDK update"**Previous message:**Armin Zingler: "Re: Device.Indices (correction)"**Next in thread:**ZMan: "Re: IntersectInformation Problem"**Reply:**ZMan: "Re: IntersectInformation Problem"**Messages sorted by:**[ date ] [ thread ]

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.

Thanks in advance

Chris

**Next message:**Jarred Nicholls: "Re: SDK update"**Previous message:**Armin Zingler: "Re: Device.Indices (correction)"**Next in thread:**ZMan: "Re: IntersectInformation Problem"**Reply:**ZMan: "Re: IntersectInformation Problem"**Messages sorted by:**[ date ] [ thread ]