Comments (5)
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.
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.
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.
@stewartmiles I did notice that.
from mathfu.
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)
- Matrix vector product question.
- SIMD detection doesn't work on MSVC x64 targets HOT 5
- Projection function HOT 6
- Google_Mathfu failed with warning C4305 when build with MSVC HOT 3
- Expose GetColumn in Matrix
- Remove "vectorial" lib external dependency? HOT 2
- Support for double vectors/matrices (with SIMD)?
- matrix_4x4_simd.h is not included by default HOT 2
- Quaternions are 32 bytes due to alignment constraints instead of 16 bytes
- Api description in GLSL Mappings for typedef Matrix< float, 4, 4 > HOT 1
- CMAKE_SOURCE_DIR vs. CMAKE_CURRENT_SOURCE_DIR usage in studio 3.4 timeframe
- Google_MathFu failed to build due to error C1083 with MSVC on windows HOT 1
- Google_Mathfu failed with warning C4100 when build with MSVC
- When SIMD build disabled, Vector<T, Dims> miss some fundamental methods HOT 1
- Perspective projection matrix (what device coordinates is it mapping to?)
- Is this page wrong? I think there should be no parentheses. HOT 2
- method HadamardProduct of Matrix can not compile
- Bug on Quaternion::LookAt()
- Compile flag Not Updated HOT 1
- When building Google_MathFu emits warning C2220 on MSVC
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mathfu.