Sign in to follow this  

D3DXLoadMeshHierarchyFromX fails if 2 animated meshes are loaded

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

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 ;)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sc0rp
Anyone? Please, I can't find the solution.


If you aren't using the most recent DirectX SDK (August 2007), try switching to that. D3DX bug fixes and features are what's been happening in the SDK over the past couple of years. If you're not using the most recent SDK, this could be an issue that's already been corrected. (Its my understanding that the animation controller objects are not used by many, if any, commercial games.)

Share this post


Link to post
Share on other sites
Thank you both for replying.

RWThurman, my problem lies on the D3DXLoadMeshHierarchy instruction. The DX seems to be passing 1 more frame than the mesh actually has. But it passes an invalid pointer wich crashes the program. So I guess it is a DX bug.

It 1st passes the 2 frames corresponding to the 2 meshes on the .X file. Then it passes an invalid pointer to an inexisting frame. The big problem is that the invalid pointer isn't NULL but a pointer to somewhere on the memory that's not a valid frame.

legalize, yes it is the last SDK. I'll wait for the next release and work on something else right now.
Still I might try animation using bones. Maybe that 1 isn't buged and it's of better use.

Share this post


Link to post
Share on other sites

This topic is 3711 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.

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