How can i make my meshes be drawn taking in account which one is in from of another? i.e. if i have a mesh that is farder than another it should be drawn behind the second.
Is there a way to do this in xna that is more standardized or do i have to calculate for each mesh myself? If i have to calculate for each mesh by myself, from which point do i calculate the distance to the mesh? the camera position?
Here is how i draw them :
Matrix[] transforms = new Matrix[gameobject.model.Bones.Count];
gameobject.model.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in gameobject.model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.Projection = camera.projectionMatrix;
effect.View = camera.viewMatrix;
effect.World = transforms[mesh.ParentBone.Index] * gameobject.orientation;
}
mesh.Draw();
}