summaryrefslogtreecommitdiff
path: root/gfx/gl/camera.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan.goodliffe@octal.co.uk>2022-12-13 12:09:29 +0000
committerDan Goodliffe <dan.goodliffe@octal.co.uk>2022-12-13 12:09:29 +0000
commit579c45cc66aa5e68a8a9f9ac44051da450c6225d (patch)
treeeb7a8b1ec6dde6e5443a990200c33ef6c7b3480c /gfx/gl/camera.h
parentMaintain a camera's inverse view projection matrix (diff)
downloadilt-579c45cc66aa5e68a8a9f9ac44051da450c6225d.tar.bz2
ilt-579c45cc66aa5e68a8a9f9ac44051da450c6225d.tar.xz
ilt-579c45cc66aa5e68a8a9f9ac44051da450c6225d.zip
Calculate an accurate up vector for the camera
Diffstat (limited to 'gfx/gl/camera.h')
-rw-r--r--gfx/gl/camera.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/gfx/gl/camera.h b/gfx/gl/camera.h
index 3182969..2d937a0 100644
--- a/gfx/gl/camera.h
+++ b/gfx/gl/camera.h
@@ -24,18 +24,28 @@ public:
void
setForward(const glm::vec3 & f)
{
- forward = f;
- updateView();
+ setForward(f, upFromForward(f));
}
void
- setView(const glm::vec3 & p, const glm::vec3 & f, const glm::vec3 & u = ::up)
+ setForward(const glm::vec3 & f, const glm::vec3 & u)
{
- position = p;
forward = f;
up = u;
updateView();
}
void
+ setView(const glm::vec3 & p, const glm::vec3 & f)
+ {
+ position = p;
+ setForward(f);
+ }
+ void
+ setView(const glm::vec3 & p, const glm::vec3 & f, const glm::vec3 & u)
+ {
+ position = p;
+ setView(f, u);
+ }
+ void
lookAt(const glm::vec3 & target)
{
setForward(glm::normalize(target - position));
@@ -51,6 +61,8 @@ public:
return position;
}
+ static glm::vec3 upFromForward(const glm::vec3 & forward);
+
private:
void updateView();