質問

まあ、私はそれのためだけにMinecraftの地形を作成しています。私が抱えている問題は、特定の角度を見ると、実際に他の背後にあるいくつかの顔がそれらの前に描かれているため、実際にそこにあるものが表示されないことです。 Minecraftのように、私は地形が地域に分離されており、Vertexbufferが構築されると、「外側」の顔のみが表示されます。それはまた、何らかの理由で、まさに上部や左のブロックを描いていません。これらの問題のすべてに加えて、顔は重複しているように見えます(顔の半分のみが見ることができます)

これがどのように見えますか(他の顔を修理しなければならないので、私は上面を描くだけです): http://s1100.photobucket.com/albums/g420/darestium/?action=view¤t=minecraftliketerrain.png

また、次の方法ですべての領域を一度に描画しています(自分で書くことができるまでReimerのエフェクトファイルを使用しています:):

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); 
                    } 
                } 
            } 
        } 
    } 

ヘルプは大歓迎ですありがとう:)

役に立ちましたか?

解決

Zバッファーが無効になっているようです。設定を試してください:

GraphicsDevice.DepthStencilState = DepthStencilState.Default;

あなたが言及する上/左ブロックを描画しないことに関する問題は、おそらく頂点バッファ生成コードに関係する問題です(もしそうなら、その問題について特に別の質問をしてみてください)。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top