This project is read-only.

World Translation Getting Lost

Jun 25, 2008 at 9:44 PM
Hi again!

I believe you've got a bug in your vertex program for SkinnedModelEffect.fx. Currently, no matter what I set the effect's world translation to, the model does not translate (ie - "move"). Is this because multiplying a 4x3 matSmoothSkin by the 4x4 World loses the World's translation data elements (I think they're [41, 42, 43])?

This all used to work fine.

To reproduce, just set effect.World to Matrix.Identity with a translation of something other than [0,0,0] - you'll notice that the model just doesn't translate no matter what you put in.

Thank you kindly for looking into this issue!
Jun 25, 2008 at 10:54 PM
Edited Jun 25, 2008 at 11:13 PM
Hey hey, I've got a fix for the bug!

It looks like my previous diagnosis was correct - your multiplie of 4x3 and a 4x4 loses the latter's translation value. Here's one of the vertex programs after I fixed it  -

v2f animatedModelVS_Light(a2v IN)
    v2f OUT;
    // Calculate the final bone transformation matrix
    float4x3 matSmoothSkin = 0;
    matSmoothSkin += matBones[IN.boneIndex.x] * IN.boneWeight.x;
    matSmoothSkin += matBones[IN.boneIndex.y] * IN.boneWeight.y;
    matSmoothSkin += matBones[IN.boneIndex.z] * IN.boneWeight.z;
    matSmoothSkin += matBones[IN.boneIndex.w] * IN.boneWeight.w;
    // World transformation
    float4x4 worldSkin;
    worldSkin[0] = float4(matSmoothSkin[0], 0);
    worldSkin[1] = float4(matSmoothSkin[1], 0);
    worldSkin[2] = float4(matSmoothSkin[2], 0);
    worldSkin[3] = float4(matSmoothSkin[3], 1);
    worldSkin = mul(worldSkin, matW);
    // Transform vertex and normal
    float3 position = mul(IN.position, worldSkin);
    OUT.position = position;
    OUT.hposition = mul(float4(position, 1.0f), matVP);
    float3 normal = mul(IN.normal, (float3x3)worldSkin);
    OUT.normal = normal;
    float3 eyeVec = matVI[3].xyz - position;
    OUT.eyeVec = eyeVec;
    OUT.uv0 = IN.uv0;
    return OUT;

Jun 25, 2008 at 11:29 PM
Additionally, I have directional light shadows working with this component, so I can get that code to you if you like :)
Jun 26, 2008 at 1:18 AM

It is indeed a bug! You was very fast providing a solution for it before I could read this post! =D  Thanks a lot, I will correct it and add a credit for you on this item.
Thanks again.

PS: The new version of the library will probably be out on this Friday and I believe it fixes a lot of problems.
Jun 26, 2008 at 2:58 AM
>> Additionally, I have directional light shadows working with this component, so I can get that code to you if you like :)
Sounds great. I want to add a User Content section in the XNAnimation homepage at CodePlex, it would be great to add this shader there.

Can you send me an e-mail (you can find it in the profile page)? So we can talk more outside this forum. Thanks!