好吧,我正在创建一个我的世界地形的东西只是为了它。我遇到的问题是,如果你从某个角度看,一些实际上在其他人后面的脸会被画在他们前面,因此不会显示那里的实际脸。像 minecraft 一样,我将地形分成多个区域,并且在构建顶点缓冲区时,只显示“外部”面。这也是由于某种原因没有绘制最顶部或左侧的块。除了所有这些问题外,人脸似乎是重叠的,即(只能看到一半人脸)
这是它的样子(注意我只画了顶面,因为我必须修复其他的):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);
}
}
}
}
}
非常感谢您的帮助,谢谢:)