@@ -13,23 +13,23 @@ namespace sndx::render {
1313
1414 [[nodiscard]]
1515 glm::mat4 getViewMatrix () const {
16- auto out = glm::translate (glm::mat4 (1.0 ), pos);
17- return glm::mat4_cast (orientation) * out;
16+ auto out = glm::translate (glm::mat4 (1.0 ), - pos);
17+ return glm::mat4_cast (glm::conjugate ( orientation) ) * out;
1818 }
1919
2020 [[nodiscard]]
2121 glm::vec3 getForward () const {
22- return glm::inverse ( orientation) * glm::vec3 (0.0 , 0.0 , 1.0 );
22+ return orientation * glm::vec3 (0.0 , 0.0 , 1.0 );
2323 }
2424
2525 [[nodiscard]]
2626 glm::vec3 getUp () const {
27- return glm::inverse ( orientation) * glm::vec3 (0.0 , 1.0 , 0.0 );
27+ return orientation * glm::vec3 (0.0 , 1.0 , 0.0 );
2828 }
2929
3030 [[nodiscard]]
3131 glm::vec3 getRight () const {
32- return glm::inverse ( orientation) * glm::vec3 (- 1.0 , 0.0 , 0.0 );
32+ return orientation * glm::vec3 (1.0 , 0.0 , 0.0 );
3333 }
3434
3535 // in degrees! not radians!
@@ -71,17 +71,20 @@ namespace sndx::render {
7171 return *this ;
7272 }
7373
74- Camera& lookAt (const glm::vec3& at) {
74+ Camera& lookAt (const glm::vec3& at, const glm::vec3& up ) {
7575 auto direction = at - pos;
7676 auto len = glm::length (direction);
7777
7878 if (len < 0 .0001f )
7979 return *this ;
8080
8181 direction /= len;
82-
83- orientation = glm::quatLookAt (direction, getUp ());
82+ orientation = glm::quatLookAt (direction, up);
8483 return *this ;
8584 }
85+
86+ Camera& lookAt (const glm::vec3& at) {
87+ return lookAt (at, getUp ());
88+ }
8689 };
8790}
0 commit comments