move a model

hi, can someone please point me to/post code hich shows how to move a model in the way it is facing?

I currently have a model loaded and at runtime left/right arrows rotate it respectively. what would i do to make it move forward in the direction it is facing when i press the forward arrow?

thanks for any help

-Prodigy

[345 byte] By [Prodigy074] at [2007-12-25]
# 1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=712432&SiteID=1
Jim.Welch at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 2

i was kinda hoping for 3dcode, heres part of what ive got so far

publicvoid UpdateCamera()

{

view = Matrix.CreateLookAt(newVector3(0, 10, 0), newVector3(0, 0, 0), newVector3(0, 0, 1));

Matrix r1 = Matrix.CreateRotationZ(0.8f * rot);

ViewProjection = view * proj;

world = r1;

}

publicvoid ReadInput()

{

KeyboardState kbs = Keyboard.GetState();

if (kbs.IsKeyDown(Keys.Up))

{

}

if (kbs.IsKeyDown(Keys.Left))

{

rot -= 0.1f;

}

if (kbs.IsKeyDown(Keys.Right))

{

rot += 0.1f;

}

}

Prodigy074 at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 3
This is the movement I use for my camera, you should easily be able to use it for your model. It includes moving backwards and forwards, strafing as well as rotation. This is assuming you want to move freely in all directions. If you want to stay level on the X-axis take out the line with CreateFromAxisAngle in the rotation method. BTW, I got this from http://www.two-kings.de/tutorials/basics/basics01.html

(Call move then rotate)

private void Move(GamePadState currentstate)
{
Vector3 direction;
direction = cameralookat - cameraposition;
direction.Normalize();

cameraposition += direction * (currentstate.ThumbSticks.Right.Y * 2);
cameralookat += direction * (currentstate.ThumbSticks.Right.Y * 2);

direction = Vector3.Cross(direction, updirection);
direction.Normalize();

cameraposition += direction * (currentstate.ThumbSticks.Right.X * 2);
cameralookat += direction * (currentstate.ThumbSticks.Right.X * 2);
}

private void Rotate(GamePadState currentstate)
{
Vector3 direction, rotationaxis;
Matrix rotationmatrix, zrotationmatrix;

direction = cameralookat - cameraposition;
direction.Normalize();

rotationaxis = Vector3.Cross(direction, updirection);
rotationaxis.Normalize();

rotationmatrix = Matrix.CreateFromAxisAngle(rotationaxis, MathHelper.ToRadians(-currentstate.ThumbSticks.Left.Y));

zrotationmatrix = Matrix.CreateRotationY(MathHelper.ToRadians(-currentstate.ThumbSticks.Left.X));

direction = Vector3.Transform(direction, (rotationmatrix * zrotationmatrix));
updirection = Vector3.Transform(updirection, (rotationmatrix * zrotationmatrix));

cameralookat = direction + cameraposition;
}

AndreOdendaal at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...