我在安卓的OpenGLES应用程序中实现骨骼动画时遇到了麻烦。对于模型,我使用assimp来转换一个用3ds max导出的FBX文件,并将其转换为文本文件。此文件加载骨骼数据(顶点、权重、偏移矩阵、层次结构等)。
如果我将骨骼矩阵作为单位矩阵发送,则可以获得绑定姿势:
然后,我存储每个节点的子节点,并使用下面的代码递归地将节点转换矩阵乘以它们的父节点
public void setBoneHeirarchy()
{
for (Bone b : mRootBones)
{
setBoneTransformations(b, mRootTransform);//From assimp aiScene->mRootNode->mTransformation
}
}
private void setBoneTransformations(Bone b, Matrix4 parent)
{
Matrix4 globalTransform = new Matrix4();
globalTransform.multMatrix(parent); //[this].multMatrix([arg]) multiplies the matrix like [this] = [this] * [arg]
globalTransform.multMatrix(b.nodeTransformation); //loaded from assimp as aiNode->mTransformation
b.transformation.loadIdentity(); //the final transformation to return
b.transformation.multMatrix(mRootTransformInverse); //Inverse of mRootNode->mTransformation
b.transformation.multMatrix(globalTransform); //calculated above
b.transformation.multMatrix(b.offsetMatrix); //read from text file (converted with assimp)
for (Bone child: b.children)
setBoneTransformations(child, globalTransform);
}
这个blob是这样的结果:
我认为我的骨骼权重和i是正确的,因为当我转换其中一个转换矩阵时,得到的结果是: i.stack.imgur.com/fcTro.png
我正在尝试使用ogldev.org/www/tutorial38/tutorial38.html教程
现在我不知道该去哪里找错误
是读取矩阵有问题还是计算有问题?
发布于 2017-05-10 10:02:56
在尝试了许多矩阵乘法的组合之后,我解决了这个问题
首先,我从FBX切换到Collada文件格式,然后转换成我自己的矩阵后,从assimp加载它的矩阵(我正在转置它,同时加载到乘法的shader)
我不完全明白是不是把它改成了Collada,这是否有帮助,但谷歌搜索显示,人们对FBX格式有问题。
https://stackoverflow.com/questions/43740035
复制相似问题