Pregunta

Bueno, estoy creando un terreno de Minecraft solo por el gusto. El problema que tengo es que si miras en cierto ángulo, algunas caras que realmente están detrás de otras se dibujan frente a ellos, por lo que no muestra los reales que están allí. Al igual que Minecraft, tengo el terreno separado en las regiones, y cuando se construye el vértice, solo se muestran las caras "exteriores". También es por alguna razón no dibujar la parte superior ni los bloques izquierdos. Además de todos estos problemas, las caras parecen estar superpuestas, es decir (solo la mitad de una cara se puede ver)

Esto es lo que parece (tenga en cuenta que solo estoy dibujando las caras superiores porque tengo que arreglar a los demás): http://s1100.photobucket.com/albums/g420/darestium/?action=view¤t=minecraftliketerrain.png

También estoy dibujando todas las regiones de una sola vez con el siguiente método (estoy usando el archivo de efecto de Reimer hasta que pueda escribir el mío :):

public void Draw(Player player, World world) 
    { 
        effect.CurrentTechnique = effect.Techniques["TexturedNoShading"]; 
        effect.Parameters["xWorld"].SetValue(Matrix.Identity); 
        effect.Parameters["xProjection"].SetValue(player.Camera.ProjectionMatrix); 
        effect.Parameters["xView"].SetValue(player.Camera.ViewMatrix); 
        effect.Parameters["xCamPos"].SetValue(player.Camera.Position); 
        effect.Parameters["xTexture"].SetValue(world.TextureAlias.SheetTexture); 
        effect.Parameters["xCamUp"].SetValue(player.Camera.UpDownRotation); 

        for (int x = 0; x < world.regions.GetLength(0); x++) 
        { 
            for (int y = 0; y < world.regions.GetLength(1); y++) 
            { 
                foreach (EffectPass pass in effect.CurrentTechnique.Passes) 
                { 
                    pass.Apply(); 


                    Region region = world.regions[x, y]; 

                    if (player.Camera.BoundingFrustum.Contains(region.BoundingBox) != ContainmentType.Disjoint) 
                    { 
                        device.SetVertexBuffer(region.SolidVertexBuffer); 
                        //device.Indices = region.SolidIndices; 
                        device.DrawPrimitives(PrimitiveType.TriangleList, 0, region.VertexCount); 
                        //device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, region.VertexCount, 0, region.SolidIndices.IndexCount / 3); 
                    } 
                } 
            } 
        } 
    } 

La ayuda sería muy apreciada gracias :)

¿Fue útil?

Solución

Parece que el z-buffer está deshabilitado. Intenta configurar:

GraphicsDevice.DepthStencilState = DepthStencilState.Default;

El problema con él no dibuja los bloques superior/izquierdo, que usted menciona, es probablemente un problema con su código de generación de búfer de vértice (si es así, intente hacer otra pregunta específicamente sobre ese problema).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top