private void PerformSelectionWithSelectionBox( Math.Vector2 first, Math.Vector2 second )
{
Log( "MouseSelector: " + _name + " performing selection." );
float left = first.x, right = second.x,
top = first.y, bottom = second.y;
if ( left > right )
Utility.Swap( ref left, ref right );
if ( top > bottom )
Utility.Swap( ref top, ref bottom );
if ( ( right - left ) * ( bottom - top ) < 0.0001 )
return;
Ray topLeft = _Camera.GetCameraToViewportRay( left, top );
Ray topRight = _Camera.GetCameraToViewportRay( right, top );
Ray bottomLeft = _Camera.GetCameraToViewportRay( left, bottom );
Ray bottomRight = _Camera.GetCameraToViewportRay( right, bottom );
Math.PlaneBoundedVolume vol = new PlaneBoundedVolume();
vol.planes.Add( new Math.Plane( topLeft.GetPoint( 3 ), topRight.GetPoint( 3 ), bottomRight.GetPoint( 3 ) ) ); // front plane
vol.planes.Add( new Math.Plane( topLeft.Origin, topLeft.GetPoint( 100 ), topRight.GetPoint( 100 ) ) ); // top plane
vol.planes.Add( new Math.Plane( topLeft.Origin, bottomLeft.GetPoint( 100 ), topLeft.GetPoint( 100 ) ) ); // left plane
vol.planes.Add( new Math.Plane( bottomLeft.Origin, bottomRight.GetPoint( 100 ), bottomLeft.GetPoint( 100 ) ) ); // bottom plane
vol.planes.Add( new Math.Plane( topRight.Origin, topRight.GetPoint( 100 ), bottomRight.GetPoint( 100 ) ) ); // right plane
PlaneBoundedVolumeList volList = new PlaneBoundedVolumeList();
volList.Add( vol );
PlaneBoundedVolumeListSceneQuery volQuery;
volQuery = Root.Instance.SceneManager.CreatePlaneBoundedVolumeQuery( new PlaneBoundedVolumeList() );
volQuery.Volumes = volList;
SceneQueryResult result = volQuery.Execute();
foreach ( MovableObject obj in result.objects )
{
SelectObject( obj );
}
}