예제 #1
0
        private void SetupTerrainPatches()
        {
            // Clear the terrain cells.
            if (mTerrainCells == null)
            {
                mTerrainCells = new List <TerrainCell>();
            }
            else
            {
                mTerrainCells.Clear();
            }

            // Compute the world matrix to place the terrain in the middle of the scene.
            Matrix WorldMatrix = Matrix.CreateTranslation((float)mHeightMap.Width * -0.5f, 0.0f, (float)mHeightMap.Length * -0.5f);

            // Create the terrain patches.
            int patchWidth  = 16;
            int patchLength = 16;
            int patchCountX = mHeightMap.Width / patchWidth;
            int patchCountZ = mHeightMap.Length / patchLength;
            int patchCount  = patchCountX * patchCountZ;

            for (int x = 0; x < patchCountX; ++x)
            {
                for (int z = 0; z < patchCountZ; ++z)
                {
                    TerrainCell patch = new TerrainCell(mGame);

                    patch.BuildPatch(mHeightMap, WorldMatrix, patchWidth, patchLength, x * (patchWidth - 1), z * (patchLength - 1));

                    mTerrainCells.Add(patch);
                }
            }
        }
예제 #2
0
파일: Terrain.cs 프로젝트: GodLesZ/svn-dump
		private void SetupTerrainPatches() {

			// Clear the terrain cells.
			if( mTerrainCells == null )
				mTerrainCells = new List<TerrainCell>();
			else
				mTerrainCells.Clear();

			// Compute the world matrix to place the terrain in the middle of the scene.
			Matrix WorldMatrix = Matrix.CreateTranslation( (float)mHeightMap.Width * -0.5f, 0.0f, (float)mHeightMap.Length * -0.5f );

			// Create the terrain patches.
			int patchWidth = 16;
			int patchLength = 16;
			int patchCountX = mHeightMap.Width / patchWidth;
			int patchCountZ = mHeightMap.Length / patchLength;
			int patchCount = patchCountX * patchCountZ;

			for( int x = 0; x < patchCountX; ++x ) {
				for( int z = 0; z < patchCountZ; ++z ) {
					TerrainCell patch = new TerrainCell( mGame );

					patch.BuildPatch( mHeightMap, WorldMatrix, patchWidth, patchLength, x * ( patchWidth - 1 ), z * ( patchLength - 1 ) );

					mTerrainCells.Add( patch );
				}
			}
		}