The animation doesn't play...

Topics: Developer Forum, User Forum
Jun 21, 2012 at 4:47 PM

Dear fellow programmers,

I used to use blender 2.49, xna 3.0 framework and visual studio to make a windows app that runs an animation. It worked fine.

Now I updated my blender to 2.62, xna to 4.0. I have updated the animation library to work with XNA 4.0. But for some reason, I couldn't get the animation to play. The model loads fine. Then animator gets populated fine. I checked the AnimationController duration and it is 70,000,000.

Here's how I code:

private ModelAnimator animator;

private AnimationController BirthingPosition;

public void InitializeModel()       

{

//Initialize animator and animation           

animator = new ModelAnimator(game, model);           

animator.World = currentWorld;//rotate model           

//Add custom effect           

foreach (ModelMesh mesh in model.Meshes)           

{               

//Add custom effect               

foreach (ModelMeshPart part in mesh.MeshParts)               

{                   

if (part.Effect is BasicPaletteEffect)                   

{                       

Effect newEffect = myEffect.Clone();// GraphicsDevice);                        newEffect.Parameters["World"].SetValue(currentWorld);                       

BasicPaletteEffect oldEffect = (BasicPaletteEffect)part.Effect;                        newEffect.Parameters["Texture"].SetValue(oldEffect.Texture);                        newEffect.Parameters["View"].SetValue(view);                        newEffect.Parameters["Projection"].SetValue(projection);                       

part.Effect = newEffect;                   

}                   

else if (part.Effect is BasicEffect)                   

{                       

break;                   

}               

}           

}           

if (animator.Animations.Count > 0)           

{

BirthingPosition = new AnimationController(game, animator.Animations["Test"]);                   

foreach(BonePose pose in animator.BonePoses)                   

{                       

pose.CurrentController = BirthingPosition;                       

pose.CurrentBlendController = null;                   

}

}

protected override bool Draw()

{

TimeSpan elapsedTime = timer.Elapsed.Subtract(lastTimer);

GraphicsDevice.BlendState = BlendState.AlphaBlend;                GraphicsDevice.DepthStencilState = DepthStencilState.Default;

....

 if (BirthingPosition != null)                   

{                       

BirthingPosition.UpdateWithTimeSpan(elapsedTime);                   

}                   

animator.Update(gameTime);                   

//Draw                   

animator.Draw(gameTime);

}

 

I don't know what I did wrong. The animation just won't play. Please help.

Thanks so much!