2011-03-05 3 views

답변

0

간단한 대답은 없습니다. 무한한 수의 폴리곤을 그리려고하면 메모리가 고갈되고 프로그램이 충돌하지만 하드웨어가 장면을 렌더링하는 데 무한한 시간이 걸릴 것입니다.

이 문제를 해결하기 위해 게임 개발자는 스카이 박스 및 도달 할 수없는 지형과 같은 트릭을 사용하여 플레이어가 세상을 무한하다고 생각하게 만듭니다. 따라서 반복적 인 바탕 질감을 가진 유한 한 세계를 원하면 그리드에서 여러 번 땅 텍스처를 그리고 땅의 바깥 가장자리를 덮는 skybox를 놓으십시오.

정말로 무한한 세계가 원한다면 하늘 상자와 땅이 움직이는 속임수를 쓸 수 있습니다. 따라서 땅과 하늘 상자의 속도를 움직이는 스프라이트의 속도로 설정하십시오.

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