Quote:
I've recently ditched my own 3d model loading/animation class in favor of D3DX's implementation. I've had some pretty good results so far, though as soon as I try to animate the models (in my game), everything blows up.
I first created my own SkinnedMesh class roughly based off of the Direct3D skinned mesh samples included in the SDK. I got it in-game....and un-animated meshes were displayed fine, though when I tried to animate the model, it just disappears or blows up into a bunch of random triangles.
After trying to find the error for a few hours, I just copied/pasted the sample code right out of the SDK in hopes that I'd done something stupid....though the model still blows up as soon as I tried to animate it.
Next I referenced the tutorial here on GameDev by Jason Jurecka ( CLICKY ) and tried to implement his code...still the model isn't displayed as soon as I turn animation on (In my game). This tutorial was quite useful because he based it off the same DXSDK code I based my SkinnedMesh class off of.
The weird part is that both of these programs display the animated .x model perfectly when I run their app, but as soon as I try to put it into my game it blows up. Specifically as soon as I call the SetTime() function of the D3DXAnimationController associated with the model, and pass in anything other than 0.
I'm using Visual Studio 6.0, and one of the first versions of the DX 9.0 SDK. Which just adds to my problems. The SetTime() function of the animation controller class has been taken out (a few years ago :-p) so that could have something to do with it. Though everything works perfectly in Jason's example and the example from the (older) DirectX SDK, which both use the SetTime() function.
I can't use a newer verison of the DirectX SDK because:
- They don't support Visual Studio 6.0 anymore
- I can't seem to get my exported animated .x files to work in ANY of the DirectX sample programs, or in the MeshViewer program included in the newest versions of the DirectX SDK.
I have two working examples that compile fine, and display my animated .x file perfectly...though as soon as I try to implement those classes into my app....the animation doesn't work.
Some other notes:
- When I pass 0 into the D3DXAnimationController->SetTime() function, the first frame of the animation is displayed correctly, anything higher than 0 blows up, only in my game though.
- The number of bones loaded is correct.
- (To those familiar with the example code that I'm talking about) I've done a lot of debugging of the problem, and it looks like the contents of the "ppBoneMatrixPtrs" member of the D3DXMESHCONTAINER_DERIVED class are getting set to some crazy values right after the first UpdateFrameMatrices() call...I don't understand why this doesn't happen in the two examples I mentioned previously. I stepped through the samples and as soon as I hit the first UpdateFrameMatrices() call, the values are a lot different than in my game. They get initialized to the same values but after that first call the matrices look a lot different.
I've isolated the model rendering code as much as possible, commenting out every code path that isn't necessary to display the model, and get input from the keyboard...and it still blows up. I've tried setting the same RenderStates as the examples and that didn't help.
I'm about to start with the Direct3D skinned mesh sample and slowly phase MY game code into THEIR sample app and check it out at every stage to see when the animation stops working...this is driving me crazy...I've been working on this for a few days, and I need to find a solution. Any help/suggestions would be GREATLY appreciated.
- Dan
Here is a screenshot of what I do have in-game though...too bad the damn animations don't want to work...