Change spherical camera: now X is right, Y is forward, Z is up
This commit is contained in:
parent
695da47ade
commit
cf6a8e98eb
2 changed files with 10 additions and 4 deletions
|
|
@ -65,8 +65,10 @@ namespace psemek::geom
|
||||||
struct spherical_camera
|
struct spherical_camera
|
||||||
: perspective_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 azimuthal_angle;
|
||||||
float elevation_angle;
|
float elevation_angle;
|
||||||
float distance;
|
float distance;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#include <psemek/geom/perspective.hpp>
|
#include <psemek/geom/perspective.hpp>
|
||||||
#include <psemek/geom/translation.hpp>
|
#include <psemek/geom/translation.hpp>
|
||||||
#include <psemek/geom/rotation.hpp>
|
#include <psemek/geom/rotation.hpp>
|
||||||
|
#include <psemek/geom/permutation.hpp>
|
||||||
|
#include <psemek/geom/scale.hpp>
|
||||||
#include <psemek/geom/homogeneous.hpp>
|
#include <psemek/geom/homogeneous.hpp>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
@ -98,8 +100,10 @@ namespace psemek::geom
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
translation<float, 3>({0.f, 0.f, -distance}).homogeneous_matrix()
|
translation<float, 3>({0.f, 0.f, -distance}).homogeneous_matrix()
|
||||||
* homogeneous(plane_rotation<float, 3>(1, 2, elevation_angle).matrix())
|
* homogeneous(swap<float, 3>(1, 2).matrix())
|
||||||
* homogeneous(plane_rotation<float, 3>(2, 0, azimuthal_angle).matrix())
|
* homogeneous(scale<float, 3>({1.f, -1.f, 1.f}).matrix())
|
||||||
|
* homogeneous(plane_rotation<float, 3>(2, 1, elevation_angle).matrix())
|
||||||
|
* homogeneous(plane_rotation<float, 3>(1, 0, azimuthal_angle).matrix())
|
||||||
* translation<float, 3>({ -target[0], -target[1], -target[2] }).homogeneous_matrix()
|
* translation<float, 3>({ -target[0], -target[1], -target[2] }).homogeneous_matrix()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue