# Lost Mouse in a 3D World.

This topic is 4706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Howdy all, I've been searching for sometime now and need some direction in using the mouse to select my meshes in the 3D world. Here is what I have done so far. I've modelled a basic wheel and converted to .x. I get my wheel in my 3D world. I can use key presses and even button presses on my mouse to do things like rotate camera, move camera closer/further to the tire, and a mouse button switches my mesh to wireframe. I want to put up two tires in 3D space and be able to click on either one or the other to get the tires spinning the opposite way. What is the concept that I need to understand to start figuring out how to select meshes using the mouse in my 3D world. Any help would be sincerely appreciated. Toad

##### Share on other sites
I believe the term you want is "3D picking". Basically you calculate where the object (tire) will be on the screen when it is rendered and compare it with the mouse coordinates. To make it a bit easier, you can use a simpler bounding sphere. This won't be as accurate, but easier to implement.

D3DX may incorporate functions for ray-triangle intersections, you could try this as well.

##### Share on other sites
Quote:
 Original post by Sr_GuapoI believe the term you want is "3D picking". Basically you calculate where the object (tire) will be on the screen when it is rendered and compare it with the mouse coordinates. To make it a bit easier, you can use a simpler bounding sphere. This won't be as accurate, but easier to implement.D3DX may incorporate functions for ray-triangle intersections, you could try this as well.

In addition to this, look into these functions:

D3DXIntersect method
D3DXIntersectSubset method
D3DXIntersectTri method

And this one:

D3DXVec3Unproject method

These are the functions you'll most likely use.

If you got any question, please don't hasitate to ask them, good luck.

Regards,

Xeile

##### Share on other sites
There is also a "Pick" sample in the latest (December '05) SDK that does pretty much exactly what you want [smile]

hth
Jack

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013549
×