diff options
author | David Doan <daviddoan@Davids-MacBook-Pro-100.local> | 2023-12-08 16:18:34 -0500 |
---|---|---|
committer | David Doan <daviddoan@Davids-MacBook-Pro-100.local> | 2023-12-08 16:18:34 -0500 |
commit | 7fff3eb8df3eb102398aa238e19cc5c48365021f (patch) | |
tree | d9d8fa37bd6325bc58d4fbe1d6d40f1d92bc09b2 /src/vec4ops/vec4ops.cpp | |
parent | 281ebd77fbfe0686c789c2a7ba6e7e9d1e0db3f3 (diff) |
camera stuff
Diffstat (limited to 'src/vec4ops/vec4ops.cpp')
-rw-r--r-- | src/vec4ops/vec4ops.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/vec4ops/vec4ops.cpp b/src/vec4ops/vec4ops.cpp index 80cebaf..458bc1f 100644 --- a/src/vec4ops/vec4ops.cpp +++ b/src/vec4ops/vec4ops.cpp @@ -1,5 +1,6 @@ #include <stdexcept> #include "vec4ops.h" +#include "settings.h" // vector operations on 4d vectors, // reference: https://hollasch.github.io/ray4/Four-Space_Visualization_of_4D_Objects.html#chapter5 @@ -36,6 +37,16 @@ glm::mat4 Vec4Ops::getViewMatrix4( glm::vec4 upVector, glm::vec4 lookVector) { + // rotation matrices for each plane + glm::mat4 rotMatrixXY = getRotationMatrix4XY(glm::radians(settings.xy)); + glm::mat4 rotMatrixXZ = getRotationMatrix4XZ(glm::radians(settings.xz)); + glm::mat4 rotMatrixYZ = getRotationMatrix4YZ(glm::radians(settings.yz)); + glm::mat4 rotMatrixXW = getRotationMatrix4XW(glm::radians(settings.xw)); + glm::mat4 rotMatrixYW = getRotationMatrix4YW(glm::radians(settings.yw)); + glm::mat4 rotMatrixZW = getRotationMatrix4ZW(glm::radians(settings.zw)); + + glm::mat4 combinedRotationMatrix = rotMatrixXY * rotMatrixYZ * rotMatrixXZ * rotMatrixXW * rotMatrixYW * rotMatrixZW; + // calculate e3 basis vector, the transformation col of view matrix if (glm::distance(fromPoint, toPoint) < 0.0001f) { throw std::runtime_error("fromPoint and toPoint are the same"); @@ -60,5 +71,17 @@ glm::mat4 Vec4Ops::getViewMatrix4( glm::vec4 e0 = cross4(e3, e2, e1); e0 = glm::normalize(e0); + // Apply the combined rotation matrix to the view basis vectors + e0 = combinedRotationMatrix * e0; + e1 = combinedRotationMatrix * e1; + e2 = combinedRotationMatrix * e2; + e3 = combinedRotationMatrix * e3; + + // Normalizing might be necessary after applying the rotation + e0 = glm::normalize(e0); + e1 = glm::normalize(e1); + e2 = glm::normalize(e2); + e3 = glm::normalize(e3); + return {e2, e1, e0, e3}; }
\ No newline at end of file |