I have an issue with drawing a Texture2d in my 3d game. I followed RB Whitakers advice on changing the depth buffer, but it didnt seem to work.
The ground is supposed to be checkered. The ground is just a flat model with a texture attached to it.
public void Draw(Matrix view, Matrix projection, Viewport viewport, GraphicsDevice device)
{
Matrix[] transforms = new Matrix[Model.Bones.Count];
Model.CopyAbsoluteBoneTransformsTo(transforms);
Matrix worldMatrix = Matrix.Identity;
Matrix rotationYMatrix = Matrix.CreateRotationY(ForwardDirection);
Matrix translateMatrix = Matrix.CreateTranslation(Position);
worldMatrix = rotationYMatrix * translateMatrix;
smoke.Draw(view, projection, worldMatrix, viewport);
device.DepthStencilState = new DepthStencilState()
{
DepthBufferEnable = true
};
foreach (ModelMesh mesh in Model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.World =
worldMatrix * transforms[mesh.ParentBone.Index]; ;
effect.View = view;
effect.Projection = projection;
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
}
mesh.Draw();
}
}
The item smoke is what is giving me the trouble. It just draws a texture at the position of the ship. Is there something else I have to do besides changing the DepthBUffer?