public void ImportHeightMapAndGridMap(string heightmapFile, string gridmapFile = null) { if (File.Exists(heightmapFile)) { heightmapContent = new ContentManager(graphicsDeviceControl1.Services, contentBuilder.OutputDirectory); contentBuilder.Add(heightmapFile, "heightmap", null, "TextureProcessor"); bool gridmapFileExists = !string.IsNullOrEmpty(gridmapFile) && File.Exists(gridmapFile); if (gridmapFileExists) { contentBuilder.Add(gridmapFile, "gridmap", null, "TextureProcessor"); } contentBuilder.Build(); camera.Detach(Terrain.TerrainIndexer); Terrain = new Terrain(GraphicsDevice, camera, heightmapContent.Load <Texture2D>("heightmap"), heightmapFile, effectFile, terrainTextureFile); Terrain.Texture = grassTexture; terrainBrush.Terrain = Terrain; if (gridmapFileExists) { List <string> assets = Grid.RoadAssetFiles; Grid = new Grid(Terrain, 8, camera, GraphicsDevice, basicEffect); Grid.RoadModel = contentManager.Load <Model>("jalan_raya"); Grid.RoadModel_belok = contentManager.Load <Model>("jalan_raya_belok"); Grid.GridMapFile = gridmapFile; Grid.GridMap = heightmapContent.Load <Texture2D>("gridmap"); Grid.ImportGridMap(); Grid.RoadAssetFiles = assets; gridPointer = new GridPointer(Grid); gridPointers = new List <GridPointer>(); } camera.Attach(Terrain.TerrainIndexer); camera.Notify(); } }