Original Post
Hi guys,
I''m working on my mouse picking routine, which is simple enough, I''m basically using the pick sample in D3D as a guide.
One modification I''m making though is that I''m using bounding boxes rather than testing against every face in the mesh (which seems horribly inefficient to me).
As an obvious intermediate step, I need to create bounding boxes against all the models I want to test for in the pick routine. Easy enough, I used D3DXComputeBoundingBox() for this, which seems to work.
However, for the purposes of testing and debugging, I decided I wanted to draw the boxes as well so I can see them on screen. I think I have a method to do this, but I also feel like I''m floundering a bit, so I wanted to ask and see if y''all think this is an appropriate method.
First, during my D3D init procedure, I create a line using the D3DXCreateLine() function. Also during this step, for each model, I use the D3DXComputeBoundingBox() to get my two min,max vectors of the box, and I store them with each model type.
On a mouse click when I determine a pick check is needed, I then loop through all of my models that are visible in the viewport, and pull out thier BB vectors. I run each of these vectors through the usual transformations (world -> view -> projection) to get screen coords, then feed these coords to the line to draw the box.
Is that the right idea? Any problems with this method?
-Ron