Advertisement Jump to content
Sign in to follow this  
Relfos

Animation Retargeting

This topic is 1812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!