コード例 #1
0
        void on_btnHeightmapSaveAs_clicked(object o, EventArgs e)
        {
            string filepath = GetFilePath("Save heightmap as", "*.JPG");

            if (filepath != "")
            {
                HeightMapPersistence.GetInstance().Save(filepath);
            }
        }
コード例 #2
0
        void on_btnLoadHeightmap_clicked(object o, EventArgs e)
        {
            string filepath = GetFilePath("Open heightmap", "*.JPG");

            if (filepath != "")
            {
                HeightMapPersistence.GetInstance().Load(filepath);
            }
        }
コード例 #3
0
 void on_btnHeightMapSave_clicked(object o, EventArgs e)
 {
     if (MetaverseClient.GetInstance().worldstorage.terrainmodel.HeightmapFilename != "")
     {
         HeightMapPersistence.GetInstance().Save(MetaverseClient.GetInstance().worldstorage.terrainmodel.HeightmapFilename);
     }
     else
     {
         on_btnHeightmapSaveAs_clicked(o, e);
     }
 }
コード例 #4
0
        public void Restore(Stream stream, Uri projecturi)
        //public void Restore( StringReader stringreader, Uri projecturi )
        {
            WorldModel worldmodel = MetaverseClient.GetInstance().worldstorage;

            // note to self: should make these types a publisher/subscriber thing
            //XmlSerializer serializer = new XmlSerializer( typeof( World ), new Type[]{
            //  typeof( Avatar ),
//                typeof( FractalSplineCylinder ),
//              typeof( FractalSplineRing ),
//            typeof( FractalSplineBox ),
//          typeof( FractalSplineTorus ),
//        typeof( FractalSplinePrism ),
//      typeof( FractalSplineTube )
            //    } );
            //DialogHelpers.ShowInfoMessage( null, serializer.Deserialize(filestream).GetType().ToString());
            ProjectFileController.GetInstance().SetProjectPath(projecturi);

            StreamReader sr       = new StreamReader(stream);
            string       contents = sr.ReadToEnd();

            sr.Close();
            StringReader stringreader = new StringReader(contents);

            OsmpXmlSerializer.GetInstance().RegisterType(typeof(World));
            World world = (World)OsmpXmlSerializer.GetInstance().Deserialize(stringreader);

            stringreader.Close();
            //World world = (World)serializer.Deserialize( stream );

            worldmodel.Clear();
            foreach (Entity entity in world.Entities)
            {
                if (entity.GetType() != typeof(Avatar))
                {
                    LogFile.WriteLine("WorldPersistToXml, restoring: " + entity);
                    worldmodel.AddEntity(entity);
                }
            }
            if (world.TerrainModel.HeightmapFilename != "")
            {
                HeightMapPersistence.GetInstance().Load(world.TerrainModel.HeightmapFilename);
            }
            worldmodel.terrainmodel.texturestagesarray = world.TerrainModel.texturestagesarray;
            LogFile.WriteLine(worldmodel);
            worldmodel.terrainmodel.MinHeight = world.TerrainModel.MinHeight;
            worldmodel.terrainmodel.MaxHeight = world.TerrainModel.MaxHeight;
            worldmodel.terrainmodel.OnTerrainModified();
        }