//private static MainForm mainForm;
/// <summary>
/// 对场景序列化
/// </summary>
public static void Serialize_Scene(VCYScene o,string filename)
{
// Construct a person object
// Globals Glo_Scene = new Globals();
//
// // Set the data that is to be serialized
// me.Age = 38;
// me.WeightInPounds = 200;
//
// Console.WriteLine("Serialized Person aged: {0} weight: {1}", me.Age, me.WeightInPounds);
// Create a disk file to store the object to...
// try
//{
if(!Directory.Exists("SceneSave"))
Directory.CreateDirectory("SceneSave");
Stream s = File.Open(@"SceneSave/"+filename, FileMode.Create);
// And use a BinaryFormatted to write the object to the stream...
BinaryFormatter bf = new BinaryFormatter();
// Serialize the object
bf.Serialize(s, o);
// And close the stream
s.Close();
//}
// catch(Exception ex)
// {
// MessageBox.Show(ex.ToString());
// }
}
/// <summary>
/// 对场景反序列化
/// </summary>
public static VCYScene DeSerialize_Scene(string filename)
{
// Open the file this time
Stream s = File.Open(filename, FileMode.Open);
// And use a BinaryFormatted to read object(s) from the stream
BinaryFormatter bf = new BinaryFormatter();
// Serialize the object
object o = bf.Deserialize(s);
s.Close();
//
VCYScene sc=new VCYScene();
//Globals.Engine.Stop();
//Globals.Scene.Destroy(Globals.Engine.Device);
//Globals.Scene=new VCYScene();;
// Ensure it is of the correct type...
sc =(VCYScene)o;
return sc;
//Globals.Engine = new VCYEngine(Globals.Scene,false,mainForm.panel2);
//Globals.Engine.Start();
// if (sce != null)
// Console.WriteLine("DeSerialized Person aged: {0} weight: {1}", p.Age, p.WeightInPounds);
// And close the stream
}