Hello!
With the help of the forum I managed to fix my skinning shader problem. Now I have another problem.
I am using ASSIMP and DirectX9. I implemented the skeletal animation according to this tutorial: http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html
If I use the default pose(T-pose) the model is shown just how it should be(see attached screenshot model_tpose.png).
As soon as I use the animations from animation frame0 it goes all weird(see attached screenshot model_frame0.png).
I think that something with calculating the NodeTransformation is wrong.
Here is the code of the update function called each frame(the Matrix class is from SimpleMath.h, an oop wrapper for DirectXMath.h):
void SkinnedMesh::UpdateNode(aiAnimation *animation,float animationTime, aiNode *node, Matrix parentTransform)
{
const char *nodeName = node->mName.C_Str();
const aiNodeAnim *nodeAnim = FindNodeAnim(animation, nodeName);
Matrix NodeTransformation(*(Matrix *)&node->mTransformation);
//if I comment the whole if-section then it works, because the bones are then in default pose
if(nodeAnim != NULL)
{
//somewhere here should be the problem
aiVector3D Scaling = nodeAnim->mScalingKeys[0].mValue;
Matrix ScalingM = Matrix::CreateScale(Scaling.x,Scaling.y,Scaling.z);
aiQuaternion q = nodeAnim->mRotationKeys[0].mValue;
Matrix RotationM = Matrix::CreateFromQuaternion(Quaternion(q.x,q.y,q.z,q.w));;
aiVector3D Translation = nodeAnim->mPositionKeys[0].mValue;
Matrix TranslationM = Matrix::CreateTranslation(Translation.x,Translation.y,Translation.z);
NodeTransformation = TranslationM * RotationM * ScalingM;
}
Matrix finalTransform = parentTransform * NodeTransformation;
if(_boneMap.find(nodeName) != _boneMap.end())
{
int boneID = _boneMap[nodeName];
_finalBoneTransformations[boneID] = _globalInverseMatrix * finalTransform * this->_bones[boneID].offsetMatrix;
}
for(unsigned int i = 0;i<node->mNumChildren;i++)
{
UpdateNode(animation,animationTime,node->mChildren[i],finalTransform);
}
}
I hope someone can help me and tell me why it does that.
Btw: the problem is likely not right-handed/left-handed matrices problem, since ASSIMP and SimpleMath both use right-handed matrices.
Thanks in advance!