【发布时间】:2017-09-30 02:29:46
【问题描述】:
我在 android 的 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 是结果:
我认为我的骨骼重量和 id 是正确的,因为我得到了这个: i.stack.imgur.com/fcTro.png 当我翻译其中一个转换矩阵时
我正在尝试遵循 ogldev.org/www/tutorial38/tutorial38.html 教程
现在我不知道在哪里查找错误
是读取矩阵有问题还是计算有问题?
【问题讨论】:
标签: java android matrix opengl-es assimp