   Collision - DirectX, C++
  Here is a screenshot of my application. I compute the distance from the camera to a tree and it is correct. How do I use this distance to make a camera that would be in a collision with a tree - stop and not pass through it:D3DXMATRIX mxWorld;mxWorld._41 = m_Trees.vPos.x;mxWorld._42 = m_Trees.vPos.y;mxWorld._43 = m_Trees.vPos.z;p_d3d_Device->SetTransform( D3DTS_WORLD, &mxWorld );// Render the billboardp_d3d_Device->DrawPrimitive( D3DPT_TRIANGLESTRIP, m_Trees.dwOffset, 2 );// Rotate billboard by 90 degreeD3DXMATRIX matRotY;D3DXMatrixRotationY(&matRotY,D3DXToRadian(90));D3DXMATRIX matRes;matRes=matRotY*mxWorld;p_d3d_Device->SetTransform( D3DTS_WORLD, &matRes );// Render the billboardp_d3d_Device->DrawPrimitive( D3DPT_TRIANGLESTRIP, m_Trees.dwOffset, 2 );//Get camera positionD3DXVECTOR3 vPos = m_Camera.GetEyePt();//subtract vectors tree position and camera positionD3DXVECTOR3 vSub = m_Trees.vPos - vPos;//distance from tree to camerafloat fDist = sqrtf(vSub.x*vSub.x+vSub.y*vSub.y+vSub.z*vSub.z);
  The most simple solution would be not allowing the camera to get closer than a certain distance. So before you move the camera check if the new position is not too close to the tree and proceed, otherwise don't move to that position.   