SpiderPig Posted April 30 Share Posted April 30 I'm not positive I'm using it right... but no matter what I do the matrix's rotation (r) is always zero. Where as (i) is correct - Vec3(0,90,90); MakeDir() returns nothing, I checked. auto m = Mat4(); m.MakeDir(Vec3(0,0,1), 1); up_pivot->AlignToVector(Vec3(0,0,1), 1); auto i = up_pivot->GetRotation(); auto r = m.GetRotation(); Quote Link to comment Share on other sites More sharing options...
Josh Posted April 30 Share Posted April 30 Strange...you would expect a lot of problems if these functions were off... Mat4 m; m.MakeDir(Vec3(0, 0, 1), 1); Print("Mat4"); Print(WString(m[0])); Print(WString(m[1])); Print(WString(m[2])); Print(WString(m[3])); Print("Quat"); auto q = m.GetQuaternion(); Print(WString(q)); Print("Euler"); auto r = q.Euler(); Print(WString(r)); Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted April 30 Share Posted April 30 Oh, I think I know why. It's pointing straight down, so you activated Gimbal lock. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted April 30 Solution Share Posted April 30 Use mat.GetQuaternion() to get the exact rotation. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted April 30 Author Share Posted April 30 Thankyou. But should this code give two different results? auto m = Mat4(); m.MakeDir(Vec3(0.0f, 0.0f, 1.0f), 1); Print("Mat4"); Print(WString(m[0])); Print(WString(m[1])); Print(WString(m[2])); Print(WString(m[3])); Print("Quat"); auto q = m.GetQuaternion(); Print(WString(q)); Print("Euler"); auto r = q.Euler(); Print(WString(r)); Print(""); Print("--------------------------------------------------------------"); Print(""); auto up_pivot = CreatePivot(nullptr); up_pivot->AlignToVector(Vec3(0.0f, 0.0f, 1.0f), 1); m = up_pivot->GetMatrix(); Print("Mat4"); Print(WString(m[0])); Print(WString(m[1])); Print(WString(m[2])); Print(WString(m[3])); Print("Quat"); q = m.GetQuaternion(); Print(WString(q)); Print("Euler"); r = q.Euler(); Print(WString(r)); Console Output. Mat4 1, -0, -0, 0 0, 0, 1, 0 0, 1, 0, 0 0, 0, 0, 1 Quat -0, -0, 0, 0.707107 Euler 0, -0, -0 -------------------------------------------------------------- Mat4 0, 1, -0, 0 0, 0, 1, 0 1, -0, -0, 0 0, 0, 0, 1 Quat -0.5, -0.5, -0.5, 0.5 Euler -0, 90, 90 Quote Link to comment Share on other sites More sharing options...
Josh Posted April 30 Share Posted April 30 It may. Aligning an object to a vector is an ambiguous operation. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted April 30 Share Posted April 30 The entity method takes roll into account, and tries to make the best decision. The Mat4 method is simpler. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted April 30 Author Share Posted April 30 Oh okay, I thought maybe both did the exact same thing. How would I align a matrix to a vector? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.