Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofxAssimpModelLoader aiMatrix4x4ToOfMatrix4x4 #1358

Closed
neuroprod opened this issue Jun 27, 2012 · 4 comments
Closed

ofxAssimpModelLoader aiMatrix4x4ToOfMatrix4x4 #1358

neuroprod opened this issue Jun 27, 2012 · 4 comments

Comments

@neuroprod
Copy link

line nr 86 this:

float m[16] = { aim.a1,aim.a2,aim.a3,aim.a4,
                    aim.b1,aim.b2,aim.b3,aim.b4,
                    aim.c1,aim.c2,aim.c3,aim.c4,
                    aim.d1,aim.d2,aim.d3,aim.d4 };

should be this

float m[16] = { aim.a1,aim.b1,aim.c1,aim.d1,
                    aim.a2,aim.b2,aim.c2,aim.d2,
                    aim.a3,aim.b3,aim.c3,aim.d3,
                    aim.a4,aim.b4,aim.c4,aim.d4 };
@kylemcdonald
Copy link
Contributor

are you sure? it seems like this would completely break all of the animation stuff that's currently supported. do you have a demo where the new one works, but the old one is broken?

@neuroprod
Copy link
Author

It's just not used by the addon, everything is done in assimp data types. so it doesn't break anything

here is a simple testcase:

aiMatrix4x4 aim;
    aiMatrix4x4::Translation(aiVector3D(10, 5, 2), aim );
    float mNow[16] = { aim.a1,aim.a2,aim.a3,aim.a4,
        aim.b1,aim.b2,aim.b3,aim.b4,
        aim.c1,aim.c2,aim.c3,aim.c4,
        aim.d1,aim.d2,aim.d3,aim.d4 };

    ofMatrix4x4 test;
    test.set(mNow);
    cout <<"current :"<<endl<< test << endl<< endl;


    float mCorrect[16] = { aim.a1,aim.b1,aim.c1,aim.d1,
        aim.a2,aim.b2,aim.c2,aim.d2,
        aim.a3,aim.b3,aim.c3,aim.d3,
        aim.a4,aim.b4,aim.c4,aim.d4 };

    test.set(mCorrect);
    cout <<"correct:"<<endl<<  test << endl;

output: first is a scale matrix , second the correct translation

current :
1, 0, 0, 10
0, 1, 0, 5
0, 0, 1, 2
0, 0, 0, 1

correct:
1, 0, 0, 0
0, 1, 0, 0
0, 0, 1, 0
10, 5, 2, 1

@kylemcdonald
Copy link
Contributor

aha, i see there was a function called aiNodeToOfNode() where it was used, but the function is now commented out (maybe because this didn't work). i'll label this bite-size, and we can make the swap. thanks!

@NickHardeman
Copy link
Contributor

Wow, this is about 10 years old!
In the new ofxAssimp add-on there are some helper functions, including

inline static glm::mat4 aiMatrix4x4ToGlmMatrix(const aiMatrix4x4& amat ) {
// glm::mat4 tmatrix(amat.a1, amat.a2, amat.a3, amat.a4,
// amat.b1, amat.b2, amat.b3, amat.b4,
// amat.c1, amat.c2, amat.c3, amat.c4,
// amat.d1, amat.d2, amat.d3, amat.d4);
glm::mat4 tmatrix(amat.a1, amat.b1, amat.c1, amat.d1,
amat.a2, amat.b2, amat.c2, amat.d2,
amat.a3, amat.b3, amat.c3, amat.d3,
amat.a4, amat.b4, amat.c4, amat.d4);
return tmatrix;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants