我的紋理顯示模型有一些問題。 一切正常,但是,我使用循環重複紋理來表示屏幕上的20×20的地板。我的紋理重複正確。但我不明白爲什麼我的所有紋理都會產生閃爍...... 我注意到圖像疊加在一起。我確定我檢查了我的循環編碼是否正確。爲什麼我的圖片在我的xna項目中閃爍?
見截圖:
我的代碼(循環函數生成地):
//Function draw - ground land
private void draw_groundLand(Vector3 position_model_origin)
{
//example generation mode 4x4 cubes
int[,,] MatriceWorldCube = new int[1,2,2];
MatriceWorldCube[0, 0, 0] = 1;
MatriceWorldCube[0, 0, 1] = 1;
MatriceWorldCube[0, 1, 0] = 2;
MatriceWorldCube[0, 1, 1] = 1;
int height = MatriceWorldCube.GetLength(0);
int width = MatriceWorldCube.GetLength(1);
int length = MatriceWorldCube.GetLength(2);
Vector3 pos_reference = position_model_origin;
for (int thickness = 0; thickness < height; thickness ++)
{
for (int column = 0; column < width; column ++)
{
for (int line = 0; line < length ; line ++)
{
// Copy any parent transforms.
Matrix[] transforms = new Matrix[model_ground_land1.Bones.Count];
model_ground_land1.CopyAbsoluteBoneTransformsTo(transforms);
// Draw the model. A model can have multiple meshes, so loop.
foreach (ModelMesh mesh in model_ground_land1.Meshes)
{
// This is where the mesh orientation is set, as well
// as our camera and projection.
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationY(cubeGroundLand1_modelRotation) * Matrix.CreateTranslation(position_model_origin);
effect.View = View;
effect.Projection = Projection;
}
// Draw the mesh, using the effects set above.
mesh.Draw();
}
position_model_origin.X = (float)(line +1);
}
position_model_origin.X = pos_reference.X;
position_model_origin.Z = (float)(column +1);
}
position_model_origin.Z = pos_reference.Z;
position_model_origin.Y = (float)(thickness+1);
}
position_model_origin.Y = pos_reference.Y;
position_model_origin = pos_reference;
}
預先感謝您的幫助。我失去了耐心(整個週末^ ^)
看起來像[z-fighting](http://en.wikipedia.org/wiki/Z-fighting)。 – CodeCaster
好的謝謝你我不知道這個問題。我剛開始使用「XNA」。你建議如何避免這種情況?如何設置Z戰鬥? 非常感謝。 –
來自鏈接:_「通過使用更高分辨率的深度緩衝區,通過z緩衝在某些情況下,或通過簡單地移動多邊形進一步分開,可以減少Z戰鬥。看起來你在同一個地方有太多的多邊形。 – CodeCaster