• Advertisement
Sign in to follow this  

3DS Max export - bones animation problem

This topic is 2433 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

Hi everyone!
I'm building a Direct3D based game engine.
I use my own file format for static / skinned meshes.
The exporter is based on an article from The Game Engine Architecture book and The NVidia nv-exporter sample (So it is the shader code).

sad.gif My problem is that the bones I export do not "influence" properly the vertices, this way I get some strange skin deformations.

My approach was:
(I) In the exporter
  • Export initial bone position and orientation (quaternion) in world space (flip z with y)
  • For every frame (sample) - export bone position and orientation (quaternion) also in world space (flip z with y)(II) In the engine
    • Load initial bone position and orientation
      - D3DXMatrixRotationQuaternion(&mQ, &Q);
      - D3DXMatrixTranslate(&mT, &T);
      - D3DXMatrixMultiply(&matBone, &mQ, &mT);
      - D3DXMatrixInverse(&matInvBose, NULL, &matBone);
    • Update the bone's matrice based on the key and send to shader
      - The same as above except I don't invert matInvBone
      - Set the shader matrice as matBone * matInvBindPose
      This code decomposes the transform matrices and swaps Z with Y:

      static void GetIGameTransform(Matrix3 m, geo::VERT3 &T, geo::VERT4 &Q)
      AffineParts ap;
      decomp_affine(m, &ap);

      T.set(ap.t.x, ap.t.z, ap.t.y);
      Q.set(ap.q.x, ap.q.z, ap.q.y, ap.q.w);

      This code gets the initial bone transform matrices:

      // get initial bone matrix
      for (int b = 0; b < boneIDs.Count(); b++)
      // Get parent

      // Get its transform matrix
      GMatrix mat;
      pSkin->GetInitBoneTM(pCurrent, mat);

      geo::VERT4 Q;
      geo::VERT3 T;
      GetIGameTransform(mat.ExtractMatrix3(), T, Q);

      SkeletonJoint* pJoint = new SkeletonJoint(name, parent, T, Q);

      The following code exports bones animation:

      geo::VERT3 T;
      geo::VERT4 Q;

      IGameNode * node = boneIDs[iNode]->pNode; // pSkin->GetIGameBone(vertex, bone);

      GetIGameTransform(node->GetWorldTM(t).ExtractMatrix3(), T, Q);


      And the update code:

      Skeleton* pSkeleton = m_pClip->GetSkeleton();
      for (unsigned int i = 0; i < pSkeleton->m_joints.Count(); i++)
      SkeletonJoint* pJoint = pSkeleton->m_joints;
      AnimationPose* pAnimation = m_pClip->m_samples[m_iKey];
      SQT* pSQT = pAnimation->m_jointPoses;
      #ifndef EXPORTER
      D3DXMATRIX matTmp, matT, matQ;
      D3DXMatrixTranslation(&matT, pSQT->T.x, pSQT->T.y, pSQT->T.z);
      D3DXMatrixRotationQuaternion(&matQ, &pSQT->Q);

      matTmp = matQ * matT;
      m_globalPoses = matTmp * pJoint->m_InvBindPose;


      The results:
      bf1f6785.jpg smile.gif , when the initial bone matrice == animation matrice (M * M[sup]-1[/sup]=matrix identity)

      8c2df19e.jpg sad.gif

      e7aaca3f.jpg unsure.gif

      827fe470.jpg blink.gif

      Thank you!

Share this post

Link to post
Share on other sites
Is Maya || XSI SDKs more intuitive or at least do they have some better exporter samples for DirectX / Skinned meshes?

Share this post

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

  • Advertisement