Add a free-flying camera
This commit is contained in:
parent
23de4a520e
commit
eb1f5d49ff
2 changed files with 26 additions and 0 deletions
|
|
@ -92,4 +92,17 @@ namespace psemek::geom
|
|||
matrix<float, 4, 4> view() const override;
|
||||
};
|
||||
|
||||
struct free_camera
|
||||
: perspective_camera
|
||||
{
|
||||
// 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;
|
||||
point<float, 3> pos;
|
||||
|
||||
matrix<float, 4, 4> view() const override;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,4 +120,17 @@ namespace psemek::geom
|
|||
return tr.homogeneous_matrix();
|
||||
}
|
||||
|
||||
matrix<float, 4, 4> free_camera::view() const
|
||||
{
|
||||
auto tr =
|
||||
swap<float, 3>(1, 2).transform()
|
||||
* scale<float, 3>({1.f, -1.f, 1.f}).transform()
|
||||
* plane_rotation<float, 3>(1, 2, elevation_angle).transform()
|
||||
* plane_rotation<float, 3>(1, 0, azimuthal_angle).transform()
|
||||
* translation<float, 3>({ -pos[0], -pos[1], -pos[2] }).transform()
|
||||
;
|
||||
|
||||
return tr.homogeneous_matrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue