   Troubles with skinned mesh
  I try to write skeletal animation but got a problem model that i use animated incorrect. It's look like bones rotate in oposite direction from what they must,but the same model work fine with DirecX SDK sample. So i think it's my mistake but i can't find it. Please if any can help there is code where i think bug:void cSkeletalAnimationSet::updateAnimation( ){  if( m_fPlayTime>=m_fAnimationLength )  {    set_time ( fmod(m_fPlayTime, m_fAnimationLength ) );  }  float fSpeed = m_fPlayTime / m_fAnimationLength;  float first = m_anim->m_time[ m_idx_first ];  float last = m_anim->m_time[ m_idx_last ];  float time = first + ( last - first)* fSpeed;  for( ; m_idx_curr < m_idx_last; m_idx_curr++)  {    if( time <= m_anim->m_time[ m_idx_curr] )    { break;    }    m_idx_prev = m_idx_curr;  }  float k = (time - m_anim->m_time[ m_idx_prev ])/(m_anim->m_time[ m_idx_curr ] - m_anim->m_time[ m_idx_prev ]);    for( vector<sAnimationKeyPlay>::iterator i=m_keys.begin(); i!=m_keys.end(); i++)  {    if( (*i).m_frame )    {   (*i).m_frame->m_matrix = cMatrix4x4::Identity; (*i).m_frame->m_bUpdated = true; if( !i->m_rotation->empty() ) {   const cVector4d & v1 = (*(i->m_rotation))[ m_idx_prev ];   const cVector4d & v2 = (*(i->m_rotation))[ m_idx_curr ];   (*i).m_frame->m_matrix.RotateQuat( v1.lerp( v2, k ) ); } if( !i->m_scale->empty() ) {   const cVector3d & v1 = (*(i->m_scale))[ m_idx_prev ];   const cVector3d & v2 = (*(i->m_scale))[ m_idx_curr ];   (*i).m_frame->m_matrix.AddScale( v1 + (v2 - v1) * k ); } if( !i->m_translate->empty() ) {   const cVector3d & v1 = (*(i->m_translate))[ m_idx_prev ];   const cVector3d & v2 = (*(i->m_translate))[ m_idx_curr ];   (*i).m_frame->m_matrix *= cMatrix4x4( v1 + (v2 - v1) * k  ); }}  }}void cSkeletalAnimator::UpdateFrames ( sFrame * pFrame, const cMatrix4x4 & parent, bool bForce ){  if( bForce || pFrame->m_bUpdated )  {    pFrame->m_combined_matrix = pFrame->m_matrix * parent;    pFrame->m_bUpdated = true;    bForce = true;  }  for( vector<sFrame>::iterator i=pFrame->m_frames.begin(); i!=pFrame->m_frames.end(); i++)  {    UpdateFrames( &(*i), pFrame->m_combined_matrix, bForce );  }}void cSkeletalAnimator::update( float dt ){  //dt = 0;  if( !m_played_anim.empty() )  { ResetFrames( m_frames );    vector<cSkeletalAnimationSet*>::iterator i = m_played_anim.begin();    float fWeightMax = 0;    bool bPlaying = false;    for(;i!=m_played_anim.end(); i++)    { if( *i ) {   (*i)->updateState( dt );   fWeightMax += (*i)->max_weight() ;   bPlaying = true; }    }    m_bPlaying = bPlaying;    if( bPlaying )    { for(i = m_played_anim.begin();i!=m_played_anim.end(); i++) {   if( (*i) )   {(*i)->set_animation_weight( (*i)->weight() / fWeightMax );(*i)->updateAnimation( );   } } for( vector<sFrame>::iterator it=m_frames.begin(); it!=m_frames.end(); it++) {   UpdateFrames( &(*it), cMatrix4x4::Identity, true ); } {   for( size_t i = 0; i<m_combined.size(); i++)   {if( m_combined && *m_combined_transform ){  const cMatrix4x4 & m = m_pSkeleton->m_bones.m_bone_offset;  cMatrix4x4 & m1 = (*m_combined);  m_final = m1 * m ;}   } } if( !m_pOwner->shader() ) {   BYTE * ptr = (BYTE*) m_pOwner->m_vertices->lock(0, 0, false);   BYTE * ptr1 = (BYTE*) &m_pOwner->model()->vertieces()[0];for( vector< vector< sBoneTransform > >::iterator i= m_bones.begin(); i!=m_bones.end(); i++)   {cVector3d * v_dst = (cVector3d*) ptr;cVector3d * v_src = (cVector3d*) ptr1;cVector3d org = *v_dst;if( !(*i).empty() ){  *v_dst = cVector3d(0,0,0);  for( vector<sBoneTransform>::iterator it=(*i).begin(); it!= (*i).end(); it++)  {    *v_dst += (*v_src * (*it->m_mat) ) * it->m_weight;  }}ptr += m_pOwner->m_vertices->stride();ptr1 += m_pOwner->m_vertices->stride();   }   m_pOwner->m_vertices->unlock(); }    }  }}
  Could you post some screen shots of the same point in time of the animation, from both the D3D example and your application so that we can see the difference?   ;  There what i have in my application:There what show mview.exe:(If you say how i can upload file, i can send here x file );  I think problem in this place:for( vector< vector< sBoneTransform > >::iterator i= m_bones.begin(); i!=m_bones.end(); i++)   {cVector3d * v_dst = (cVector3d*) ptr;cVector3d * v_src = (cVector3d*) ptr1;cVector3d org = *v_dst;if( !(*i).empty() ){  *v_dst = cVector3d(0,0,0);  for( vector<sBoneTransform>::iterator it=(*i).begin(); it!= (*i).end(); it++)  {    *v_dst += (*v_src * (*it->m_mat) ) * it->m_weight;  }}ptr += m_pOwner->m_vertices->stride();ptr1 += m_pOwner->m_vertices->stride();   }May be i incorrect transofrm vertex there function :cVector3d operator * ( const cVector3d & v, const cMatrix4x4 & mat ){#ifdef USE_DIRECTX_EXT    cVector4d res;D3DXVec3Transform(res, v, mat);    return res.v;#else    cVector3d res;res.x = mat._11*v.x + mat._21*v.y + mat._31*v.z + mat._41;res.y = mat._12*v.x + mat._22*v.y + mat._32*v.z + mat._42;res.z = mat._13*v.x + mat._23*v.y + mat._33*v.z + mat._43;return res;#endif};  Well, thanks everyone, problem was in exporter not in player. ;  There another problem, with shader.void DefaultRenderVS( float4 vPos : POSITION,  float4 vWeight: BLENDWEIGHT,  byte4  vMatrices: BLENDINDICES,    float2 vTex0 : TEXCOORD0,  out float4 oDiffuse: COLOR0,    out float4 oPos : POSITION,    out float2 oTex0 : TEXCOORD0 ){float4 pos;int indices[4] = (int[4]) vMatrices ;if( indices[0] == 255 ){pos = vPos;}else{pos = float4(0,0,0,0);for( int i =0;i<4; i++ ){pos += mul( vPos, g_Bones[ indices ] )*vWeight<span style="font-weight:bold;">;<br>}<br>}<br><br>    oPos = mul( pos, g_mWorldViewProj );<br><br>    oTex0 = vTex0;<br>    oDiffuse = g_cColor;<br>}<br><br><br></pre></div><!–ENDSCRIPT–><br><br>this code don't working . I use follow vertex format<br><br><!–STARTSCRIPT–><!–source lang="cpp"–><div class="source"><pre><br><span class="cpp-keyword">struct</span> sVertex<br>{<br>   <span class="cpp-keyword">float</span> xyz[<span class="cpp-number">3</span>];<br>   <span class="cpp-keyword">float</span> weights[<span class="cpp-number">4</span>];<br>   byte  indices[<span class="cpp-number">4</span>];<br>   <span class="cpp-keyword">float</span> uv[<span class="cpp-number">2</span>];<br>};<br><br><br></pre></div><!–ENDSCRIPT–> <br><br><!–EDIT–><span class=editedby><!–/EDIT–>[Edited by - Kostikov Stas on June 28, 2009 9:43:14 PM]<!–EDIT–></span><!–/EDIT–>