| 791 | } |
| 792 | |
| 793 | void Viewport::cameraLookAlong( const Vector3f& newDir, const Vector3f& up ) |
| 794 | { |
| 795 | assert( std::abs( dot( newDir.normalized(), up.normalized() ) ) < 1e-6f ); |
| 796 | |
| 797 | Vector3f lookDir = cameraCenter - cameraEye; |
| 798 | auto rotLook = Matrix3f::rotation( newDir, lookDir ); |
| 799 | |
| 800 | auto upVec = rotLook.inverse() * cameraUp; |
| 801 | float sign = 1.0f; |
| 802 | if ( dot( cross( up, upVec ), newDir ) < 0.0f ) |
| 803 | sign = -1.0f; |
| 804 | |
| 805 | auto rotUp = Matrix3f::rotation( newDir, sign * angle( up, upVec ) ); |
| 806 | |
| 807 | params_.cameraTrackballAngle = rotLook; |
| 808 | params_.cameraTrackballAngle = params_.cameraTrackballAngle * Quaternionf( rotUp ); |
| 809 | |
| 810 | needRedraw_ = true; |
| 811 | } |
| 812 | |
| 813 | void Viewport::cameraRotateAround( const Line3f& axis, float angle ) |
| 814 | { |
no test coverage detected