diff --git a/libs/geom/include/psemek/geom/camera.hpp b/libs/geom/include/psemek/geom/camera.hpp index 7969bcff..976e9443 100644 --- a/libs/geom/include/psemek/geom/camera.hpp +++ b/libs/geom/include/psemek/geom/camera.hpp @@ -65,8 +65,10 @@ namespace psemek::geom struct spherical_camera : perspective_camera { - // assumes up is +Y - // + // assumes up is +Z + // azimuthal angle is in XY plane + // both angles zero gives X right, Y forward, and Z up + float azimuthal_angle; float elevation_angle; float distance; diff --git a/libs/geom/source/camera.cpp b/libs/geom/source/camera.cpp index 1bb8ef7b..9b54a9f3 100644 --- a/libs/geom/source/camera.cpp +++ b/libs/geom/source/camera.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include @@ -98,8 +100,10 @@ namespace psemek::geom { return translation({0.f, 0.f, -distance}).homogeneous_matrix() - * homogeneous(plane_rotation(1, 2, elevation_angle).matrix()) - * homogeneous(plane_rotation(2, 0, azimuthal_angle).matrix()) + * homogeneous(swap(1, 2).matrix()) + * homogeneous(scale({1.f, -1.f, 1.f}).matrix()) + * homogeneous(plane_rotation(2, 1, elevation_angle).matrix()) + * homogeneous(plane_rotation(1, 0, azimuthal_angle).matrix()) * translation({ -target[0], -target[1], -target[2] }).homogeneous_matrix() ; }