Stratos: Punto de Encuentro de Desarrolladores

¡Bienvenido a Stratos!

Acceder

Foros





Direct3d Vs Characterfx

Iniciado por boubou, 07 de Enero de 2004, 05:20:32 PM

« anterior - próximo »

boubou

 bueno, hora el modelo se carga pero no anima.

este es el codigo

void CAnimationNode::SetTime( DWORD dwtime )
{
UINT ikey;
UINT ikey1;
UINT ikey2;
D3DXMATRIX resultmatrix;
D3DXMATRIX tempmatrix;
float flerpvalue;
D3DXVECTOR3 scalevector;
D3DXVECTOR3 positionvector;
D3DXQUATERNION quat;
BOOL banimate = false;
DWORD dwtime1, dwtime2;

// if no target frame is found, then this object doesn't hold animation keys
if( pTargetFrame )
{
 // check the type of the key
 if( aMatrixKey )
 {
  dwtime %= aMatrixKey[dwMatrixKeyCount-1].dwTime;

  // get the two keys between which the time is currently in
  for( ikey = 0; ikey < dwMatrixKeyCount; ikey++ )
   if( aMatrixKey[ikey].dwTime > dwtime )
   {
    ikey2 = ikey;
    if( ikey > 0 )
     ikey1 = ikey - 1;
    else  // when ikey == 0, then ikey1 == 0
     ikey1 = ikey;
    break;
   }
  dwtime1 = (float)aMatrixKey[ikey1].dwTime;
  dwtime2 = (float)aMatrixKey[ikey2].dwTime;





  // get the lerp value from the time
  if( (dwtime2-dwtime1) ==0 )
   flerpvalue = 0;
  else
   flerpvalue = float(dwtime-dwtime1) / float(dwtime2-dwtime1);

  // we cannot apply a lerp function on two matrices, so just get the
  // nearest one
  if (flerpvalue > 0.5)
   ikey = ikey2;
  else
   ikey = ikey1;

  // apply the transformation
  pTargetFrame->SetTransformationMatrix( &aMatrixKey[ikey].Mat );
 }
 else
 {
  // initialize a matrix to hold the result of the transformation
  D3DXMatrixIdentity(&resultmatrix);

  // check the scale key
  if( aScaleKey )
  {
   ikey1 = ikey2 = 0;
   dwtime %= aScaleKey[dwScaleKeyCount-1].dwTime;

   // get the two keys between which the time is currently in
   for( ikey = 0; ikey < dwScaleKeyCount; ikey++ )
    if( aScaleKey[ikey].dwTime > dwtime )
    {
     ikey2 = ikey;

     if( ikey > 0 )
      ikey1 = ikey - 1;
     else  // when ikey == 0, then dwp2 == 0
      ikey1 = ikey;
     break;
    }
   dwtime1 = aScaleKey[ikey1].dwTime;
   dwtime2 = aScaleKey[ikey2].dwTime;

   // get the lerp value
   if( (dwtime2-dwtime1) == 0 )
    flerpvalue = 0;
   else
    flerpvalue =  float(dwtime-dwtime1)/float(dwtime2-dwtime1);

   // apply the lerp function on the scale vector
   D3DXVec3Lerp( &scalevector, &aScaleKey[ikey1].Scale,
    &aScaleKey[ikey2].Scale, flerpvalue );

   // create the matrix
   D3DXMatrixScaling( &tempmatrix, scalevector.x, scalevector.y, scalevector.z );
   D3DXMatrixMultiply( &resultmatrix, &resultmatrix, &tempmatrix );

   banimate = true;
  }

  //check rot keys
  if (aRotationKey )
  {
   ikey1 = ikey2 = 0;
   dwtime %= aRotationKey[dwRotationKeyCount-1].dwTime;

   // get the two keys surrounding the current time value
   for( ikey = 0; ikey < dwRotationKeyCount; ikey++ )
    if( aRotationKey[ikey].dwTime > dwtime )
    {
     ikey2 = ikey;
     if( ikey > 0 )
      ikey1 = ikey - 1;
     else  // when ikey == 0, then dwp2 == 0
      ikey1 = ikey;
     break;
    }
   dwtime1 = aRotationKey[ikey1].dwTime;
   dwtime2 = aRotationKey[ikey2].dwTime;

   // get the lerp value
   if( (dwtime2-dwtime1) == 0 )
    flerpvalue = 0;
   else
    flerpvalue = float(dwtime-dwtime1)/float(dwtime2-dwtime1);

   //apply spherical lerp function
   D3DXQUATERNION q1,q2;
   q1.x = -aRotationKey[ikey1].Rotation.x;
   q1.y = -aRotationKey[ikey1].Rotation.y;
   q1.z = -aRotationKey[ikey1].Rotation.z;
   q1.w = aRotationKey[ikey1].Rotation.w;

   q2.x = -aRotationKey[ikey2].Rotation.x;
   q2.y = -aRotationKey[ikey2].Rotation.y;
   q2.z = -aRotationKey[ikey2].Rotation.z;
   q2.w = aRotationKey[ikey2].Rotation.w;

   D3DXQuaternionSlerp( &quat, &q1, &q2, flerpvalue );

   // create the matrix
   D3DXMatrixRotationQuaternion( &tempmatrix, &quat );
   D3DXMatrixMultiply( &resultmatrix, &resultmatrix, &tempmatrix );
   banimate = true;
  }

  // check for position keys
  if( aPositionKey )
  {
   ikey1 = ikey2 = 0;
   dwtime %= aPositionKey[dwPositionKeyCount-1].dwTime;

   // get the two keys surrounding the time value
   for( ikey = 0; ikey < dwPositionKeyCount; ikey++ )
    if( aPositionKey[ikey].dwTime > dwtime )
    {
     ikey2 = ikey1;
     if( ikey > 0 )
      ikey1 = ikey - 1;
     else  // when ikey == 0, then dwp2 == 0
      ikey1 = ikey;
     break;
    }
   dwtime1 = aPositionKey[ikey1].dwTime;
   dwtime2 = aPositionKey[ikey2].dwTime;

   // get the lerp value
   if( dwtime2-dwtime1 == 0 )
    flerpvalue = 0;
   else
    flerpvalue = float(dwtime-dwtime1)/float(dwtime2-dwtime1);

   // apply the lerp function
   D3DXVec3Lerp( (D3DXVECTOR3*)&positionvector, &aPositionKey[ikey1].Pos,
    &aPositionKey[ikey2].Pos, flerpvalue );

   // prepare the matrix
   D3DXMatrixTranslation( &tempmatrix, positionvector.x, positionvector.y, positionvector.z );
   D3DXMatrixMultiply( &resultmatrix, &resultmatrix, &tempmatrix );
   banimate = true;
  }
  else
  {
   // if no position key is found, use the original position of the frame
   D3DXMATRIX * poriginalmatrix = pTargetFrame->GetOriginalMatrix();
   D3DXMatrixTranslation( &tempmatrix, poriginalmatrix->_41,
    poriginalmatrix->_42, poriginalmatrix->_43 );
   D3DXMatrixMultiply( &resultmatrix, &resultmatrix, &tempmatrix );
  }

  if (banimate)
   pTargetFrame->SetTransformationMatrix( &resultmatrix );
 }
}


}
onstruo Bou... Ha vuelto Mwhahahahahahahahahahahahahah!

Es la unica esperanza de los trolls tras el envio al "infienno
" de WhiteBlaizer y X-Alien






Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.