Search code examples
javaopengl-escollada

GLES/Java Collada(.dae) skeleton importing


I'm trying to extract the skeleton from the collada .dae file format. I am able to get the final child node positions properly as well as the root node however the rest of the nodes appear to be incorrect.

Root(Good) -> Child(Sometimes Good/Sometimes Bad) -> ... -> Final Child(Good)

enter image description here enter image description here

As you can see by the images, some of the joins are in the right spot but don't seem to connect properly, other joints are just flat out wrong, and the final joints like the head, finder tips, feet are correct. I think I'm on the right path but am unsure where to look to figure out whats causing the issue.

Here is the code I'm using to get the joint global matrices.

public final float[] getGlobalMatrix() {
        if (mParent != null) {
            Matrix.multiplyMM(mMatrix, 0, mParent.getMatrix(), 0, mLocalBoneTransformMatrix, 0);
        } else {
            final float[] tmp = new float[16];
            Matrix.setIdentityM(tmp, 0);
            Matrix.multiplyMM(mMatrix, 0, tmp, 0, mLocalBoneTransformMatrix, 0);
        }
        return mMatrix;
    }

I'm rendering this in GLEs2.0 so I'm converting the matrices I read in from the collada file using the following method.

private static float[] convertToGLESMatrix(final float[] colladaMatrix) {
        final float[] result = new float[16];
        result[ 0] = colladaMatrix[ 0];
        result[ 1] = colladaMatrix[ 4];
        result[ 2] = colladaMatrix[ 8];
        result[ 3] = colladaMatrix[12];

        result[ 4] = colladaMatrix[ 1];
        result[ 5] = colladaMatrix[ 5];
        result[ 6] = colladaMatrix[ 9];
        result[ 7] = colladaMatrix[13];

        result[ 8] = colladaMatrix[ 2];
        result[ 9] = colladaMatrix[ 6];
        result[10] = colladaMatrix[10];
        result[11] = colladaMatrix[14];

        result[12] = colladaMatrix[ 3];
        result[13] = colladaMatrix[ 7];
        result[14] = colladaMatrix[11];
        result[15] = colladaMatrix[15];
        return result;
    }

This seems to be working fine I just thought Id'e mention it just in case it was an issue.


Solution

  • Turns out my draw function was passing some data by reference in the recursive loop and updating it causing the issues.