Мне интересно, есть ли в любом случае повторение наземной модели бесконечного времени в XNA. Например, в этом примере http://create.msdn.com/en-US/education/catalog/sample/chasecamera?xna model repeat
ответ
Простой ответ: нет. Если вы попытаетесь нарисовать бесконечное количество полигонов, не только закончится ваша память, а ваша программа выйдет из строя, но аппаратное обеспечение потребует бесконечного количества времени для рендеринга сцены.
Чтобы обойти это, разработчики игр используют трюки, такие как skyboxes и недостижимый ландшафт, чтобы заставить игрока думать, что мир бесконечен. Поэтому, если вы хотите конечный мир с повторяющейся текстурой земли, просто нарисуйте текстуру земли кучей раз в сетке и поставьте skybox, который покрывает внешние края земли.
Если вы действительно хотите мир бесконечного взгляда, вы можете сделать трюк, где skybox и земля перемещаются вместе с вами. Так что просто установите скорости земли и skybox как скорость движущегося спрайта.
Нравится это! Это мой выбор. Вы можете повторить модель из индекса матрицы с другой текстурой
//Draw a ground land
private void draw_groundLand1(int[,,] MatriceWorldCube,Vector3 position_model_origin)
{
int hauteur = MatriceWorldCube.GetLength(0);
int largeur = MatriceWorldCube.GetLength(1);
int longueur = MatriceWorldCube.GetLength(2);
Vector3 pos_reference = position_model_origin;
for (int epaisseur = 0; epaisseur < hauteur; epaisseur++)
{
for (int collone = 0; collone < largeur; collone++)
{
for (int ligne = 0; ligne < longueur ; ligne++)
{
//Vérifie si l'index de la matrice comporte bien un matériaux a placer
if (MatriceWorldCube[epaisseur, collone, ligne] != 0)
{
// 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;
//Applique la texture en fonction du type de matière définit dans l'indice de la matrice
switch (MatriceWorldCube[epaisseur, collone, ligne])
{
case 1:
effect.Texture = text_ground_land1;
break;
case 2:
effect.Texture = text_ground_land2;
break;
default:
break;
}
}
// Draw the mesh, using the effects set above.
mesh.Draw();
}
}
position_model_origin.X = (float)(ligne+1);
}
position_model_origin.X = pos_reference.X;
position_model_origin.Z = (float)(collone+1);
}
position_model_origin.Z = pos_reference.Z;
position_model_origin.Y = (float)(epaisseur+1);
}
position_model_origin.Y = pos_reference.Y;
position_model_origin = pos_reference;
}