public static H3D Open(MemoryStream MS) { //Please note that data should be on Memory when opening because addresses are relocated. //Otherwise the original file would be corrupted! BinaryDeserializer Deserializer = new BinaryDeserializer(MS, GetSerializationOptions()); H3DHeader Header = Deserializer.Deserialize <H3DHeader>(); Console.Write("H3DHeader printout:\n{0}\n", Header); PrintProperties(Header); Console.Write("H3DHeader printout end\n\n\n\n\n"); new H3DRelocator(MS, Header).ToAbsolute(); H3D Scene = Deserializer.Deserialize <H3D>(); Console.Write("H3DScene printout:\n{0}\n", Scene); foreach (var field in Scene.GetType().GetFields()) { PrintProperties(field); } //PrintProperties(Scene); Scene.BackwardCompatibility = Header.BackwardCompatibility; Scene.ForwardCompatibility = Header.ForwardCompatibility; Scene.ConverterVersion = Header.ConverterVersion; Scene.Flags = Header.Flags; foreach (var thingy in Scene.Textures) { bool thing = false; //thing = true; if (thing) { string test = (new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location)).Directory + "\\" + thingy.Name + ".bin"; var bw = new BinaryWriter(File.OpenWrite(test)); bw.Write(thingy.RawBuffer); bw.Close(); } } return(Scene); }