Introduction - If you have any usage issues, please Google them yourself
Ever mesh in the scene has a unique color value(DWORD). Picking, render the scene to target(texture), just use the unique color( see .fx file ), retrieve the mouse position(screen space ) color at once, check the color and you will get the mesh. Picking with Render to texture, Not need lock vertex buffer to check intersection ray and triangle, within retrieving just lock one pixel. Device must support render to target、D3DFMT_A8R8G8B8 or D3DFMT_X8R8G8B8、not 2^n texture size、support shader of course.
Compile Environment:
DX SDK above Aug. , 2006 vc 2005
Thinking:
1. Use a class to encapsulate
2. Picking check return the pointer of the mesh( or reference )