Original Post
Hey guys, I got a new question regarding this topic: http://www.gamedev.net/community/forums/topic.asp?topic_id=336374 I use DirectX 9.0c and MS VC++ (non-managed). I have created lots of boxes using D3DXCreateBox and I place them using D3DXMatrixTranslation. So when I draw them I use translation first. There are no collision in boxes. And I would like to color the box when mouse is over it. So I use a picking ray. My problem is how to get min and max using D3DXBoxBoundProbe. First I tried to give this parameter to D3DXBoxBoundProbe function cause boxes do not change place. But this method did not work out cause it can select the near box. Maybe I need to calculate bounding box by using D3DXComputeBoundingBox but I dunno how to get "CONST D3DXVECTOR3 * pFirstPosition" since I do not create FVF for it. One more thing is it enough to calculate bounding box only once when I initializing application or should I need to calculate it each time on mouse move? this is how I calculate picking ray: float px = 0.0f; float py = 0.0f; D3DVIEWPORT9 vp; d3ddev->GetViewport(&vp); D3DXMATRIX proj; d3ddev->GetTransform(D3DTS_PROJECTION, &proj); px = ((( 2.0f*x) / vp.Width) - 1.0f) / proj(0, 0); py = (((-2.0f*y) / vp.Height) + 1.0f) / proj(1, 1); origin = D3DXVECTOR3(0.0f, 0.0f, 0.0f); direction = D3DXVECTOR3(px, py, 1.0f); // transform the ray to world space D3DXMATRIX view; d3ddev->GetTransform(D3DTS_VIEW, &view); D3DXMATRIX viewInverse; D3DXMatrixInverse(&viewInverse, 0, &view); // transform the ray's origin, w = 1. D3DXVec3TransformCoord(&origin, &origin, T); // transform the ray's direction, w = 0. D3DXVec3TransformNormal(&direction, &direction, T); // normalize the direction D3DXVec3Normalize(&direction, &direction); Thank you all guys...