Hi all
I am making an rts, and I've just made it 3d. I know how to make a single guy picking function, but what should I do with selecting multiple guys? Should I process the same function for each pixel in the drawn rectangle? Or is there any more efficient method?
Any help appreciated
Use that rectangle to project a selection frustum into the scene, and use this frustum to determine which of your selectable units are within the area of selection. This should most definitely NOT be a pixel by pixel test. That would be far too processing intensive.
thank you a lot
Now, is there any handy function to do this ( like D3DXIntersect for ray picking ) or do I have to write such function myself, or should I concentrate on the unit's position only and I gnore the whole mesh?
I don't believe there's any D3DX utility to handle multi-picking. I wouldn't bother with testing the entire mesh. That's way overkill. You probably will want to do at least a spherical hit test, and just play around with the sphere size to get a 'good enough' selection. That should be more than adequate for selecting a group of units in an RTS unless you have units with highly irregular shapes.