Renamed MQODataFormat to MQOTextDataFormat (is there a binary version as well?)
This commit is contained in:
parent
4389d8dd38
commit
b50c8f2d02
@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using UniversalEditor.ObjectModels.Multimedia3D.Model;
|
||||
namespace UniversalEditor.DataFormats.Multimedia3D.Model.Metasequoia
|
||||
{
|
||||
public class MQODataFormat : DataFormat
|
||||
{
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
DataFormatReference dfr = base.MakeReference();
|
||||
dfr.Filters.Add("Metasequoia model", new string[] { "*.mqo" });
|
||||
dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All);
|
||||
return dfr;
|
||||
}
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
ModelObjectModel model = (objectModel as ModelObjectModel);
|
||||
if (model == null) return;
|
||||
|
||||
IO.Reader tr = base.Accessor.Reader;
|
||||
string MetasequoiaDocument = tr.ReadLine();
|
||||
if (MetasequoiaDocument != "MetasequoiaDocument") throw new InvalidDataFormatException("File does not begin with \"MetasequoiaDocument\"");
|
||||
|
||||
string DocumentFormat = tr.ReadLine();
|
||||
if (DocumentFormat != "Format Text Ver 1.0") throw new InvalidDataFormatException("Cannot understand Metasequoia format \"" + DocumentFormat + "\"");
|
||||
|
||||
while (!tr.EndOfStream)
|
||||
{
|
||||
string line = tr.ReadLine();
|
||||
if (String.IsNullOrEmpty(line.Trim())) continue;
|
||||
|
||||
if (line.StartsWith("Scene "))
|
||||
{
|
||||
}
|
||||
else if (line.StartsWith("Material "))
|
||||
{
|
||||
string materialCountStr = line.Substring(9, line.IndexOf("{") - 9);
|
||||
int materialCount = Int32.Parse(materialCountStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using UniversalEditor.ObjectModels.Multimedia3D.Model;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Multimedia3D.Model.Metasequoia
|
||||
{
|
||||
public class MQOTextDataFormat : DataFormat
|
||||
{
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
DataFormatReference dfr = base.MakeReference();
|
||||
dfr.Filters.Add("Metasequoia model", new string[] { "*.mqo" });
|
||||
dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All);
|
||||
return dfr;
|
||||
}
|
||||
|
||||
private float mvarFormatVersion = 1.0f;
|
||||
public float FormatVersion { get { return mvarFormatVersion; } set { mvarFormatVersion = value; } }
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
ModelObjectModel model = (objectModel as ModelObjectModel);
|
||||
if (model == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
IO.Reader tr = base.Accessor.Reader;
|
||||
string MetasequoiaDocument = tr.ReadLine();
|
||||
if (MetasequoiaDocument != "MetasequoiaDocument") throw new InvalidDataFormatException("File does not begin with \"MetasequoiaDocument\"");
|
||||
|
||||
string DocumentFormat = tr.ReadLine();
|
||||
if (!DocumentFormat.StartsWith("Format Text Ver ")) throw new InvalidDataFormatException("Cannot understand Metasequoia format \"" + DocumentFormat + "\"");
|
||||
|
||||
mvarFormatVersion = Single.Parse(DocumentFormat.Substring(16));
|
||||
|
||||
while (!tr.EndOfStream)
|
||||
{
|
||||
string line = tr.ReadLine();
|
||||
if (String.IsNullOrEmpty(line.Trim())) continue;
|
||||
|
||||
if (line.StartsWith("Scene "))
|
||||
{
|
||||
}
|
||||
else if (line.StartsWith("Material "))
|
||||
{
|
||||
string materialCountStr = line.Substring(9, line.IndexOf("{") - 9);
|
||||
int materialCount = Int32.Parse(materialCountStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
ModelObjectModel model = (objectModel as ModelObjectModel);
|
||||
if (model == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
IO.Writer tw = base.Accessor.Writer;
|
||||
tw.WriteLine("MetasequoiaDocument");
|
||||
|
||||
tw.WriteLine("Format Text Ver " + mvarFormatVersion.ToString("0.#"));
|
||||
|
||||
tw.WriteLine("Material " + model.Materials.Count.ToString());
|
||||
foreach (ModelMaterial mat in model.Materials)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user