1

私はMinecraftのクローンを作成していますが、カメラを少しでも速く動かすと、次のようにチャンクの間に大きな裂け目があります。

http://imgur.com/oTtN2

各チャンクは32x32x32キューブであり、重要な場合に備えて、キューブの種類ごとに1つの頂点バッファーがあります。画面にも2Dテキストを描いていますが、描画の種類ごとにグラフィックデバイスの状態を設定する必要があることを学びました。これが私が立方体を描く方法です:

GraphicsDevice.Clear(Color.LightSkyBlue);

#region 3D
// Set the device
device.BlendState = BlendState.Opaque;
device.DepthStencilState = DepthStencilState.Default;
device.RasterizerState = RasterizerState.CullCounterClockwise;

// Go through each shader and draw the cubes of that style
lock (GeneratedChunks)
{
    foreach (KeyValuePair<CubeType, BasicEffect> KVP in CubeType_Effect)
    {
        // Iterate through each technique in this effect
        foreach (EffectPass pass in KVP.Value.CurrentTechnique.Passes)
        {
            // Go through each chunk in our chunk map, and pluck out the cubetype we care about
            foreach (Vector3 ChunkKey in GeneratedChunks)
            {
                if (ChunkMap[ChunkKey].CubeType_TriangleCounts[KVP.Key] > 0)
                {
                    pass.Apply(); // assign it to the video card
                    KVP.Value.View = camera.ViewMatrix;
                    KVP.Value.Projection = camera.ProjectionMatrix;
                    KVP.Value.World = worldMatrix;

                    device.SetVertexBuffer(ChunkMap[ChunkKey].CubeType_VertexBuffers[KVP.Key]);
                    device.DrawPrimitives(PrimitiveType.TriangleList, 0, ChunkMap[ChunkKey].CubeType_TriangleCounts[KVP.Key]);
                }
            }
        }
    }
}
#endregion

私がじっと立っていれば、世界は元気に見えます。これはウィンドウモードになっているためかもしれないと思いましたが、全画面表示に切り替えても問題は解決しませんでした。また、XNAはそれ自体で二重にバッファリングされていると思いますか?またはそうグーグルは私に言った。

4

2 に答える 2

1

同様の問題が発生しました。Effectのすべてのパラメーターを設定した後、pass.Apply()を呼び出す必要があることがわかりました。

于 2012-02-24T05:03:16.597 に答える
0

これまでの修正は、1つの巨大な頂点バッファを使用することでした。私はそれが好きではありませんが、それがうまくいくようです。

于 2012-02-16T22:19:40.323 に答える