How do you select more than 1 model at a time with picking,the same idea in rts games where you make a box in 2D i think and it selects the units in 3D,how would i achieve this effect?
Edited by Anddos, 14 December 2013 - 03:22 PM.
Jump to content
Posted 14 December 2013 - 03:36 PM
I think there are 2 ways for this problem. First you use D3DVectorProject to project vertexes of your unit in 3dWorld to ScreenWorld (AaBox for example). Then checking it with your 2d Rect. I think this is very simple, just to optimize the number of Project call, as I know it's not very fast! (<100 is ok, but more is not good)
The more common way, is to generate a Frustum with your Rect. This is just like how you pre detect which Mesh is on Screen (The rect here is your Video size). Then checking if your unit/mesh is inside your Frustum! This way is more complex, because you do things in the 3dWorld...
If you want to learn about Frustum Culling this article is very nice : http://www.flipcode.com/archives/Frustum_Culling.shtml
In the both approach. You must first have a pre select step, select only mesh/ unit that are potential. So the number of check is short. Although there are case, when all unit stay at some point, and a simple box, will select all of them (hundred to thousand ...), in that case will need a lot of optimize, if you dont want to do checking all of them!
Edited by greenpig83, 14 December 2013 - 03:42 PM.