简体   繁体   English

GLES / Java Collada(.dae)骨架导入

[英]GLES/Java Collada(.dae) skeleton importing

I'm trying to extract the skeleton from the collada .dae file format. 我正在尝试从collada .dae文件格式中提取框架。 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) 根(好)->子(有时好/有时坏)-> ...->最终子(好)

在此处输入图片说明 在此处输入图片说明

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. 我将在GLEs2.0中进行渲染,因此我将使用以下方法转换从collada文件读取的矩阵。

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. 我似乎认为这很不错,以防万一这是一个问题。

事实证明,我的draw函数正在递归循环中通过引用传递一些数据,并对其进行更新导致了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM