Archived

This topic is now archived and is closed to further replies.

Frustrating run-time error with CMultiAnim from Multiple Animation SDK example

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

Okay, so I decided to use CMultiAnim in my program, and I have a lot of it working well. However, there''s an odd error (I believe...) involving the D3DXLoadMeshHierarchyFromX function call in CMultiAnim::Setup. After the function is called, so that m_pAC is made, any function of m_pAC''s called after LoadMesh generates this error in a message box: Debug Error! Program: Module: File: i386/chkesp.c Line: 42 The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention wiht a function pointer declared with a different calling convention. (Press Retry to debug the application) Abort///Retry///Ignore Now, right now I can''t seem to find any problems wrong with the loadmesh function (it returns S_OK, all the variables are valid). Has anyone else run into this, and know of a possible solution?

Share this post


Link to post
Share on other sites
"(or a wrong function pointer cast). "

Could you please elaborate on what you mean by that?

Btw, I'm positive that all the files are right, esp. since I doubt that the bad creation of m_pAC would be the first thing to come up if I was missing some files.


Oh, and here's the CMultiAnim source code for those who don't want to bother looking it up:

//-----------------------------------------------------------------------------
// Name: CMultiAnim::Setup()
// Desc: The class is initialized with this method.
// We create the effect from the fx file, and load the animation mesh
// from the given X file. We then call SetupBonePtrs() to initialize
// the mesh containers to enable bone matrix lookup by index. The
// Allocation Hierarchy is passed by pointer to allow an app to subclass
// it for its own implementation.
//-----------------------------------------------------------------------------
HRESULT CMultiAnim::Setup( LPDIRECT3DDEVICE9 pDevice,
TCHAR sXFile[],
TCHAR sFxFile[],
CMultiAnimAllocateHierarchy *pAH,
LPD3DXLOADUSERDATA pLUD )
{
assert( pDevice != NULL );
assert( sXFile );
assert( sFxFile );
assert( pAH );

// set the MA instance for CMultiAnimAllocateHierarchy
pAH->SetMA( this );

// set the device
m_pDevice = pDevice;
m_pDevice->AddRef();

HRESULT hr;
D3DXVECTOR3 vCenter;
LPD3DXEFFECTCOMPILER pEC = NULL;

// Increase the palette size if the shader allows it. We are sort
// of cheating here since we know tiny has 35 bones. The alternative
// is use the maximum number that vs_2_0 allows.
D3DXMACRO mac[2] =
{
{ "MATRIX_PALETTE_SIZE_DEFAULT", "35" },
{ NULL, NULL }
};

// If we support VS_2_0, increase the palette size; else, use the default
// of 26 bones from the .fx file by passing NULL
D3DCAPS9 caps;
D3DXMACRO *pmac = NULL;
m_pDevice->GetDeviceCaps( & caps );
if( caps.VertexShaderVersion > D3DVS_VERSION( 1, 1 ) )
{
MessageBox(NULL, "pmac check", NULL, MB_OK);
pmac = mac;
}

// create effect -- do this first, so LMHFX has access to the palette size
TCHAR tszPath[ MAX_PATH ];
hr = DXUtil_FindMediaFileCch( tszPath, MAX_PATH, sFxFile );
if( FAILED( hr ) )
{
MessageBox(NULL, "Filename Error for FX file", NULL, MB_OK);
goto e_Exit;
}

// Define DEBUG_VS and/or DEBUG_PS to debug vertex and/or pixel shaders with the shader debugger.
// Debugging vertex shaders requires either REF or software vertex processing, and debugging
// pixel shaders requires REF. The D3DXSHADER_FORCE_*_SOFTWARE_NOOPT flag improves the debug
// experience in the shader debugger. It enables source level debugging, prevents instruction
// reordering, prevents dead code elimination, and forces the compiler to compile against the next
// higher available software target, which ensures that the unoptimized shaders do not exceed
// the shader model limitations. Setting these flags will cause slower rendering since the shaders
// will be unoptimized and forced into software. See the DirectX documentation for more information
// about using the shader debugger.
{
DWORD dwShaderFlags = 0;
#ifdef DEBUG_VS
dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
#endif
#ifdef DEBUG_PS
dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
#endif
hr = D3DXCreateEffectFromFile( m_pDevice,
tszPath,
pmac,
NULL,
dwShaderFlags,
NULL,
&m_pEffect,
NULL);

if( FAILED( hr ) )
{
MessageBox(NULL, "Error creating D3DXEffect", NULL, MB_OK);

MessageBox(NULL, DXGetErrorString9(hr), NULL, MB_OK);

goto e_Exit;
}
}

// create the mesh, frame hierarchy, and animation controller from the x file
hr = DXUtil_FindMediaFileCch( tszPath, MAX_PATH, sXFile );
if( FAILED( hr ) )
{
MessageBox(NULL, "Error with XFile path", NULL, MB_OK);
goto e_Exit;
}

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!THIS IS WHERE THE ERROR IS!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


hr = D3DXLoadMeshHierarchyFromX( tszPath,
0,
m_pDevice,
pAH,
pLUD,
(LPD3DXFRAME *) &m_pFrameRoot,
&m_pAC );




MessageBox(NULL, DXGetErrorString9(hr), NULL, MB_OK);

if( FAILED(hr) || m_pAC == NULL)
{
hr = E_FAIL;
MessageBox( NULL,
_T("The sample is attempting to load a mesh without animation or incompatible animation. This sample requires tiny_4anim.x or a mesh with identical animation sets. The program will now exit."),
_T("Mesh Load Error"), MB_OK );
goto e_Exit;
}



// set up bone pointers
hr = SetupBonePtrs( m_pFrameRoot );
if( FAILED( hr ) )
{
MessageBox(NULL, "Error setting up bone pointers", NULL, MB_OK);
goto e_Exit;
}

// get bounding radius
hr = D3DXFrameCalculateBoundingSphere( m_pFrameRoot, & vCenter, & m_fBoundingRadius );
if( FAILED( hr ) )
{
MessageBox(NULL, "Error calculating bounding sphere", NULL, MB_OK);
goto e_Exit;
}

// If there are existing instances, update their animation controllers.
{
vector< CAnimInstance* >::iterator itCur, itEnd = m_v_pAnimInstances.end();
for( itCur = m_v_pAnimInstances.begin(); itCur != itEnd; ++ itCur )
{
LPD3DXANIMATIONCONTROLLER pNewAC = NULL;
hr = m_pAC->CloneAnimationController( m_pAC->GetMaxNumAnimationOutputs(),
m_pAC->GetMaxNumAnimationSets(),
m_pAC->GetMaxNumTracks(),
m_pAC->GetMaxNumEvents(),
&pNewAC );
// Release existing animation controller
if( ( * itCur )->m_pAC )
( * itCur )->m_pAC->Release();
( * itCur )->Setup( pNewAC );
}
}




e_Exit:

if( FAILED( hr ) )
{
if( m_amxWorkingPalette )
{
delete [] m_amxWorkingPalette;
m_amxWorkingPalette = NULL;
m_dwWorkingPaletteSize = 0;
}

if( m_pAC )
{
m_pAC->Release();
m_pAC = NULL;
}

if( m_pFrameRoot )
{
D3DXFrameDestroy( m_pFrameRoot, pAH );
m_pFrameRoot = NULL;
}

if( m_pEffect )
{
m_pEffect->Release();
m_pEffect = NULL;
}

if( pEC )
pEC->Release();

m_pDevice->Release();
m_pDevice = NULL;

}

return hr;
}


[edited by - Cypher19 on March 26, 2004 2:33:54 PM]

Share this post


Link to post
Share on other sites