I have a very simple terrain map, 256x256 tiles for example, it's divided into tiles (same squares...). every tile have height, slope... Something like figure below. My default look will be an iso view. (Each tile can be divied into smaller tiles for smooth, i called tesselation)
D3DXMatrixOrthoLH(&matProj, videoWidth , videoHeight , -100000, 100000);
float xPitch=0;
float yPitch=PI/3.0; //rotate yPitch 60 degree
float zPitch=PI/4.0; //rotate zPitch 45 degree
Now I need to select a unit tile onscreen with mouse (where to move to or build something...)! I have mouse position Mx,My I need to know what tile it is! If the map is flat, it's very easy! but with height, it's difficult. I'm planning to make the map quite static (not rotate often)... only translation. So I can store all the Vertex coordinate (x,y) on screen. By using D3DXVec3Project. And then search the triangles that contain the mouse position-> the tile we needed! However with this approach we may need to search 5-10 or 20 triangles. Do you know any betterway, more optimized or elegant ? Thanks!
I read about something like RayCasting for detection, maybe it can be used in my case. Because there is no eye pos in my view setup, the view vector is constant! 3D Screenspace Raycasting/Picking DirectX9
D3DXVec3Unproject also look quite promising!
Image : http://i1335.photobucket.com/albums/w666/greenpig83/sc4_zpsaaa61249.png