Animation / 3D studio max problem

Topics: User Forum
Oct 21, 2007 at 11:16 PM
Hi,

I am trying to make an animation of a car with wheels in XNA, using 3D studio max, and the Panda direct x exporter. For animation in XNA I have decided to use the XNA Animation Component Library (http://www.codeplex.com/animationcomponents).

My animation works perfectly fine in 3D studio max (you can watch it at http://bensa.spurven.biz/auto/correct.avi), the only difference between the front and back tire is that the front tire is scaled down (before animated). Then I export it to XNA, and run it with this code (Basically (kode) the same as in the animation lib tutorial example):



#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Xclna.Xna.Animation;
using System.Diagnostics;
#endregion

namespace RaceGame
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
ContentManager content;
ModelAnimator carAnimator;
Matrix view;
Vector3 carPosition = Vector3.Zero;
AnimationController forward;

public Game1()
{
graphics = new GraphicsDeviceManager(this);
content = new ContentManager(Services);
}

protected override void Initialize()
{
base.Initialize();
}

private void RunController(ModelAnimator animator, AnimationController controller)
{
foreach (BonePose p in animator.BonePoses)
{
p.CurrentController = controller;
p.CurrentBlendController = null;
}
}

protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
Model model = content.Load<Model>("panda");
carAnimator = new ModelAnimator(this, model);
Viewport port = graphics.GraphicsDevice.Viewport;
view = Matrix.CreateLookAt(new Vector3(-80f, 40f, 80f), Vector3.Zero, Vector3.Up);
Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)port.Width / port.Height, .1f, 100000f);

foreach (ModelMesh mesh in model.Meshes)
{
foreach (Effect effect in mesh.Effects)
{
if (effect is BasicEffect)
{
BasicEffect basic = (BasicEffect)effect;
basic.View = view;
basic.Projection = projection;
basic.EnableDefaultLighting();
}

}
}

forward = new AnimationController(this, carAnimator.Animations"forward");
}
}

protected override void UnloadGraphicsContent(bool unloadAllContent)
{
if (unloadAllContent == true)
{
content.Unload();
}
}

private void UpdateState(GameTime gameTime)
{
KeyboardState keyState = Keyboard.GetState();
BonePoseCollection poses = carAnimator.BonePoses;
//forward.SpeedFactor = 0.1f;
forward.IsLooping = true;
RunController(carAnimator, forward);
}

protected override void Update(GameTime gameTime)
{
KeyboardState keyState = Keyboard.GetState();
UpdateState(gameTime);
//carAnimator.World = Matrix.CreateScale(100);
carAnimator.World = Matrix.CreateRotationX((float)Math.PI / 2) * Matrix.CreateRotationY((float)Math.PI * 2);
base.Update(gameTime);
}

protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
graphics.GraphicsDevice.RenderState.CullMode = CullMode.None;
base.Draw(gameTime);
}
}
}



However, something gets messed up in the process, as the front tire seems to inlcude the scaling in the animation. So, the back tire animation is like it should be, but the front tire (which is scaled) does not.

XNA animation start: http://bensa.spurven.biz/auto/start.PNG
End: http://bensa.spurven.biz/auto/end.PNG

Exported x-file: http://bensa.spurven.biz/auto/panda.X

Any ideas?
Apr 1, 2008 at 6:51 PM
if possible try using the kwXport exporter, I haven't had great experience w/ the Panda one... the FBX 2006.11 exporter is my personal favorite.

The kWXport plugin's output file ( ascii ) is easy to read through as well... as it'll split the transform, scale, and rotation changes... the panda one that you've posted seems to only use a 4x4 matrix... which I can't recall how to split out the relevant properties...