예제 #1
0
        /// <summary>
        /// Serializes given COLLADA object into an XML document
        /// </summary>
        /// <returns>string XML value</returns>
        public static string Serialize(Collada obj, System.Text.Encoding encoding)
        {
            System.IO.StreamReader streamReader = null;
            System.IO.MemoryStream memoryStream = null;
            try
            {
                memoryStream = new System.IO.MemoryStream();
                System.Xml.XmlWriterSettings xmlWriterSettings = new System.Xml.XmlWriterSettings();
                xmlWriterSettings.Encoding = encoding;
                // settings for human readability!!
                xmlWriterSettings.Indent = true;
                // xmlWriterSettings.NewLineOnAttributes = true;
                xmlWriterSettings.NewLineChars    = Environment.NewLine;
                xmlWriterSettings.NewLineHandling = NewLineHandling.Replace;
                // settings end

                System.Xml.XmlWriter xmlWriter = XmlWriter.Create(memoryStream, xmlWriterSettings);
                Serializer.Serialize(xmlWriter, obj);
                memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
                streamReader = new System.IO.StreamReader(memoryStream);
                return(streamReader.ReadToEnd());
            }
            finally
            {
                if ((streamReader != null))
                {
                    streamReader.Dispose();
                }
                if ((memoryStream != null))
                {
                    memoryStream.Dispose();
                }
            }
        }
예제 #2
0
 private void Clear()
 {
     LibraryGeometries   = new LibraryGeometries();
     LibraryImages       = new LibraryImages();
     LibraryMaterials    = new LibraryMaterials();
     LibraryEffects      = new LibraryEffects();
     LibraryVisualScenes = new LibraryVisualScenes();
     _collada.scene      = null;
     _collada            = null;
 }
예제 #3
0
 public static Collada LoadFromFile(string fileName)
 {
     try
     {
         Collada result = null;
         using (FileStream fs = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read))
         {
             result = Deserialize(fs);
         }
         return(result);
     }
     finally
     { }
 }
예제 #4
0
 /// <summary>
 /// Deserializes xml markup from file into an COLLADA object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output COLLADA object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out Collada obj, out System.Exception exception)
 {
     exception = null;
     try
     {
         obj = LoadFromFile(fileName);
         return(true);
     }
     catch (System.Exception ex)
     {
         obj       = default(Collada);
         exception = ex;
         return(false);
     }
 }
예제 #5
0
 /// <summary>
 /// Deserializes workflow markup into an COLLADA object
 /// </summary>
 /// <param name="xmlStream">stream with xml markup content to deserialize</param>
 /// <param name="obj">Output COLLADA object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(Stream xmlStream, out Collada obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(Collada);
     try
     {
         obj = Deserialize(xmlStream);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
예제 #6
0
 public static void SaveToFile(Collada obj, string fileName, System.Text.Encoding encoding)
 {
     System.IO.StreamWriter streamWriter = null;
     try
     {
         string xmlString = Serialize(obj, encoding);
         streamWriter = new System.IO.StreamWriter(fileName, false, Encoding.UTF8);
         streamWriter.WriteLine(xmlString);
         streamWriter.Close();
     }
     finally
     {
         if ((streamWriter != null))
         {
             streamWriter.Dispose();
         }
     }
 }
예제 #7
0
 public static string Serialize(Collada obj)
 {
     return(Serialize(obj, Encoding.UTF8));
 }
예제 #8
0
 public static async Task <Collada> LoadFromFileAsync(string fileName)
 {
     return(await Task.Run <Collada>(() => { return Collada.LoadFromFile(fileName); }));
 }
예제 #9
0
 public static bool LoadFromFile(string fileName, out Collada obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
예제 #10
0
 public static void SaveToFile(Collada obj, string fileName)
 {
     SaveToFile(obj, fileName, Encoding.UTF8);
 }
예제 #11
0
 public static bool Deserialize(Stream xmlStream, out Collada obj)
 {
     System.Exception exception = null;
     return(Deserialize(xmlStream, out obj, out exception));
 }
예제 #12
0
 public void Begin(string author = "", string authorTool = "ColladaNET", string copyright = "")
 {
     _collada       = new Collada();
     _collada.asset = new Asset(new Asset.Contributor(author, authorTool, copyright + " " + DateTime.Now.Year, ""), DateTime.Now, DateTime.Now, new Asset.Unit(0.01f, "meter"), UpAxisType.Y_UP);
 }