public async static Task <SimpleCollada> Load_File() { try { SimpleCollada col_scenes = null; XmlSerializer sr = new XmlSerializer(typeof(SimpleCollada)); FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; openPicker.FileTypeFilter.Add(".xml"); openPicker.FileTypeFilter.Add(".dae"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { var stream = await file.OpenStreamForReadAsync(); col_scenes = (SimpleCollada)(sr.Deserialize(stream)); } return(col_scenes); } catch (Exception ex) { //Console.WriteLine(ex.ToString()); //Console.ReadLine(); return(null); } }
public async static void Save_File(SimpleCollada data) { FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; // Dropdown of file types the user can save the file as savePicker.FileTypeChoices.Add("DAE", new List<string>() { ".dae" }); savePicker.FileTypeChoices.Add("Xml", new List<string>() { ".xml" }); // Default file name if the user does not type one in or select a file to replace savePicker.SuggestedFileName = "Test"; StorageFile file = await savePicker.PickSaveFileAsync(); if (file != null) { IRandomAccessStream sessionRandomAccess = await file.OpenAsync(FileAccessMode.ReadWrite); IOutputStream sessionOutputStream = sessionRandomAccess.GetOutputStreamAt(0); try { XmlSerializer serializer = new XmlSerializer(typeof(SimpleCollada)); serializer.Serialize(sessionOutputStream.AsStreamForWrite(), data); } catch (System.InvalidOperationException e) { Debug.WriteLine(e.InnerException); } sessionRandomAccess.Dispose(); await sessionOutputStream.FlushAsync(); sessionOutputStream.Dispose(); } }
void CreateMaterials(ref SimpleCollada data) { data.Library_Materials.Material = new Grendgine_Collada_Material[1]; Grendgine_Collada_Material m = new Grendgine_Collada_Material(); m.ID = "ID3"; m.Name = "edge_color000255"; m.Instance_Effect = new Grendgine_Collada_Instance_Effect(); m.Instance_Effect.URL = "#ID4"; data.Library_Materials.Material[0] = m; }
private void FillData(ref SimpleCollada data, PolygonCollection paths) { Grendgine_Collada_Visual_Scene sc1 = CreateScene("ID1", 1); data.Library_Visual_Scenes.Visual_Scene = new Grendgine_Collada_Visual_Scene[1] { sc1 }; foreach (Polygon poly in paths.Polygons) { } data.Scene.Visual_Scene = new Grendgine_Collada_Instance_Visual_Scene(); data.Scene.Visual_Scene.URL = "#ID1"; }
SimpleCollada CreateSceneData() { SimpleCollada tst = new SimpleCollada(); tst.Asset.Title = "Test 1"; tst.Asset.Created = DateTime.Now; tst.Asset.Modified = tst.Asset.Created; tst.Asset.Up_Axis = "Y_UP"; tst.Asset.Unit = new Grendgine_Collada_Asset_Unit(); tst.Asset.Unit.Meter = 0.001; tst.Asset.Unit.Name = "MM"; Grendgine_Collada_Asset_Contributor cont = new Grendgine_Collada_Asset_Contributor(); cont.Author = "A. Battersby"; cont.Authoring_Tool = "OTWorkbench"; tst.Asset.Contributor = new Grendgine_Collada_Asset_Contributor[1] { cont }; CreateMaterials(ref tst); CreateLibraryEffects(ref tst); return tst; }
public async static void Save_File(SimpleCollada data) { FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; // Dropdown of file types the user can save the file as savePicker.FileTypeChoices.Add("DAE", new List <string>() { ".dae" }); savePicker.FileTypeChoices.Add("Xml", new List <string>() { ".xml" }); // Default file name if the user does not type one in or select a file to replace savePicker.SuggestedFileName = "Test"; StorageFile file = await savePicker.PickSaveFileAsync(); if (file != null) { IRandomAccessStream sessionRandomAccess = await file.OpenAsync(FileAccessMode.ReadWrite); IOutputStream sessionOutputStream = sessionRandomAccess.GetOutputStreamAt(0); try { XmlSerializer serializer = new XmlSerializer(typeof(SimpleCollada)); serializer.Serialize(sessionOutputStream.AsStreamForWrite(), data); } catch (System.InvalidOperationException e) { Debug.WriteLine(e.InnerException); } sessionRandomAccess.Dispose(); await sessionOutputStream.FlushAsync(); sessionOutputStream.Dispose(); } }
void CreateLibraryEffects(ref SimpleCollada data) { data.Library_Effects.Effect = new Grendgine_Collada_Effect[1]; Grendgine_Collada_Effect efct = new Grendgine_Collada_Effect(); efct.ID = "ID4"; Grendgine_Collada_Profile_COMMON prof = new Grendgine_Collada_Profile_COMMON(); prof.Technique = new Grendgine_Collada_Effect_Technique_COMMON(); prof.Technique.sID = "COMMON"; prof.Technique.Constant = new Grendgine_Collada_Constant(); prof.Technique.Constant.Transparency = new Grendgine_Collada_FX_Common_Float_Or_Param_Type(); prof.Technique.Constant.Transparency.Float = new Grendgine_Collada_SID_Float(); prof.Technique.Constant.Transparency.Float.Value = 1; prof.Technique.Constant.Transparent = new Grendgine_Collada_FX_Common_Color_Or_Texture_Type(); prof.Technique.Constant.Transparent.Opaque = Grendgine_Collada_FX_Opaque_Channel.A_ONE; prof.Technique.Constant.Transparent.Color = new Grendgine_Collada_Color(); prof.Technique.Constant.Transparent.Color.Value_As_String = "0 0 0 1"; efct.Profile_COMMON = new Grendgine_Collada_Profile_COMMON[] { prof }; data.Library_Effects.Effect[0] = efct; }