I am having trouble implementing bone animation in my OpenGLES app in android. For the model, i used assimp to convert a FBX file exported with 3ds max and converted it into a text file. This file loads the bone data (vertices, weights, offset matrices, heirarchy etc.)
I can get the bind pose if i send the bone matrices as identity matrices:
Then I store the children of each node and multiply the node transformation matrix by their parents recursively using this code
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);
}
This blob is the result:
I think my bone weights and ids are correct because I get this: i.stack.imgur.com/fcTro.png when i translate one of the transformation matrices
I was trying to follow ogldev.org/www/tutorial38/tutorial38.html tutorial
and now I don't know where to look for errors
Is there a problem in reading the matrices or is it the calculation?
I solved it after trying many combinations of matrix multiplications
I don't completely understand if it was changing it to Collada that helped or not but google search suggests that people had problems with the FBX format.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.