Original Post
Hello,
I'm trying to build a manual parser for .X files, without using the DirectX specific functions for loading, just to learn by practicing how skinning and animation works. I am already able to present the mesh on the screen, and I'm pretty sure that all of the data in the file is being loaded correctly (including animation data).
I'm now trying to reproduce the animation set contained in a sample .x file, but I can't seem to get it right. Each bone saves its matrix, children bones, the vertices it affects and their weight. Then, before drawing a mesh I update it and try to perform the transformations given by the bones. To do so, for each bone, I get the bone matrix, multiply it by the keyframe matrix (a matrix that is interpolated from two consecutive keyframes) and transform each vertex affected by the bone by the resulting matrix * the weight for that vertex.
Something like:
However, doing something like this simply destroys the mesh and the animation is nothing like what it should be. I'm probably missing something very evident here, but I can't seem to find what...
Thanks in advance...
I'm trying to build a manual parser for .X files, without using the DirectX specific functions for loading, just to learn by practicing how skinning and animation works. I am already able to present the mesh on the screen, and I'm pretty sure that all of the data in the file is being loaded correctly (including animation data).
I'm now trying to reproduce the animation set contained in a sample .x file, but I can't seem to get it right. Each bone saves its matrix, children bones, the vertices it affects and their weight. Then, before drawing a mesh I update it and try to perform the transformations given by the bones. To do so, for each bone, I get the bone matrix, multiply it by the keyframe matrix (a matrix that is interpolated from two consecutive keyframes) and transform each vertex affected by the bone by the resulting matrix * the weight for that vertex.
Something like:
foreach (Bone bone in bones) matrix boneMatrix = bone->matrix; matrix animMatrix = animation->getCurrentMatrix(); //I'm hoping that this gives me the bone position in a given moment matrix result = boneMatrix * animMatrix; foreach (Vertex v in vertices) matrix weightedMatrix = result * bone->getWeight(v); v = weightedMatrix * v; endendHowever, doing something like this simply destroys the mesh and the animation is nothing like what it should be. I'm probably missing something very evident here, but I can't seem to find what...
Thanks in advance...