D3DXLoadMeshHierarchyFromX fails if 2 animated meshes are loaded

Started by
10 comments, last by Sc0rp 16 years, 6 months ago
Hi. I can successfully load 1 or multiple meshes with 1 or more frame levels. I can also load a single animated mesh and it plays just fine. But when I had a second mesh to that file, D3DXLoadMeshHierarchyFromX returns D3DERR_INVALIDCALL. While debugging I found out that it loads 2 frames and 2 meshes but then loads a third frame after wich comes the error. I can't debug after that since it's assembly code. But i found out that it tries to call the destructors of my ID3DXAllocateHierarchy (wich fails due to the invalid frame allocation). Does anybody knows why it can load a single animated mesh perfectly but not 2? Thank you in advance ;)
Advertisement
Hi Sc0rp,

I'm not sure what exactly do u mean by a single animation mesh. But I have tried personally adding several "Animation Sets" to the file, and it works just fine. Adding and removing that is. But the Animation file had one mesh but several animations.

Hope thats helps.
Thanks for replying ramy.

What I mean is that I can have a box, let's say rotating. And that's ok. But if I simply add another mesh to the scene (another box for instance) and export it all to the same .X file D3DXLoadMeshHierarchyFromX fails.

Maybe it's a problem of the .X format. Maybe it can only have 1 mesh animated per file. But since I can't find documentation on that I'm guessing the problem is mine.
Quote:Original post by Sc0rp
I can successfully load 1 or multiple meshes with 1 or more frame levels. I can also load a single animated mesh and it plays just fine. But when I had a second mesh to that file, D3DXLoadMeshHierarchyFromX returns D3DERR_INVALIDCALL.


Link with the debug D3DX and then look in the debug output stream for the cause of the failure.

My free book on Direct3D: "The Direct3D Graphics Pipeline"
My blog on programming, vintage computing, music, politics, etc.: Legalize Adulthood!

Thanks legalize.

Here's the error:

"Assertion failure! (h:\gfx_sdk_dgt_sdk\windows\directx\dxg\active\d3dx9\anim\loadxh.cpp 1392): D3DXFrameNumNamedMatrices(pframeRoot) == plc->cNamedMatrices
D3DX: ID3DXAnimationController::RegisterAnimationOutput: Number of matrices registered is equal to the max number set at creation time."

Any idea?
Quote:Original post by Sc0rp
Here's the error:

"Assertion failure! (h:\gfx_sdk_dgt_sdk\windows\directx\dxg\active\d3dx9\anim\loadxh.cpp 1392): D3DXFrameNumNamedMatrices(pframeRoot) == plc->cNamedMatrices
D3DX: ID3DXAnimationController::RegisterAnimationOutput: Number of matrices registered is equal to the max number set at creation time."

Any idea?


When you create an animation controller, you tell it how many outputs it will have. You can't register more outputs than that; it uses a fixed-size array and doesn't dynamically increase it.

When you create the controller, use a bigger number for the requested number of animation outputs.

My free book on Direct3D: "The Direct3D Graphics Pipeline"
My blog on programming, vintage computing, music, politics, etc.: Legalize Adulthood!

Quote:Original post by legalize
Quote:Original post by Sc0rp
Here's the error:

"Assertion failure! (h:\gfx_sdk_dgt_sdk\windows\directx\dxg\active\d3dx9\anim\loadxh.cpp 1392): D3DXFrameNumNamedMatrices(pframeRoot) == plc->cNamedMatrices
D3DX: ID3DXAnimationController::RegisterAnimationOutput: Number of matrices registered is equal to the max number set at creation time."

Any idea?


When you create an animation controller, you tell it how many outputs it will have. You can't register more outputs than that; it uses a fixed-size array and doesn't dynamically increase it.

When you create the controller, use a bigger number for the requested number of animation outputs.


I did. I already set it to high numbers and still the same. I only have 1 animation and 2 meshes. The animation controller is created like this:

D3DXCreateAnimationController(10, 10, 10, 10, &AnimController);

I'm not getting even near that limit.

Do I have to make my own instance of the ID3DXAnimationController as I did to the ID3DXAllocateHierarchy? If it is working with 1 mesh I guess not.
Anyone? Please, I can't find the solution.
Hi Scorp,

I've been having the same issue very spuratically in the last few weeks. About 10% of the time, one particular mesh (an animated windmill) has this issue. Only recently have I realized that the same assert was coming out. None of my other skinned meshes are exhibiting this problem, but then again this is the first static/skinned mesh I've used.

Once the assert kicks off, then the animation of my model becomes very choppy as though a lot of the keys are missing. If I cause a device lost event by moving my game to another monitor, then the problem usually disappears.

Also, I'm using D3DXLoadMeshHierarchy to load my skinned mesh in a template, then the instance clones the template's animation controller using CloneAnimationController. It look like this:

const i32 cloneAnimationControllerStatus = animationControllerPtr->CloneAnimationController(
animationControllerPtr->GetMaxNumAnimationOutputs(),
animationControllerPtr->GetMaxNumAnimationSets(),
animationControllerPtr->GetMaxNumTracks(),
animationControllerPtr->GetMaxNumEvents(),
&m_animationControllerPtr);
if (cloneAnimationControllerStatus != 0)
{
throw Exception("Could not clone animation controller: " + toString(cloneAnimationControllerStatus));
}

I'm laying more traps for this bug. I'm not sure if the clone or the load call is issuing the assert. If I catch the root problem, then I'll post what I did to fix this problem for myself.
Sorry about the false alarm. The model issueing the assert wasn't the windmill. It was another newer model whose export to .x was dubious at best.

This topic is closed to new replies.

Advertisement