私はMinecraftのクローンを作成していますが、カメラを少しでも速く動かすと、次のようにチャンクの間に大きな裂け目があります。
各チャンクは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はそれ自体で二重にバッファリングされていると思いますか?またはそうグーグルは私に言った。