| 808 | } |
| 809 | |
| 810 | void GuiShapeEdPreview::fitToShape() |
| 811 | { |
| 812 | if ( !mModel ) |
| 813 | return; |
| 814 | |
| 815 | // Determine the shape bounding box given the current camera rotation |
| 816 | MatrixF camRotMatrix( smCamMatrix ); |
| 817 | camRotMatrix.setPosition( Point3F::Zero ); |
| 818 | camRotMatrix.inverse(); |
| 819 | |
| 820 | Box3F bounds; |
| 821 | computeSceneBounds( bounds ); |
| 822 | mOrbitPos = bounds.getCenter(); |
| 823 | |
| 824 | camRotMatrix.mul( bounds ); |
| 825 | |
| 826 | // Estimate the camera distance to fill the view by comparing the radii |
| 827 | // of the box and the viewport |
| 828 | F32 len_x = bounds.len_x(); |
| 829 | F32 len_z = bounds.len_z(); |
| 830 | F32 shapeRadius = mSqrt( len_x*len_x + len_z*len_z ) / 2; |
| 831 | F32 viewRadius = 0.45f * getMin( getExtent().x, getExtent().y ); |
| 832 | |
| 833 | // Set camera parameters |
| 834 | if ( mDisplayType == DisplayTypePerspective ) |
| 835 | { |
| 836 | mOrbitDist = ( shapeRadius / viewRadius ) * mSaveWorldToScreenScale.y; |
| 837 | } |
| 838 | else |
| 839 | { |
| 840 | mOrthoCamTrans.set( 0, 0, 0 ); |
| 841 | mOrthoFOV = shapeRadius * viewRadius / 320; |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | void GuiShapeEdPreview::setOrbitPos( const Point3F& pos ) |
| 846 | { |
no test coverage detected