//public void Load()
 //{
 //  Load(Config.GetInstance().defaultHeightMapFilename);
 //}
 public void Load(string filename)
 {
     //Bitmap bitmap = Bitmap.FromFile(filename) as Bitmap;
     //Bitmap bitmap = DevIL.DevIL.LoadBitmap(filename);
     ImageWrapper image = new ImageWrapper( filename );
     int width = image.Width;
     int height = image.Height;
     MetaverseClient.GetInstance().worldstorage.terrainmodel.HeightMapWidth = width;
     MetaverseClient.GetInstance().worldstorage.terrainmodel.HeightMapHeight = height;
     MetaverseClient.GetInstance().worldstorage.terrainmodel.Map = new double[width, height];
     LogFile.WriteLine("loaded bitmap " + width + " x " + height);
     double minheight = Config.GetInstance().mingroundheight;
     double maxheight = Config.GetInstance().maxgroundheight;
     double heightmultiplier = ( maxheight - minheight ) / 255;
     for (int i = 0; i < width; i++)
     {
         for (int j = 0; j < height; j++)
         {
             MetaverseClient.GetInstance().worldstorage.terrainmodel.Map[i, j] = (float)( minheight +
                 heightmultiplier *
                 image.GetBlue(i, j) );
         }
     }
     MetaverseClient.GetInstance().worldstorage.terrainmodel.HeightmapFilename = filename;
     MetaverseClient.GetInstance().worldstorage.terrainmodel.OnTerrainModified();
     MainTerrainWindow.GetInstance().InfoMessage("Heightmap loaded");
 }
Example #2
0
        void LoadHeightMap( string sm3directory, TdfParser.Section terrainsection)
        {
            TerrainModel terrainmodel = MetaverseClient.GetInstance().worldstorage.terrainmodel;

            string filename = Path.Combine( sm3directory, terrainsection.GetStringValue("heightmap") );
            double heightoffset = terrainsection.GetDoubleValue("heightoffset");
            double heightscale = terrainsection.GetDoubleValue("heightscale");
            LogFile.WriteLine("heightoffset: " + heightoffset + " heightscale " + heightscale);
            terrainmodel.MinHeight = heightoffset;
            terrainmodel.MaxHeight = heightoffset + heightscale; // I guess???

            ImageWrapper image = new ImageWrapper( filename );
            //Bitmap bitmap = DevIL.DevIL.LoadBitmap(filename);
            int width = image.Width;
            int height = image.Height;
            terrainmodel.HeightMapWidth = width;
            terrainmodel.HeightMapHeight = height;
            terrainmodel.Map = new double[width, height];
            LogFile.WriteLine("loaded bitmap " + width + " x " + height);
            double minheight = terrainmodel.MinHeight;
            double maxheight = terrainmodel.MaxHeight;
            double heightmultiplier = (maxheight - minheight) / 255;
            LogFile.WriteLine("heightmultiplier: " + heightmultiplier + " minheight: " + minheight);
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    terrainmodel.Map[i, j] =
                        (float)(minheight + heightmultiplier *
                        image.GetBlue(i,j) );
                }
            }
            terrain.HeightmapFilename = filename;
        }