os acordais de que ya me fuincionba... pos no ha resultado ser asi :(
no se que coño le pasa que no carga el modelo en mi engine (nooo)
a decir verdad no se ve ni en el visor de mallas ese de directx...
os lo dejo en vuestras manos caballeros... buena caza.
Pon el archivo de CFX en algún sitio con sus texturas y probaré a importarlo cuando llegue a casa
podrías no crear otro thread para algo que cabe en el anterior? thx
me he pasado al gamespace la malla funciona en el ejemplo de skinned mesh y en el visor pero cuando intento cargarlo en el engine la aplicacion se cierra.
a que es debido esto?
por favor ayudadme!!!!!!
Cita de: "boubou"me he pasado al gamespace la malla funciona en el ejemplo de skinned mesh y en el visor pero cuando intento cargarlo en el engine la aplicacion se cierra.
a que es debido esto?
Aprende a programar :D
Es broma, :P , como no pongas mas no creo que nos venga por inspiracion.
Saludos
Pon el archivo.cfx y lo probaré en casa!! :angry:
Hombre, eso de que lo has probado en tu motor y se cierra... es algo así como demasiado genérico, ¿no?
¿No puedes concretar un poco? ¿Explicar un poco como funciona tu motor? ¿Has hecho un debug concienzudo para ver en que línea peta exactamente?
falla al hacer el loadskinmeshfromxof ese
Pon un poco de codigo de antes de ese punto, lo que haces, etc, asi podremos ver como ayudarte. Suerte
HRESULT result;
LPD3DXBUFFER pmaterialsbuf = NULL;
LPD3DXBUFFER padjacencybuf = NULL;
LPD3DXBUFFER pboneoffsetbuf = NULL;
DWORD dwnamelength;
UINT dwfacescount;
result = pxofobj->GetName( NULL, &dwnamelength );
if( FAILED( result ) )
throw new CDXException( "Couldn't get x file data object's name", result );
if( dwnamelength > 0 )
{
char * pname = new char[dwnamelength];
SAFEPOINTER( pname );
result = pxofobj->GetName( pname, &dwnamelength );
if( FAILED( result ) )
throw new CDXException( "Couldn't get x file data object's name", result );
SetName( pname );
delete[] pname;
}
result = D3DXLoadSkinMeshFromXof( pxofobj, D3DXMESH_MANAGED, pd3ddevice, &padjacencybuf,
&pmaterialsbuf, &dwMaterialCount, &pBoneNamesBuf, &pboneoffsetbuf, &pD3DXSkinMesh );
if( FAILED( result ) )
throw new CDXException( "Couldn't load skin mesh", result );
No puedo ayudarte, yo utilizo la misma técnica que el ejemplo del SDK de skinned mesh, que funciona por CallBacks
me puedes decir como lo haces entonces?
Ya sé que parece que me repito, pero si miras el ejemplo del Skinned Mesh, ahí está lo necesario para saber cómo utilizarlo. Si hay algo concreto que no entiendes, quizás pueda ayudarte, pero no puedo explicarte TODO porque necesitaría un tutorial
vale vale. lo mirare.
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 );
}
}
}