I realize that I'm in the wrong forum, but there dosn't seem to be one for non-game applications that use Direct X. I'm not a C++ programmer. I've used Visual Basic and VB.NET to write applications that display objects in 3D. I want to able to allow the user to select one of several 3D objects via the mouse. Can someone supply some sample code in VB or VB.NET that does this.
Thanks in advance.

VB.NET/Direct X 3D object selection using the mouse click.
Jeffrey.Ye
Here is the core of the Intersection. It will return bool if a mesh was selected.
public bool Intersect(Microsoft.DirectX.Direct3D.Device device, Mesh mesh)
{
//intersection information
IntersectInformation closest;
//the near vector
Vector3 near;
//the far vector
Vector3 far;
near = new Vector3(cursor.X, cursor.Y, 0); //the mouse coordinates
far = new Vector3(cursor.X, cursor.Y, 1); //the mouse coordinates
near.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, entity.MatWorld);
far.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, entity.MatWorld);
far.Subtract(near);
if(mesh.Intersect(near, far, out closest))
return true;
return false;
}
This method just makes sure that the coordinates you get for the mouse is perfect. Method name is self explanatory.
[code language = "c#"]
private void ValidateMouseCoordinates(Form window)
{
//Computes the screen space coordinates to client coordinates
cursor = window.PointToClient(Cursor.Position);
if(cursor.X < 0) //if the x position is less than 0. set it to the window width
cursor.X = window.Width;
if(cursor.Y < 0) //if the y position is less than 0. set it to the window height
cursor.Y = window.Height;
}
[/code]
I hope this helps.
Take care.
BennyAndGisela
learning_to_code
dhtroy
The Feb 06 SDK contains c++ version, but indeed no managed version. Sorry!
I still recommend looking at it's source, as the concepts are the same in both managed and unmanaged dx, even though the syntax differs somewhat.