| 866 | } |
| 867 | |
| 868 | void GuiShapeEdPreview::fitToShape() |
| 869 | { |
| 870 | if ( !mModel ) |
| 871 | return; |
| 872 | |
| 873 | // Determine the shape bounding box given the current camera rotation |
| 874 | MatrixF camRotMatrix( smCamMatrix ); |
| 875 | camRotMatrix.setPosition( Point3F::Zero ); |
| 876 | camRotMatrix.inverse(); |
| 877 | |
| 878 | Box3F bounds; |
| 879 | computeSceneBounds( bounds ); |
| 880 | mOrbitPos = bounds.getCenter(); |
| 881 | |
| 882 | camRotMatrix.mul( bounds ); |
| 883 | |
| 884 | // Estimate the camera distance to fill the view by comparing the radii |
| 885 | // of the box and the viewport |
| 886 | F32 len_x = bounds.len_x(); |
| 887 | F32 len_z = bounds.len_z(); |
| 888 | F32 shapeRadius = mSqrt( len_x*len_x + len_z*len_z ) / 2; |
| 889 | F32 viewRadius = 0.45f * getMin( getExtent().x, getExtent().y ); |
| 890 | |
| 891 | // Set camera parameters |
| 892 | if ( mDisplayType == DisplayTypePerspective ) |
| 893 | { |
| 894 | mOrbitDist = ( shapeRadius / viewRadius ) * mSaveWorldToScreenScale.y; |
| 895 | } |
| 896 | else |
| 897 | { |
| 898 | mOrthoCamTrans.set( 0, 0, 0 ); |
| 899 | mOrthoFOV = shapeRadius * viewRadius / 320; |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | void GuiShapeEdPreview::setOrbitPos( const Point3F& pos ) |
| 904 | { |
no test coverage detected