I'm working on a skinned mesh demo.

And I have successfully export my own mesh from 3ds max.

But in my meshviewer program,only first frame is correct.

Like this,the right image is the correct animation, the cube in left image means the bone

I have got all bone matrix saved in mBoneTransforms[m][n].The m indicate m-th bone, the n means the n-th frame, each data in mBoneTransforms is a matrix

following is my code:

The drawCube(float4x4 world) method is used to drawing bones.And this completely represent the animation correctly.

So my bone animation is correctly, skinned animation is wrong

static int frameCount = 0; for (int i = 0; i < mYHMMesh.boneInfo.BoneCount; i++) { XMFLOAT4X4 boneInv = floatToXMFLOAT(mBoneTransforms[i][0]); XMStoreFloat4x4(&boneInv, XMMatrixInverse(NULL, XMLoadFloat4x4(&boneInv))); //boneInv is what I think offset matrix, is it wrong? m_constantBufferData.boneTransform[i] = mul(mBoneTransforms[i][frameCount % 120], XMFLOATTofloat4x4(boneInv)); //drawBone(mBoneTransforms[i][frameCount % 120); } frameCount++;

PixelShaderInput SimpleVertexShader(VertexShaderInput input) { PixelShaderInput vertexShaderOutput; float weights[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; weights[0] = input.Weights.x; weights[1] = input.Weights.y; weights[2] = input.Weights.z; weights[3] = 1.0f - weights[0] - weights[1] - weights[2]; float4 pos = float4(input.pos, 1.0f); float4 norm = float4(normalize(input.norm), 0.0f); for (int i = 0; i < 4; ++i) { pos += weights[i] * mul(pos, gBoneTransform[input.BoneIndices[i]]); norm += weights[i] * mul(norm, gBoneTransform[input.BoneIndices[i]]); } pos = mul(pos, model); pos = mul(pos, view); pos = mul(pos, projection); norm = mul(norm, model); vertexShaderOutput.pos = pos; vertexShaderOutput.tex = input.tex; vertexShaderOutput.norm = normalize(norm.xyz); return vertexShaderOutput; }

**Edited by kgs, 12 November 2013 - 09:49 PM.**