Exemple #1
0
void Animation::SetFrameOverlay( F32 frame, AnimKey &state, F32 controlFrame) const
{
  controlFrame;

  U32 i;
#if 0
  Quaternion conq;
  conq.ClearData();
  for (i = 1; i < keys.count; i++)
  {
    AnimKey &lastKey = keys[i - 1];
    AnimKey &thisKey = keys[i];

    if (controlFrame <= thisKey.frame)
    {
      // determine the current fraction to this cycle
      F32 dk = thisKey.frame - lastKey.frame;
      ASSERT( dk > 0);
      F32 dfdk  = (controlFrame - lastKey.frame) / dk;

      if (lastKey.type & animQUATERNION)
      {
        // do a parametric interpolation of the quaternion using dfdk
        conq = (thisKey.quaternion - lastKey.quaternion) * dfdk + lastKey.quaternion;
      }
      break;
    }
  }
#endif
//         0;  4; 0.923880, 0.382683, 0.0, 0.0;;,
//         0;  4; 0.898028, 0.439939, 0.0, 0.0;;,
//         0;  4; 0.868631, 0.495459, 0.0, 0.0;;,
//         0;  4; 0.770513, 0.637424, 0.0, 0.0;;,

  for (i = 1; i < keys.count; i++)
  {
    AnimKey &lastKey = keys[i - 1];
    AnimKey &thisKey = keys[i];

    if (frame <= thisKey.frame)
    {
//      LOG_DIAG( ("%f ; %f ; %f", lastKey.frame, frame, thisKey.frame) );

      ASSERT( lastKey.frame < thisKey.frame);

      // determine the current fraction to this cycle
      F32 dk = thisKey.frame - lastKey.frame;
      ASSERT( dk > 0);
      F32 dfdk  = (frame - lastKey.frame) / dk;

      if (lastKey.type & animQUATERNION)
      {
        // do a parametric interpolation of the quaternion using dfdk
        Quaternion q = (thisKey.quaternion - lastKey.quaternion) * dfdk + lastKey.quaternion;

    #if 1
        if (q.Dot( q) <= 0)
        {
          LOG_WARN( ("Quat::Set q.Dot(q) <= 0: %f %f %f %f", q.s, q.v.x, q.v.y, q.v.z) );
          LOG_WARN( ("lastKey.quat: %f %f %f %f", lastKey.quaternion.s, lastKey.quaternion.v.x, lastKey.quaternion.v.y, lastKey.quaternion.v.z) );
          LOG_WARN( ("thisKey.quat: %f %f %f %f", thisKey.quaternion.s, thisKey.quaternion.v.x, thisKey.quaternion.v.y, thisKey.quaternion.v.z) );
          LOG_WARN( ("dfdk: %f; lastKey.frame %f; thisKey.frame; frame", dfdk, lastKey.frame, thisKey.frame, frame) );

          statQuatError = TRUE;
        }
    #else
        ASSERT( q.Dot( q) > 0);
    #endif

        // blend in the quat
        //
//        q -= conq;
//        q = state.quaternion * q;
//        q.Set( PI * 0.11f, Matrix::I.right);
//        q = state.quaternion * q;
        state.Set( q );
      }
      break;
    }
  }
}