Sign in to follow this  
Myrtle

D3DLoadMeshHierarchyFromX - null animation controller returned

Recommended Posts

I'm quite new to directx and am having problems with the D3DLoadMeshHierarchyFromX function. The problem is that it is returning a null animation controller. Everything else works fine and the mesh renders. All i am doing to check the animation controller is: if(m_aminController) which triggers a Msg box, the Msg box is never triggered, does anyone have any idea what my problem could be, i'm very thankful for any ideas or help! I tested it with the tiny.x and the tiny_4anim file also with a number of other files, they all show (with the animation) in the DirectXViewer. Thanks in advance

Share this post


Link to post
Share on other sites
Post the code for your call to D3DXLoadMeshHierarchyFromX, as well as your code for allocating frames, else there's nothing anyone can do to help you.

I'd suggest putting a breakpoint in the code and stepping over the call, though, rather than trying to put in message boxes. Debuggers are there for a reason.

Share this post


Link to post
Share on other sites
ok, heres my code for creating frames and the call to the function.


HRESULT CMeshHierarchy::CreateFrame(LPCSTR Name, LPD3DXFRAME *ppNewFrame)
{
*ppNewFrame = NULL;

D3DXFRAME_EXTENDED *newFrame = new D3DXFRAME_EXTENDED;
ZeroMemory(newFrame,sizeof(D3DXFRAME_EXTENDED));

newFrame->Name= NULL;

D3DXMatrixIdentity(&newFrame->TransformationMatrix);
D3DXMatrixIdentity(&newFrame->exCombinedTransformationMatrix);

newFrame->pMeshContainer = NULL;
newFrame->pFrameSibling = NULL;
newFrame->pFrameFirstChild = NULL;

*ppNewFrame = newFrame;

return S_OK;
}

HRESULT cMeshes::LoadXFile(std::string FileName)
{
HRESULT hr;

CMeshHierarchy Alloc;

hr = D3DXLoadMeshHierarchyFromX(FileName.c_str(), D3DXMESH_MANAGED, Dir.getD3DDevice(), &Alloc, NULL, &m_frameRoot, &m_animController);
if(FAILED(hr))
return hr;

if(m_animController)
{
MessageBox(NULL, "animation", "ERROR", MB_OK);
m_numAnimationSets = m_animController->GetNumAnimationSets();
}

if(m_frameRoot)
{
SetupBoneMatrices((D3DXFRAME_EXTENDED*)m_frameRoot, NULL);

m_boneMatrices = new D3DXMATRIX[m_maxBones];
ZeroMemory(m_boneMatrices, sizeof(D3DXMATRIX)*m_maxBones);
}

return S_OK;
}




I did put the breakpoint in and it just steps over the if statement, it never gets triggered I just don't see why, but i've probably got somethign worng in mode code.

code is in c++ and april directx.

Share this post


Link to post
Share on other sites
The way you have it coded, it will show the message box if the animation controller is not NULL.

if(m_animController)

is the same thing as:

if(m_animController != NULL)

Share this post


Link to post
Share on other sites
Yes that's what I wanted, I am checking if the animation controller return is not null (has animation info in it). The problem is that the controller is always returning null for the D3DXLoadMeshHierarchyFromX function. I have tried it with multiple x files all of which have animation info in them (including the tiny.x) and it still returns a null animation controller. The messagebox is never shown.

Share this post


Link to post
Share on other sites
OOps!

Look at this:

newFrame->Name= NULL;

You cannot have animations if you don't have any named frames. Be sure to copy the name you are given for each frame. Not all frames will necessarily have a name, but if DirectX cannot register the named frames in the D3DXFRAME hierarchy with the bone names in the animation sets, it won't work.

Share this post


Link to post
Share on other sites
Yes thats done it! Thank You very much, i've been looking for my mistake for days.

Thank You

It makes sense now why that was happening, thank you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this