Add camera::direction()

This commit is contained in:
Nikita Lisitsa 2020-09-23 21:56:25 +03:00
parent 86785a5923
commit 2dd9ebae76
2 changed files with 7 additions and 0 deletions

View file

@ -24,6 +24,8 @@ namespace psemek::geom
virtual vector<float, 3> axis_y() const;
virtual vector<float, 3> axis_z() const;
virtual vector<float, 3> direction() const;
// x, y are in clip-space [-1, 1]
// NB: this vector is not necessarily normalized
virtual vector<float, 3> direction(float x, float y) const;

View file

@ -46,6 +46,11 @@ namespace psemek::geom
return { b[0], b[1], b[2] };
}
vector<float, 3> camera::direction() const
{
return -axis_z();
}
vector<float, 3> camera::direction(float x, float y) const
{
vector<float, 4> b{ x, y, -1.f, 1.f};