Animation Retargeting

Started by
2 comments, last by Ruggostein 10 years, 2 months ago

I am trying to code animation retargeting.

As you can see in the image below, I have 2 skeletons.

One is a human running, the other a cartoon frog.

My objective is to allow the frog to run using the animation from the other model.

Currently I tried detecting bones with same name in the two skeletons, and just copy bone translations&rotations from the running skeleton to the frog skeleton.

This is not enough though, the frog moves, but the animation is incorrect

Both skeletons have different number of bones. I would like this code to support different number of bones, since it would make porting animations from one model to another way easier.

Anyone has experience on this?

o4c6.png

Advertisement

Animation retargeting is a popular research field that has progressed far beyond "bones with the same name". Review scientific literature to gather a lot of good ideas to try.

Omae Wa Mou Shindeiru

Lorenzo is right, but if you don't have the time or energy to read the latest research papers (which use a highly stylized math form), one thing you could try is affinitize the guest skeleton's bones to the host skeleton by transforming both skeletons into the same local space and then connecting guest bones to nearest neighbor skeleton bones using something like:

[Source]

for (DWORD i = 0; i < pSkin->m_numOffsetMatrices; i++)

{

D3DXVECTOR3 SkinPos( 0.0f, 0.0f, 0.0f );

D3DXMATRIX boneOffsetToRoot;

D3DXMatrixInverse( &boneOffsetToRoot, NULL, &pSkin->m_boneOffsetTransforms[ i ] );

D3DXVec3TransformCoord( &SkinPos, &SkinPos, &boneOffsetToRoot );

float bestDist = INFINITY;

for (DWORD j = 0; j < pSkeleton->m_numFrames; j++)

{

D3DXVECTOR3 BindPos( 0.0f, 0.0f, 0.0f );

D3DXVec3TransformCoord(

&BindPos,

&BindPos,

&pSkeleton->m_matrixFrames[ j ].

m_skeletalRootSpace );

float dist = D3DXVec3Length( &D3DXVECTOR3( SkinPos - BindPos ) );

if (dist < bestDist)

{

bestDist = dist;

pSkin->m_boneIndex[ i ] = j;

}

}

}

[/Source]

Thanks Steve, indeed I cannot read the papers, I'm not very good at math, besides trignometry.

In my experiments I was able to almost get it working, the only problem was the bones got stretched out to the original skeleton dimensions.

I'll try your approach :)

This topic is closed to new replies.

Advertisement