public void LoadScene(string filename) { ClearScene(); SceneFile sceneFile = SceneLoaderAndSaver.LoadScene(filename); List <PotatoSphere> spheres = sceneFile.Spheres.ToList(); List <PotatoMesh> meshs = new List <PotatoMesh>(); //TODO: Support mesh in scenes data file. meshsBuilder.Build(ref meshs); SceneName = filename; Cubemap.LoadCubemap(option.Cubemap); PotatoSceneData = new PotatoSceneData(spheres, meshs, sceneFile.PointLights.ToList(), RetreiveAllTextureInScene(spheres), option, Cubemap); }
public static void SaveScene(string sceneName, PotatoSphere[] spheres, PotatoMesh[] meshes, PotatoPointLight[] pointLights) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(SceneFile)); SceneFile sceneFile = new SceneFile(spheres, meshes, pointLights); string xml = string.Empty; using (var sw = new StringWriter()) { //TODO: Mettre l'encoding en ASCII pour lire le fichier. Trouver un moyen d'enlever le utf-16 du fichier mit automatiquement. using (XmlWriter writer = XmlWriter.Create(sw, settings: new XmlWriterSettings { Encoding = System.Text.Encoding.ASCII, Indent = true })) { xmlSerializer.Serialize(writer, sceneFile); xml = sw.ToString(); xml = xml.Replace("utf-16", "ascii"); //Encoding do not work, replace it. writer.Flush(); writer.Dispose(); } } File.WriteAllText(sceneName, xml); }