Git Product home page Git Product logo

Comments (5)

oblitum avatar oblitum commented on May 5, 2024

I just confirmed in my sample the sole problem I have is this behavior of LookAt when changing from GLM to mathfu. I've created my initial camera from raw data using the GLM output and the rest of the sample using mathfu API and it's working.

from mathfu.

oblitum avatar oblitum commented on May 5, 2024

I've applied this patch to resemble GLM and use mathfu:

diff --git a/include/mathfu/matrix.h b/include/mathfu/matrix.h
index 38dfe6b..cf18181 100644
--- a/include/mathfu/matrix.h
+++ b/include/mathfu/matrix.h
@@ -1299,11 +1299,11 @@ static void LookAtHelperCalculateAxes(
     const Vector<T, 3>& at, const Vector<T, 3>& eye, const Vector<T, 3>& up,
     Vector<T, 3> * const axes) {
   axes[2] = (at - eye).Normalized();
-  axes[0] = Vector<T, 3>::CrossProduct(up, axes[2]).Normalized();
-  axes[1] = Vector<T, 3>::CrossProduct(axes[2], axes[0]);
+  axes[0] = Vector<T, 3>::CrossProduct(axes[2], up).Normalized();
+  axes[1] = Vector<T, 3>::CrossProduct(axes[0], axes[2]);
   axes[3] = Vector<T, 3>(-Vector<T, 3>::DotProduct(axes[0], eye),
                          -Vector<T, 3>::DotProduct(axes[1], eye),
-                         -Vector<T, 3>::DotProduct(axes[2], eye));
+                          Vector<T, 3>::DotProduct(axes[2], eye));
 }
 /// @endcond

@@ -1314,9 +1314,9 @@ static inline Matrix<T, 4, 4> LookAtHelper(
     const Vector<T, 3>& at, const Vector<T, 3>& eye, const Vector<T, 3>& up) {
   Vector<T, 3> axes[4];
   LookAtHelperCalculateAxes(at, eye, up, axes);
-  const Vector<T, 4> column0(axes[0][0], axes[1][0], axes[2][0], 0);
-  const Vector<T, 4> column1(axes[0][1], axes[1][1], axes[2][1], 0);
-  const Vector<T, 4> column2(axes[0][2], axes[1][2], axes[2][2], 0);
+  const Vector<T, 4> column0(axes[0][0], axes[1][0], -axes[2][0], 0);
+  const Vector<T, 4> column1(axes[0][1], axes[1][1], -axes[2][1], 0);
+  const Vector<T, 4> column2(axes[0][2], axes[1][2], -axes[2][2], 0);
   const Vector<T, 4> column3(axes[3], 1);
   return Matrix<T, 4, 4>(column0, column1, column2, column3);
 }

from mathfu.

stewartmiles avatar stewartmiles commented on May 5, 2024

It looks like we didn't add a handed-ness parameter for this method (unlike
Perspective -
http://google.github.io/mathfu/classmathfu_1_1_matrix.html#a6e66814f9b9659706588dc99362cbe4a
).

On Sun, Feb 1, 2015 at 7:53 PM, Francisco Lopes [email protected]
wrote:

I've applied this path to resemble GLM and use mathfu:

diff --git a/include/mathfu/matrix.h b/include/mathfu/matrix.h
index 38dfe6b..cf18181 100644--- a/include/mathfu/matrix.h+++ b/include/mathfu/matrix.h@@ -1299,11 +1299,11 @@ static void LookAtHelperCalculateAxes(
const Vector<T, 3>& at, const Vector<T, 3>& eye, const Vector<T, 3>& up,
Vector<T, 3> * const axes) {
axes[2] = (at - eye).Normalized();- axes[0] = Vector<T, 3>::CrossProduct(up, axes[2]).Normalized();- axes[1] = Vector<T, 3>::CrossProduct(axes[2], axes[0]);+ axes[0] = Vector<T, 3>::CrossProduct(axes[2], up).Normalized();+ axes[1] = Vector<T, 3>::CrossProduct(axes[0], axes[2]);
axes[3] = Vector<T, 3>(-Vector<T, 3>::DotProduct(axes[0], eye),
-Vector<T, 3>::DotProduct(axes[1], eye),- -Vector<T, 3>::DotProduct(axes[2], eye));+ Vector<T, 3>::DotProduct(axes[2], eye));
}
/// @endcond
@@ -1314,9 +1314,9 @@ static inline Matrix<T, 4, 4> LookAtHelper(
const Vector<T, 3>& at, const Vector<T, 3>& eye, const Vector<T, 3>& up) {
Vector<T, 3> axes[4];
LookAtHelperCalculateAxes(at, eye, up, axes);- const Vector<T, 4> column0(axes[0][0], axes[1][0], axes[2][0], 0);- const Vector<T, 4> column1(axes[0][1], axes[1][1], axes[2][1], 0);- const Vector<T, 4> column2(axes[0][2], axes[1][2], axes[2][2], 0);+ const Vector<T, 4> column0(axes[0][0], axes[1][0], -axes[2][0], 0);+ const Vector<T, 4> column1(axes[0][1], axes[1][1], -axes[2][1], 0);+ const Vector<T, 4> column2(axes[0][2], axes[1][2], -axes[2][2], 0);
const Vector<T, 4> column3(axes[3], 1);
return Matrix<T, 4, 4>(column0, column1, column2, column3);
}


Reply to this email directly or view it on GitHub
#3 (comment).

from mathfu.

oblitum avatar oblitum commented on May 5, 2024

@stewartmiles I did notice that.

from mathfu.

stewartmiles avatar stewartmiles commented on May 5, 2024

This was fixed (kinda) in 72ab10e . We left the default behavior of LookAt() which we know is inconsistent with the other methods that have a handedness parameter to maintain compatibility for existing users.

from mathfu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.