Jump to content

Mat4::MakeDir not working?


SpiderPig
 Share

Go to solution Solved by Josh,

Recommended Posts

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();

 

Link to comment
Share on other sites

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));

 

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

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

 

Link to comment
Share on other sites

The entity method takes roll into account, and tries to make the best decision. The Mat4 method is simpler.

  • Like 1

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...