سؤال

I writing an fbx converter for our small game engine. I stuck with rendering the Model using the animation. The matrix for each timestamp look allright and when I render just the bones it also looks like the the orginal animation. I made some snapshot to show my problem. I just can't figure out whats wrong. Maybe someone is able to give me a hint :)

The file I am using for testing is humanoid.fbx from the FBX-SDK.

The Shader should be ok:

VS_OUT output = (VS_OUT)0;

float4x4 skinTransform = 0;
skinTransform += MatrixPallette[input.BoneIndices.x] * input.Weights.x;
skinTransform += MatrixPallette[input.BoneIndices.y] * input.Weights.y;
skinTransform += MatrixPallette[input.BoneIndices.z] * input.Weights.z;
skinTransform += MatrixPallette[input.BoneIndices.w] * input.Weights.w;
//skinTransform = mul(BindShape, skinTransform);

//Transform Position
float4 worldPosition = mul(input.Position, skinTransform);
float4 viewPosition = mul(worldPosition, matView);
output.Position = mul(viewPosition, matProj);

And here is the pic. ( right -> Orginal ) http://www.pic-upload.de/view-13949399/Unbenannt.png.html

هل كانت مفيدة؟

المحلول

Instead of calculating "skin transform" for a vertex, I'd advise to calculate transformed vertex using provided transform, then get combined poisition using weights. Interpolating two matrices really isn't a very good idea.

float4 worldPosition = 0;
worldPosition += mul(input.Position, MatrixPallette[input.boneIndicies.x]) * input.Weights.x;
worldPosition += mul(input.Position, MatrixPallette[input.boneIndicies.y]) * input.Weights.y;
worldPosition += mul(input.Position, MatrixPallette[input.boneIndicies.z]) * input.Weights.z;
worldPosition += mul(input.Position, MatrixPallette[input.boneIndicies.w]) * input.Weights.w;

However, when you see such deformed object, normally it means that you forgot to multiply matrix pallette by "inverse bone transform". Inverse bone transform is transformation matrix bone had in "skin parade" pose (i.e. original pose in which object has been rigged). To calculate proper position of skinned object, in matrix pallette you should store combined transform = inverse(skinParadeTransform)*currentTransform. Current transform is transformation bone has in current animation hierarchy, and skinParadeTransform is original bone transofmration in "skin parade" mode. inverse is matrix inversion (yep, you'll have to do it).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top