2011-03-05 10 views

答えて

0

簡単な答えはノーです。無限の数のポリゴンを描画しようとすると、メモリが使い果たされ、プログラムがクラッシュするだけでなく、ハードウェアがシーンをレンダリングするのに無限の時間がかかります。

これを回避するために、ゲーム開発者は空のようなトリックや到達不能な地形を使用して、プレイヤーに世界が無限であると考えるようにします。だから、もしあなたが繰り返して地面のテクスチャを持つ有限の世界を望むならば、地面のテクスチャをグリッドにたくさん描き、地面の外縁を覆うスカイボックスを置くだけです。

あなたが本当に無限の世界を望むなら、あなたはスカイボックスと地面があなたと共に移動するトリックをすることができます。それで、地面と空の速度を移動しているスプライトの速度に設定してください。

0

このように!それは私のカスタムサンプルです。テクスチャの異なるマトリックスインデックスからモデルを繰り返すことができます

//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; 
    }