How do I draw a 2d plane and rotate camara (To be a board) in a 3d XNA game?
- by Mech0z
I am trying to create a simple board game, but the 3d part of this is really killing me.
From what I can gather I have created a plane, but it never moves even though I turn the camara, but that partially makes sense as I only turn the camara with a 3d model, but in my head that makes 0 sense, in my head if I turn the camara it should affect ALL my models? But with this code the camara only "cares" about the 3d cylinder, the plane is just completely still
private void OnDraw(object sender, GameTimerEventArgs e)
{
SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);
foreach (ModelMesh mesh in cylinderModel.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
//effect.World = Matrix.CreateRotationX((float)e.TotalTime.TotalSeconds * 2);
effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f);
effect.EnableDefaultLighting();
}
mesh.Draw();
}
//cameraPosition.Z -= 5.0f;
_effect.World = Matrix.CreateRotationZ((MathHelper.ToRadians(((float)e.TotalTime.Milliseconds / 2) % 360)));
foreach (EffectPass pass in _effect.CurrentTechnique.Passes)
{
pass.Apply();
SharedGraphicsDeviceManager.Current.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, _vertices, 0, 1, VertexPositionColor.VertexDeclaration);
}
}
Is there a way to get the camara to affect all models?