Hi all. I'm writing a game and I have some problem on how i can Draw a 3d Models over my HUD. In the world that i have created, I can explore the land trought a camera:
Vector2 cameraRotation = new Vector2(-4.023f,0.13f);
Vector3 cameraPosition = new Vector3(172.0f, -98.0f,224.0f);
And the update function:
KeyboardState keys = Keyboard.GetState();
if (keys.IsKeyDown(Keys.Up))
cameraRotation.Y -= elapsedTime;
if (keys.IsKeyDown(Keys.Down))
cameraRotation.Y += elapsedTime;
if (keys.IsKeyDown(Keys.Left))
cameraRotation.X -= elapsedTime;
if (keys.IsKeyDown(Keys.Right))
cameraRotation.X += elapsedTime;
Matrix viewRotationMatrix = Matrix.Transpose(ViewRotation);
Vector3 cameraMovement = Vector3.Zero;
if (keys.IsKeyDown(Keys.S))
cameraMovement += viewRotationMatrix.Forward;
if (keys.IsKeyDown(Keys.W))
cameraMovement += viewRotationMatrix.Backward;
if (keys.IsKeyDown(Keys.A))
cameraMovement += viewRotationMatrix.Right;
if (keys.IsKeyDown(Keys.D))
cameraMovement += viewRotationMatrix.Left;
cameraPosition += cameraMovement * 40.0f * elapsedTime;
This is my Draw function:
void Draw(Model model, Matrix world)
{
foreach (ModelMesh mesh in model.Meshes)
{
foreach (Effect effect in mesh.Effects)
{
effect.Parameters["World"].SetValue(world);
effect.Parameters["View"].SetValue(View);
effect.Parameters["Projection"].SetValue(Projection);
}
mesh.Draw(SaveStateMode.SaveState);
}
}
I need to Draw the model in the X,Y position and when I move around with the camera, the model must "follow" me. With Texture2d there is the possibility to draw in a X,Y position, how can i do with a 3d model? Thanks