Moving an animated model around a world

Topics: User Forum
Mar 28, 2007 at 4:53 PM
Hi,

I've got a rendered 3d world that I'm trying to move an animated model around.

However the model draws to the screen and is animated, but it draw at the world origin as opposed to the position I'm trying to draw it at using the world matrix. When I draw it using a static x model using default XNA model loading this code seems to work fine.

Code:

foreach (BasicPaletteEffect effect in mesh.Effects)
{
worldMatrix = Matrix.CreateRotationZ(currenttarget.rotation.Z) * Matrix.CreateScale(currenttarget.radius, currenttarget.radius, currenttarget.radius) * Matrix.CreateTranslation(currenttarget.position.X + currenttarget.roaming.X, currenttarget.position.Y + currenttarget.roaming.Y, currenttarget.position.Z + currenttarget.roaming.Z);

effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = worldMatrix;


}
RunController(dwarfAnimator, idle);

Can ayone help me and tell me where I'm going wrong?
Coordinator
Mar 29, 2007 at 6:32 AM
Edited Mar 29, 2007 at 6:37 AM
Yah, the ModelAnimator overrides the world matrix. Instead of using:

effect.World = worldMatrix;

use:
ModelAnimator.World = worldMatrix;

It does this because internally manipulating the World matrix is required to animate non skinned meshes.

Take a look at the first tutorial for an in depth examination of how to make an animated model move around convincingly.
Mar 29, 2007 at 11:40 AM
It worked, Thanks dastle you're a star. I apologise for the crap question, I'm new to this 3d programming lark.