diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/DoomWAD.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/DoomWAD.xml index 22f1062c..0bf63778 100644 --- a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/DoomWAD.xml +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/DoomWAD.xml @@ -5,7 +5,7 @@ - *.gd + *.wad diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Model/IDSoftware.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Model/IDSoftware.xml new file mode 100644 index 00000000..2e690ffa --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Model/IDSoftware.xml @@ -0,0 +1,65 @@ + + + + + + + + *.md2 + + + + IDP2 + + + + + + + + + + + + + + + + *.md3 + + + + IDP3 + + + + + + + + + + + + + + + + *.glm + + + + 2LGM + + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Scene/IDSoftware.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Scene/IDSoftware.xml new file mode 100644 index 00000000..71d51adb --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Scene/IDSoftware.xml @@ -0,0 +1,25 @@ + + + + + + + + *.bsp + + + + IBSP + + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Accessory/PolygonMovieMaker.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Accessory/PolygonMovieMaker.xml new file mode 100644 index 00000000..7d7fa776 --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Accessory/PolygonMovieMaker.xml @@ -0,0 +1,20 @@ + + + + + + + + *.vac + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/Blender.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/Blender.xml new file mode 100644 index 00000000..06e48aee --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/Blender.xml @@ -0,0 +1,20 @@ + + + + + + + + *.blend + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/Metasequoia.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/Metasequoia.xml new file mode 100644 index 00000000..587b6e1a --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/Metasequoia.xml @@ -0,0 +1,20 @@ + + + + + + + + *.mqo + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/ThreeDStudioMax.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/ThreeDStudioMax.xml new file mode 100644 index 00000000..8f78e42e --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/ThreeDStudioMax.xml @@ -0,0 +1,20 @@ + + + + + + + + *.max + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/WavefrontOBJ.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/WavefrontOBJ.xml new file mode 100644 index 00000000..d1bdb21d --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Model/WavefrontOBJ.xml @@ -0,0 +1,20 @@ + + + + + + + + *.obj + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Motion/PolygonMovieMaker.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Motion/PolygonMovieMaker.xml new file mode 100644 index 00000000..329872cc --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Motion/PolygonMovieMaker.xml @@ -0,0 +1,35 @@ + + + + + + + + *.vmd + + + + Vocaloid Motion Data file + + + + + + *.vmd + + + + Vocaloid Motion Data 0002 + + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Pose/PolygonMovieMaker.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Pose/PolygonMovieMaker.xml new file mode 100644 index 00000000..c8c8aea8 --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Pose/PolygonMovieMaker.xml @@ -0,0 +1,25 @@ + + + + + + + + *.vpd + + + + Vocaloid Pose Data file + + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Scene/Cinema4D.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Scene/Cinema4D.xml new file mode 100644 index 00000000..a67311ed --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Scene/Cinema4D.xml @@ -0,0 +1,20 @@ + + + + + + + + *.c4d + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Scene/PolygonMovieMaker.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Scene/PolygonMovieMaker.xml new file mode 100644 index 00000000..5db68131 --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GraphicDesigner3D/Associations/Scene/PolygonMovieMaker.xml @@ -0,0 +1,35 @@ + + + + + + + + *.mmd + + + + Polygon Movie maker 0001 + + + + + + *.pmm + + + + Polygon Movie maker 0001 + + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/BurikoARCDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/BurikoARCDataFormat.cs deleted file mode 100644 index 8e8b7db9..00000000 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/BurikoARCDataFormat.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UniversalEditor.IO; -using UniversalEditor.ObjectModels.FileSystem; - -namespace UniversalEditor.DataFormats.FileSystem.BurikoGeneralInterpreter -{ - public class BurikoARCDataFormat : DataFormat - { - private static DataFormatReference _dfr = null; - protected override DataFormatReference MakeReferenceInternal() - { - if (_dfr == null) - { - _dfr = base.MakeReferenceInternal(); - _dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All); - } - return _dfr; - } - - protected override void LoadInternal(ref ObjectModel objectModel) - { - FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel); - if (fsom == null) return; - - IO.Reader br = base.Accessor.Reader; - string PackFile____ = br.ReadFixedLengthString(12); - if (PackFile____ != "PackFile ") throw new InvalidDataFormatException("File does not begin with \"PackFile \""); - - int fileCount = br.ReadInt32(); - int FileDataOffset = 16 + (fileCount * 32); - - for (int i = 0; i < fileCount; i++) - { - string FileName = br.ReadFixedLengthString(16); - if (FileName.Contains('\0')) FileName = FileName.Substring(0, FileName.IndexOf('\0')); - - int FileOffset = br.ReadInt32(); - int FileSize = br.ReadInt32(); - int reserved1 = br.ReadInt32(); - int reserved2 = br.ReadInt32(); - - File file = new File(); - file.Name = FileName; - file.Size = FileSize; - file.Properties.Add("offset", FileDataOffset + FileOffset); - file.Properties.Add("length", FileSize); - file.DataRequest += file_DataRequest; - fsom.Files.Add(file); - } - } - - private void file_DataRequest(object sender, DataRequestEventArgs e) - { - IO.Reader br = base.Accessor.Reader; - File file = (sender as File); - int offset = (int)file.Properties["offset"]; - int length = (int)file.Properties["length"]; - br.Accessor.Seek(offset, SeekOrigin.Begin); - e.Data = br.ReadBytes(length); - } - - protected override void SaveInternal(ObjectModel objectModel) - { - FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel); - - IO.Writer bw = base.Accessor.Writer; - bw.WriteFixedLengthString("PackFile "); - - bw.WriteInt32(fsom.Files.Count); - - int fileOffset = 0; - byte[][] fileDatas = new byte[fsom.Files.Count][]; - foreach (File file in fsom.Files) - { - int i = fsom.Files.IndexOf(file); - - bw.WriteFixedLengthString(file.Name, 16); - - bw.WriteInt32(fileOffset); - - fileDatas[i] = file.GetDataAsByteArray(); - bw.WriteInt32(fileDatas[i].Length); - - int reserved1 = 0; - bw.WriteInt32(reserved1); - - int reserved2 = 0; - bw.WriteInt32(reserved2); - - fileOffset += fileDatas[i].Length; - } - foreach (File file in fsom.Files) - { - int i = fsom.Files.IndexOf(file); - bw.WriteBytes(fileDatas[i]); - } - } - } -} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj index 7679d7e4..798c443a 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj +++ b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj @@ -36,7 +36,6 @@ - diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Accessory/PolygonMovieMaker/VACAccessoryDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Accessory/PolygonMovieMaker/VACAccessoryDataFormat.cs index daf654b5..ae61706e 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Accessory/PolygonMovieMaker/VACAccessoryDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Accessory/PolygonMovieMaker/VACAccessoryDataFormat.cs @@ -9,12 +9,15 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Accessory.PolygonMovieMaker { public class VACAccessoryDataFormat : DataFormat { + private static DataFormatReference _dfr = null; protected override DataFormatReference MakeReferenceInternal() { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Capabilities.Add(typeof(AccessoryObjectModel), DataFormatCapabilities.All); - dfr.Filters.Add("Polygon Movie Maker accessory file", new string[] { "*.vac" }); - return dfr; + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(AccessoryObjectModel), DataFormatCapabilities.All); + } + return _dfr; } protected override void LoadInternal(ref ObjectModel objectModel) { diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Blender/BlenderDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Blender/BlenderDataFormat.cs index a21e5a41..feacee9c 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Blender/BlenderDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Blender/BlenderDataFormat.cs @@ -1,23 +1,33 @@ using System; +using UniversalEditor.IO; using UniversalEditor.ObjectModels.Multimedia3D.Model; + namespace UniversalEditor.DataFormats.Multimedia3D.Model.Blender { public class BlenderDataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("Blender scene", new string[] { "*.blend" }); - dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); - return dfr; - } + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } protected override void LoadInternal(ref ObjectModel objectModel) { - throw new NotImplementedException(); + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) throw new ObjectModelNotSupportedException(); + + Reader reader = base.Accessor.Reader; } protected override void SaveInternal(ObjectModel objectModel) { - throw new NotImplementedException(); + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) throw new ObjectModelNotSupportedException(); + + Writer writer = base.Accessor.Writer; } } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Cinema4D/Cinema4DDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Cinema4D/Cinema4DDataFormat.cs index e920d6b2..ee5f8ce1 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Cinema4D/Cinema4DDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Cinema4D/Cinema4DDataFormat.cs @@ -1,23 +1,33 @@ using System; +using UniversalEditor.IO; using UniversalEditor.ObjectModels.Multimedia3D.Model; namespace UniversalEditor.DataFormats.Multimedia3D.Model.Cinema4D { public class Cinema4DDataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("CINEMA 4D scene", new string[] { "*.c4d" }); - dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); - return dfr; + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); + } + return _dfr; } protected override void LoadInternal(ref ObjectModel objectModel) { - throw new NotImplementedException(); + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) throw new ObjectModelNotSupportedException(); + + Reader reader = base.Accessor.Reader; } protected override void SaveInternal(ObjectModel objectModel) { - throw new NotImplementedException(); + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) throw new ObjectModelNotSupportedException(); + + Writer writer = base.Accessor.Writer; } } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Metasequoia/MQOTextDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Metasequoia/MQOTextDataFormat.cs index 0b1e3cbb..44f0841a 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Metasequoia/MQOTextDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Metasequoia/MQOTextDataFormat.cs @@ -1,17 +1,21 @@ using System; + using UniversalEditor.ObjectModels.Multimedia3D.Model; +using UniversalEditor.IO; namespace UniversalEditor.DataFormats.Multimedia3D.Model.Metasequoia { public class MQOTextDataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("Metasequoia model", new string[] { "*.mqo" }); - dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); - return dfr; - } + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } private float mvarFormatVersion = 1.0f; public float FormatVersion { get { return mvarFormatVersion; } set { mvarFormatVersion = value; } } @@ -21,7 +25,7 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Model.Metasequoia ModelObjectModel model = (objectModel as ModelObjectModel); if (model == null) throw new ObjectModelNotSupportedException(); - IO.Reader tr = base.Accessor.Reader; + Reader tr = base.Accessor.Reader; string MetasequoiaDocument = tr.ReadLine(); if (MetasequoiaDocument != "MetasequoiaDocument") throw new InvalidDataFormatException("File does not begin with \"MetasequoiaDocument\""); @@ -47,10 +51,10 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Model.Metasequoia } protected override void SaveInternal(ObjectModel objectModel) { - ModelObjectModel model = (objectModel as ModelObjectModel); - if (model == null) throw new ObjectModelNotSupportedException(); + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) throw new ObjectModelNotSupportedException(); - IO.Writer tw = base.Accessor.Writer; + Writer tw = base.Accessor.Writer; tw.WriteLine("MetasequoiaDocument"); tw.WriteLine("Format Text Ver " + mvarFormatVersion.ToString("0.#")); diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/BSP/BSPMapDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/BSP/BSPMapDataFormat.cs index dc0d1e4f..bcc412a1 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/BSP/BSPMapDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/BSP/BSPMapDataFormat.cs @@ -7,36 +7,39 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Model.Quake.BSP { public class BSPMapDataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("Binary Space Partitioned 3D scene", new byte?[][] { new byte?[] { (byte)'I', (byte)'B', (byte)'S', (byte)'P' } }, new string[] { "*.bsp" }); - dfr.Capabilities.Add(typeof(SceneObjectModel), DataFormatCapabilities.All); - return dfr; - } + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(SceneObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } protected override void LoadInternal(ref ObjectModel objectModel) { throw new NotImplementedException(); - IO.Reader br = base.Accessor.Reader; - string magic = br.ReadFixedLengthString(4); - if (magic != "IBSP") throw new InvalidDataFormatException("File does not begin with \"IBSP\""); + IO.Reader br = base.Accessor.Reader; + string magic = br.ReadFixedLengthString(4); + if (magic != "IBSP") throw new InvalidDataFormatException("File does not begin with \"IBSP\""); - int version = br.ReadInt32(); - for (int i = 0; i < 17; i++) - { - int directoryEntryOffset = br.ReadInt32(); - int directoryEntryLength = br.ReadInt32(); + int version = br.ReadInt32(); + for (int i = 0; i < 17; i++) + { + int directoryEntryOffset = br.ReadInt32(); + int directoryEntryLength = br.ReadInt32(); - long currentPos = br.Accessor.Position; + long currentPos = br.Accessor.Position; - br.Accessor.Seek(directoryEntryOffset, SeekOrigin.Begin); + br.Accessor.Seek(directoryEntryOffset, SeekOrigin.Begin); - br.Accessor.Seek(currentPos, SeekOrigin.Begin); - } + br.Accessor.Seek(currentPos, SeekOrigin.Begin); + } } protected override void SaveInternal(ObjectModel objectModel) diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/GLMDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/GLMDataFormat.cs index bfd37351..62d3ce1a 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/GLMDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/GLMDataFormat.cs @@ -8,124 +8,123 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Model.Quake { public class GLMDataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("Ghoul2 model", new string[] { "*.glm" }); - dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); - return dfr; - } + protected override DataFormatReference MakeReferenceInternal() + { + DataFormatReference dfr = base.MakeReferenceInternal(); + dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); + return dfr; + } protected override void LoadInternal(ref ObjectModel objectModel) { - IO.Reader br = base.Accessor.Reader; + IO.Reader br = base.Accessor.Reader; - ModelObjectModel model = (objectModel as ModelObjectModel); - if (model == null) return; + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) return; - br.Accessor.Seek(0, SeekOrigin.Begin); + string signature = br.ReadFixedLengthString(4); + if (signature != "2LGM") throw new InvalidDataFormatException("File does not begin with '2LGM'"); - string signature = br.ReadFixedLengthString(4); - int version = br.ReadInt32(); + int version = br.ReadInt32(); - string fileName = br.ReadNullTerminatedString(64); - string animationName = br.ReadNullTerminatedString(64); + string fileName = br.ReadNullTerminatedString(64); + string animationName = br.ReadNullTerminatedString(64); - int animIndex = br.ReadInt32(); - int numBones = br.ReadInt32(); - int numLODs = br.ReadInt32(); - int ofsLODs = br.ReadInt32(); - int numSurfaces = br.ReadInt32(); - int ofsSurfHierarchy = br.ReadInt32(); - int ofsEnd = br.ReadInt32(); + int animIndex = br.ReadInt32(); + int numBones = br.ReadInt32(); + int numLODs = br.ReadInt32(); + int ofsLODs = br.ReadInt32(); + int numSurfaces = br.ReadInt32(); + int ofsSurfHierarchy = br.ReadInt32(); + int ofsEnd = br.ReadInt32(); - System.Collections.Generic.List arySurfaceHierarchyOffsets = new System.Collections.Generic.List(); - for (int i = 0; i < numSurfaces; i++) - { - int surfaceHierarchyOffset = br.ReadInt32(); - arySurfaceHierarchyOffsets.Add(surfaceHierarchyOffset); - } + System.Collections.Generic.List arySurfaceHierarchyOffsets = new System.Collections.Generic.List(); + for (int i = 0; i < numSurfaces; i++) + { + int surfaceHierarchyOffset = br.ReadInt32(); + arySurfaceHierarchyOffsets.Add(surfaceHierarchyOffset); + } - for (int i = 0; i < numSurfaces; i++) - { - /* surface hierarchy */ - string surfaceName = br.ReadNullTerminatedString(64); - int flags = br.ReadInt32(); - string shaderName = br.ReadNullTerminatedString(64); - int shaderIndex = br.ReadInt32(); - int parentIndex = br.ReadInt32(); - int numChildren = br.ReadInt32(); - System.Collections.Generic.List aryChildIndices = new System.Collections.Generic.List(); - for (int j = 0; j < numChildren; j++) - { - int childIndex = br.ReadInt32(); - aryChildIndices.Add(childIndex); - } - } + for (int i = 0; i < numSurfaces; i++) + { + /* surface hierarchy */ + string surfaceName = br.ReadNullTerminatedString(64); + int flags = br.ReadInt32(); + string shaderName = br.ReadNullTerminatedString(64); + int shaderIndex = br.ReadInt32(); + int parentIndex = br.ReadInt32(); + int numChildren = br.ReadInt32(); + System.Collections.Generic.List aryChildIndices = new System.Collections.Generic.List(); + for (int j = 0; j < numChildren; j++) + { + int childIndex = br.ReadInt32(); + aryChildIndices.Add(childIndex); + } + } - for (int i = 0; i < numLODs; i++) - { - int lodOfsEnd = br.ReadInt32(); - for (int j = 0; j < numSurfaces; j++) - { - int lodSurfaceOffset = br.ReadInt32(); - } - } - for (int i = 0; i < numSurfaces; i++) - { - ModelSurface surf = new ModelSurface(); + for (int i = 0; i < numLODs; i++) + { + int lodOfsEnd = br.ReadInt32(); + for (int j = 0; j < numSurfaces; j++) + { + int lodSurfaceOffset = br.ReadInt32(); + } + } + for (int i = 0; i < numSurfaces; i++) + { + ModelSurface surf = new ModelSurface(); - int ident = br.ReadInt32(); - int thisSurfaceIndex = br.ReadInt32(); - int surfaceOfsHeader = br.ReadInt32(); - int surfaceNumVerts = br.ReadInt32(); - int surfaceOfsVerts = br.ReadInt32(); - int surfaceNumTriangles = br.ReadInt32(); - int surfaceOfsTriangles = br.ReadInt32(); - int surfaceNumBoneReferences = br.ReadInt32(); - int surfaceOfsBoneReferences = br.ReadInt32(); - int surfaceOfsEnd = br.ReadInt32(); + int ident = br.ReadInt32(); + int thisSurfaceIndex = br.ReadInt32(); + int surfaceOfsHeader = br.ReadInt32(); + int surfaceNumVerts = br.ReadInt32(); + int surfaceOfsVerts = br.ReadInt32(); + int surfaceNumTriangles = br.ReadInt32(); + int surfaceOfsTriangles = br.ReadInt32(); + int surfaceNumBoneReferences = br.ReadInt32(); + int surfaceOfsBoneReferences = br.ReadInt32(); + int surfaceOfsEnd = br.ReadInt32(); - List triangleIndices = new List(); - for (int j = 0; j < surfaceNumTriangles; j++) - { - float triangleX = br.ReadSingle(); - float triangleY = br.ReadSingle(); - float triangleZ = br.ReadSingle(); - triangleIndices.Add(new float[] { triangleX, triangleY, triangleZ }); - } + List triangleIndices = new List(); + for (int j = 0; j < surfaceNumTriangles; j++) + { + float triangleX = br.ReadSingle(); + float triangleY = br.ReadSingle(); + float triangleZ = br.ReadSingle(); + triangleIndices.Add(new float[] { triangleX, triangleY, triangleZ }); + } - for (int j = 0; j < surfaceNumVerts; j++) - { - ModelVertex vtx = new ModelVertex(); - float normalX = br.ReadSingle(); - float normalY = br.ReadSingle(); - float normalZ = br.ReadSingle(); - vtx.Normal = new PositionVector3(normalX, normalY, normalZ); - float positionX = br.ReadSingle(); - float positionY = br.ReadSingle(); - float positionZ = br.ReadSingle(); - vtx.Position = new PositionVector3(positionX, positionY, positionZ); + for (int j = 0; j < surfaceNumVerts; j++) + { + ModelVertex vtx = new ModelVertex(); + float normalX = br.ReadSingle(); + float normalY = br.ReadSingle(); + float normalZ = br.ReadSingle(); + vtx.Normal = new PositionVector3(normalX, normalY, normalZ); + float positionX = br.ReadSingle(); + float positionY = br.ReadSingle(); + float positionZ = br.ReadSingle(); + vtx.Position = new PositionVector3(positionX, positionY, positionZ); - uint numWeightsAndBoneIndices = br.ReadUInt32(); - byte[] boneWeightings = br.ReadBytes(3); - surf.Vertices.Add(vtx); - } + uint numWeightsAndBoneIndices = br.ReadUInt32(); + byte[] boneWeightings = br.ReadBytes(3); + surf.Vertices.Add(vtx); + } - for (int j = 0; j < surfaceNumVerts; j++) - { - float textureU = br.ReadSingle(); - float textureV = br.ReadSingle(); - surf.Vertices[j].Texture = new TextureVector2(textureU, textureV); - } - for (int j = 0; j < surfaceNumBoneReferences; j++) - { - int boneReference = br.ReadInt32(); - } + for (int j = 0; j < surfaceNumVerts; j++) + { + float textureU = br.ReadSingle(); + float textureV = br.ReadSingle(); + surf.Vertices[j].Texture = new TextureVector2(textureU, textureV); + } + for (int j = 0; j < surfaceNumBoneReferences; j++) + { + int boneReference = br.ReadInt32(); + } - model.Surfaces.Add(surf); - } + model.Surfaces.Add(surf); + } } - protected override void SaveInternal(ObjectModel objectModel) + protected override void SaveInternal(ObjectModel objectModel) { throw new NotImplementedException(); } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/MD2DataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/MD2DataFormat.cs index 7257e3d7..feb21b35 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/MD2DataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/MD2DataFormat.cs @@ -5,24 +5,28 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Model.Quake { public class MD2DataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("id software MD2 model", new byte?[][] { new byte?[] { new byte?(73), new byte?(68), new byte?(80), new byte?(50) } }, new string[] { "*.md2" }); - dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); - return dfr; - } + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } private int mvarVersion = 8; - public int Version - { - get { return mvarVersion; } - set { mvarVersion = value; } - } + public int Version + { + get { return mvarVersion; } + set { mvarVersion = value; } + } protected override void LoadInternal(ref ObjectModel objectModel) { Reader br = base.Accessor.Reader; ModelObjectModel mom = objectModel as ModelObjectModel; string IDP2 = br.ReadFixedLengthString(4); + if (IDP2 != "IDP2") throw new InvalidDataFormatException("File does not begin with 'IDP2'"); + this.mvarVersion = br.ReadInt32(); int skinwidth = br.ReadInt32(); int skinheight = br.ReadInt32(); diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/MD3DataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/MD3DataFormat.cs index cec3150e..f29f949a 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/MD3DataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Quake/MD3DataFormat.cs @@ -10,34 +10,38 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Model.Quake { public class MD3DataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("id software MD3 model", new byte?[][] { new byte?[] { new byte?(73), new byte?(68), new byte?(80), new byte?(51) } }, new string[] { "*.md3" }); - dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); - return dfr; - } + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } + private int mvarVersion = 15; public int Version { - get { return mvarVersion; } - set { mvarVersion = value; } - } + get { return mvarVersion; } + set { mvarVersion = value; } + } protected override void LoadInternal(ref ObjectModel objectModel) - { - ModelObjectModel model = (objectModel as ModelObjectModel); - if (model == null) return; + { + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) return; Reader br = base.Accessor.Reader; string IDP3 = br.ReadFixedLengthString(4); this.mvarVersion = br.ReadInt32(); - - string modelName = br.ReadNullTerminatedString(64); - if (!model.StringTable.ContainsKey(1033)) - { - model.StringTable.Add(1033, new ModelStringTableExtension()); - } - model.StringTable[1033].Title = modelName; + + string modelName = br.ReadNullTerminatedString(64); + if (!model.StringTable.ContainsKey(1033)) + { + model.StringTable.Add(1033, new ModelStringTableExtension()); + } + model.StringTable[1033].Title = modelName; int flags = br.ReadInt32(); int numberOfFrames = br.ReadInt32(); @@ -49,249 +53,249 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Model.Quake int offsetToSurfaces = br.ReadInt32(); int offsetToEndOfFile = br.ReadInt32(); - #region Read the frames - br.Accessor.Position = offsetToFrames; - for (int i = 0; i < numberOfFrames; i++) - { - // General properties of a single animation frame. + #region Read the frames + br.Accessor.Position = offsetToFrames; + for (int i = 0; i < numberOfFrames; i++) + { + // General properties of a single animation frame. - // First corner of the bounding box. - float minBoundsX = br.ReadSingle(); - float minBoundsY = br.ReadSingle(); - float minBoundsZ = br.ReadSingle(); + // First corner of the bounding box. + float minBoundsX = br.ReadSingle(); + float minBoundsY = br.ReadSingle(); + float minBoundsZ = br.ReadSingle(); - // Second corner of the bounding box. - float maxBoundsX = br.ReadSingle(); - float maxBoundsY = br.ReadSingle(); - float maxBoundsZ = br.ReadSingle(); + // Second corner of the bounding box. + float maxBoundsX = br.ReadSingle(); + float maxBoundsY = br.ReadSingle(); + float maxBoundsZ = br.ReadSingle(); - // Local origin, usually (0, 0, 0). - float localOriginX = br.ReadSingle(); - float localOriginY = br.ReadSingle(); - float localOriginZ = br.ReadSingle(); + // Local origin, usually (0, 0, 0). + float localOriginX = br.ReadSingle(); + float localOriginY = br.ReadSingle(); + float localOriginZ = br.ReadSingle(); - // Radius of bounding sphere. - float radiusOfBoundingSphere = br.ReadSingle(); + // Radius of bounding sphere. + float radiusOfBoundingSphere = br.ReadSingle(); - // Name of Frame. ASCII character string, NUL-terminated (C-style) - string frameName = br.ReadNullTerminatedString(16); - } - #endregion - #region Read the tags - br.Accessor.Position = offsetToTags; - for (int i = 0; i < numberOfTags; i++) - { - // An attachment point for another MD3 model. + // Name of Frame. ASCII character string, NUL-terminated (C-style) + string frameName = br.ReadNullTerminatedString(16); + } + #endregion + #region Read the tags + br.Accessor.Position = offsetToTags; + for (int i = 0; i < numberOfTags; i++) + { + // An attachment point for another MD3 model. - // Name of Tag object. ASCII character string, NUL-terminated (C-style). - string tagName = br.ReadNullTerminatedString(64); + // Name of Tag object. ASCII character string, NUL-terminated (C-style). + string tagName = br.ReadNullTerminatedString(64); - // Coordinates of Tag object. - float originX = br.ReadSingle(); - float originY = br.ReadSingle(); - float originZ = br.ReadSingle(); + // Coordinates of Tag object. + float originX = br.ReadSingle(); + float originY = br.ReadSingle(); + float originZ = br.ReadSingle(); - // 3x3 rotation matrix associated with the Tag. - float axisX1 = br.ReadSingle(); - float axisY1 = br.ReadSingle(); - float axisZ1 = br.ReadSingle(); - float axisX2 = br.ReadSingle(); - float axisY2 = br.ReadSingle(); - float axisZ2 = br.ReadSingle(); - float axisX3 = br.ReadSingle(); - float axisY3 = br.ReadSingle(); - float axisZ3 = br.ReadSingle(); - } - #endregion - #region Read the surfaces - br.Accessor.Position = offsetToSurfaces; - for (int i = 0; i < numberOfSurfaces; i++) - { - // An animated triangle mesh. - ReadSurface(br, ref model); - } - #endregion - } + // 3x3 rotation matrix associated with the Tag. + float axisX1 = br.ReadSingle(); + float axisY1 = br.ReadSingle(); + float axisZ1 = br.ReadSingle(); + float axisX2 = br.ReadSingle(); + float axisY2 = br.ReadSingle(); + float axisZ2 = br.ReadSingle(); + float axisX3 = br.ReadSingle(); + float axisY3 = br.ReadSingle(); + float axisZ3 = br.ReadSingle(); + } + #endregion + #region Read the surfaces + br.Accessor.Position = offsetToSurfaces; + for (int i = 0; i < numberOfSurfaces; i++) + { + // An animated triangle mesh. + ReadSurface(br, ref model); + } + #endregion + } - private void ReadSurface(Reader br, ref ModelObjectModel model) - { - long offsetToStart = br.Accessor.Position; + private void ReadSurface(Reader br, ref ModelObjectModel model) + { + long offsetToStart = br.Accessor.Position; - ModelSurface surface = new ModelSurface(); - #region Header - // Magic number. As a string of 4 octets, reads "IDP3"; as unsigned - // little-endian 860898377 (0x33504449); as unsigned big-endian - // 1229213747 (0x49445033). - string magic = br.ReadFixedLengthString(4); // IDP3 + ModelSurface surface = new ModelSurface(); + #region Header + // Magic number. As a string of 4 octets, reads "IDP3"; as unsigned + // little-endian 860898377 (0x33504449); as unsigned big-endian + // 1229213747 (0x49445033). + string magic = br.ReadFixedLengthString(4); // IDP3 - // Name of Surface object. ASCII character string, NUL-terminated - // (C-style). - surface.Name = br.ReadNullTerminatedString(64); + // Name of Surface object. ASCII character string, NUL-terminated + // (C-style). + surface.Name = br.ReadNullTerminatedString(64); - int flags = br.ReadInt32(); + int flags = br.ReadInt32(); - // Number of animation frames. This should match NUM_FRAMES in the - // MD3 header. - int numFrames = br.ReadInt32(); + // Number of animation frames. This should match NUM_FRAMES in the + // MD3 header. + int numFrames = br.ReadInt32(); - // Number of Shader objects defined in this Surface, with a limit of - // MD3_MAX_SHADERS. Current value of MD3_MAX_SHADERS is 256. - int numShaders = br.ReadInt32(); + // Number of Shader objects defined in this Surface, with a limit of + // MD3_MAX_SHADERS. Current value of MD3_MAX_SHADERS is 256. + int numShaders = br.ReadInt32(); - // Number of Vertex objects defined in this Surface, up to - // MD3_MAX_VERTS. Current value of MD3_MAX_VERTS is 4096. - int numVertices = br.ReadInt32(); + // Number of Vertex objects defined in this Surface, up to + // MD3_MAX_VERTS. Current value of MD3_MAX_VERTS is 4096. + int numVertices = br.ReadInt32(); - // Number of Triangle objects defined in this Surface, maximum of - // MD3_MAX_TRIANGLES. Current value of MD3_MAX_TRIANGLES is 8192. - int numTriangles = br.ReadInt32(); + // Number of Triangle objects defined in this Surface, maximum of + // MD3_MAX_TRIANGLES. Current value of MD3_MAX_TRIANGLES is 8192. + int numTriangles = br.ReadInt32(); - // Relative offset from SURFACE_START where the list of Triangle - // objects starts. - int offsetToTriangles = br.ReadInt32(); + // Relative offset from SURFACE_START where the list of Triangle + // objects starts. + int offsetToTriangles = br.ReadInt32(); - // Relative offset from SURFACE_START where the list of Shader - // objects starts. - int offsetToShaders = br.ReadInt32(); + // Relative offset from SURFACE_START where the list of Shader + // objects starts. + int offsetToShaders = br.ReadInt32(); - // Relative offset from SURFACE_START where the list of ST objects (s-t - // texture coordinates) starts. - int offsetToTextureCoordinates = br.ReadInt32(); + // Relative offset from SURFACE_START where the list of ST objects (s-t + // texture coordinates) starts. + int offsetToTextureCoordinates = br.ReadInt32(); - // Relative offset from SURFACE_START where the list of Vertex objects - // (X-Y-Z-N vertices) starts. - int offsetToVertices = br.ReadInt32(); + // Relative offset from SURFACE_START where the list of Vertex objects + // (X-Y-Z-N vertices) starts. + int offsetToVertices = br.ReadInt32(); - // Relative offset from SURFACE_START to where the Surface object ends. - int offsetToEnd = br.ReadInt32(); - #endregion - #region Shaders - // List of Shader objects usually starts immediate after the Surface - // header, but use OFS_SHADERS (or rather, OFS_SHADERS+SURFACE_START for - // files). - br.Accessor.Position = offsetToStart + offsetToShaders; - for (int i = 0; i < numShaders; i++) - { - // Pathname of shader in the PK3. ASCII character string, - // NUL-terminated (C-style). - string shaderName = br.ReadNullTerminatedString(64); + // Relative offset from SURFACE_START to where the Surface object ends. + int offsetToEnd = br.ReadInt32(); + #endregion + #region Shaders + // List of Shader objects usually starts immediate after the Surface + // header, but use OFS_SHADERS (or rather, OFS_SHADERS+SURFACE_START for + // files). + br.Accessor.Position = offsetToStart + offsetToShaders; + for (int i = 0; i < numShaders; i++) + { + // Pathname of shader in the PK3. ASCII character string, + // NUL-terminated (C-style). + string shaderName = br.ReadNullTerminatedString(64); - // Shader index number. No idea how this is allocated, but presumably - // in sequential order of definition. - int shaderIndex = br.ReadInt32(); - } - #endregion - #region Triangles - // List of Triangle objects usually starts immediately after the list of - // Shader objects, but use OFS_TRIANGLES (+ SURFACE_START). - br.Accessor.Position = offsetToStart + offsetToTriangles; + // Shader index number. No idea how this is allocated, but presumably + // in sequential order of definition. + int shaderIndex = br.ReadInt32(); + } + #endregion + #region Triangles + // List of Triangle objects usually starts immediately after the list of + // Shader objects, but use OFS_TRIANGLES (+ SURFACE_START). + br.Accessor.Position = offsetToStart + offsetToTriangles; - List triangleIndices = new List(); - for (int i = 0; i < numTriangles; i++) - { - // List of offset values into the list of Vertex objects that - // constitute the corners of the Triangle object. Vertex numbers are - // used instead of actual coordinates, as the coordinates are - // implicit in the Vertex object. The triangles have clockwise - // winding. - int vertex1Index = br.ReadInt32(); - int vertex2Index = br.ReadInt32(); - int vertex3Index = br.ReadInt32(); + List triangleIndices = new List(); + for (int i = 0; i < numTriangles; i++) + { + // List of offset values into the list of Vertex objects that + // constitute the corners of the Triangle object. Vertex numbers are + // used instead of actual coordinates, as the coordinates are + // implicit in the Vertex object. The triangles have clockwise + // winding. + int vertex1Index = br.ReadInt32(); + int vertex2Index = br.ReadInt32(); + int vertex3Index = br.ReadInt32(); - // save the indices into the list for reference when we actually - // get to the vertex array - triangleIndices.Add(new int[] { vertex1Index, vertex2Index, vertex3Index }); - } - #endregion - #region Texture Coordinates - br.Accessor.Position = offsetToTextureCoordinates; - for (int i = 0; i < numTriangles; i++) - { - float s = br.ReadSingle(); - float t = br.ReadSingle(); + // save the indices into the list for reference when we actually + // get to the vertex array + triangleIndices.Add(new int[] { vertex1Index, vertex2Index, vertex3Index }); + } + #endregion + #region Texture Coordinates + br.Accessor.Position = offsetToTextureCoordinates; + for (int i = 0; i < numTriangles; i++) + { + float s = br.ReadSingle(); + float t = br.ReadSingle(); - // s and t texture coordinates, normalized to the range [0, 1]. Values - // outside the range indicate wraparounds/repeats. Unlike UV coordinates, - // the origin for texture coordinates is located in the upper left corner - // (similar to the coordinate system used for computer screens) whereas, - // in UV mapping, it is placed in the lower left corner. As such, the t - // value must be flipped to correspond with UV coordinates. + // s and t texture coordinates, normalized to the range [0, 1]. Values + // outside the range indicate wraparounds/repeats. Unlike UV coordinates, + // the origin for texture coordinates is located in the upper left corner + // (similar to the coordinate system used for computer screens) whereas, + // in UV mapping, it is placed in the lower left corner. As such, the t + // value must be flipped to correspond with UV coordinates. - // TODO: convert S/T coordinates to UV in order to have a standard - } - #endregion - #region Vertices - for (int i = 0; i < numVertices; i++) - { - ModelVertex vertex = new ModelVertex(); - // x, y, and z coordinates in right-handed 3-space, scaled down by - // factor 1.0/64. (Multiply by 1.0/64 to obtain original coordinate - // value.) - short _vertexX = br.ReadInt16(); - short _vertexY = br.ReadInt16(); - short _vertexZ = br.ReadInt16(); + // TODO: convert S/T coordinates to UV in order to have a standard + } + #endregion + #region Vertices + for (int i = 0; i < numVertices; i++) + { + ModelVertex vertex = new ModelVertex(); + // x, y, and z coordinates in right-handed 3-space, scaled down by + // factor 1.0/64. (Multiply by 1.0/64 to obtain original coordinate + // value.) + short _vertexX = br.ReadInt16(); + short _vertexY = br.ReadInt16(); + short _vertexZ = br.ReadInt16(); - // Zenith and azimuth angles of normal vector. 255 corresponds to 2 - // pi. See spherical coordinates. - byte normalZenith = br.ReadByte(); - byte normalAzimuth = br.ReadByte(); + // Zenith and azimuth angles of normal vector. 255 corresponds to 2 + // pi. See spherical coordinates. + byte normalZenith = br.ReadByte(); + byte normalAzimuth = br.ReadByte(); - double vertexX = (_vertexX * (1.0 / 64)); - double vertexY = (_vertexY * (1.0 / 64)); - double vertexZ = (_vertexZ * (1.0 / 64)); + double vertexX = (_vertexX * (1.0 / 64)); + double vertexY = (_vertexY * (1.0 / 64)); + double vertexZ = (_vertexZ * (1.0 / 64)); - vertex.OriginalPosition = new PositionVector3(vertexX, vertexY, vertexZ); - vertex.Position = new PositionVector3(vertexX, vertexY, vertexZ); + vertex.OriginalPosition = new PositionVector3(vertexX, vertexY, vertexZ); + vertex.Position = new PositionVector3(vertexX, vertexY, vertexZ); - // The normal vector uses a spherical coordinate system. Since the - // normal vector is, by definition, a length of one, only the angles - // need to be recorded. Each angle is constrained between 0 - 255 to - // fit in one octet. A normal vector encodes into 16 bits. + // The normal vector uses a spherical coordinate system. Since the + // normal vector is, by definition, a length of one, only the angles + // need to be recorded. Each angle is constrained between 0 - 255 to + // fit in one octet. A normal vector encodes into 16 bits. - // Encoding: - // azimuth <- atan2(y, x) * 255 / (2 * pi) - // zenith <- acos(z) * 255 / (2 * pi) + // Encoding: + // azimuth <- atan2(y, x) * 255 / (2 * pi) + // zenith <- acos(z) * 255 / (2 * pi) - // Decoding: - // lat <- zenith * (2 * pi ) / 255 - // lng <- azimuth * (2 * pi) / 255 - // x <- cos ( lng ) * sin ( lat ) - // y <- sin ( lng ) * sin ( lat ) - // z <- cos ( lat ) - double lat = (double)((double)normalZenith * (2 * Math.PI) / 255); - double lng = (double)((double)normalAzimuth * (2 * Math.PI) / 255); - - double normalX = Math.Cos(lng) * Math.Sin(lat); - double normalY = Math.Sin(lng) * Math.Sin(lat); - double normalZ = Math.Cos(lat); - vertex.Normal = new PositionVector3(normalX, normalY, normalZ); - surface.Vertices.Add(vertex); - } - #endregion + // Decoding: + // lat <- zenith * (2 * pi ) / 255 + // lng <- azimuth * (2 * pi) / 255 + // x <- cos ( lng ) * sin ( lat ) + // y <- sin ( lng ) * sin ( lat ) + // z <- cos ( lat ) + double lat = (double)((double)normalZenith * (2 * Math.PI) / 255); + double lng = (double)((double)normalAzimuth * (2 * Math.PI) / 255); + + double normalX = Math.Cos(lng) * Math.Sin(lat); + double normalY = Math.Sin(lng) * Math.Sin(lat); + double normalZ = Math.Cos(lat); + vertex.Normal = new PositionVector3(normalX, normalY, normalZ); + surface.Vertices.Add(vertex); + } + #endregion - model.Surfaces.Add(surface); - } + model.Surfaces.Add(surface); + } - protected override void SaveInternal(ObjectModel objectModel) + protected override void SaveInternal(ObjectModel objectModel) { Writer bw = base.Accessor.Writer; ModelObjectModel model = objectModel as ModelObjectModel; bw.WriteFixedLengthString("IDP3"); bw.WriteInt32(mvarVersion); - string modelTitle = String.Empty; - if (model.StringTable.ContainsKey(1033)) - { - modelTitle = model.StringTable[1033].Title; - } - else - { - // get the first string table in the list - foreach (System.Collections.Generic.KeyValuePair kvp in model.StringTable) - { - modelTitle = kvp.Value.Title; - break; - } - } + string modelTitle = String.Empty; + if (model.StringTable.ContainsKey(1033)) + { + modelTitle = model.StringTable[1033].Title; + } + else + { + // get the first string table in the list + foreach (System.Collections.Generic.KeyValuePair kvp in model.StringTable) + { + modelTitle = kvp.Value.Title; + break; + } + } bw.WriteNullTerminatedString(modelTitle, 64); bw.Flush(); } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/ThreeDStudio/ThreeDSMaxDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/ThreeDStudio/ThreeDSMaxDataFormat.cs index 2a2185c7..dc7f2b31 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/ThreeDStudio/ThreeDSMaxDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/ThreeDStudio/ThreeDSMaxDataFormat.cs @@ -7,19 +7,30 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Model.ThreeDStudio { public class ThreeDSMaxDataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("3D Studio MAX model", new string[] { "*.max" }); - dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); - return dfr; - } + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } protected override void LoadInternal(ref ObjectModel objectModel) { + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) throw new ObjectModelNotSupportedException(); + + Reader reader = base.Accessor.Reader; throw new NotImplementedException(); } protected override void SaveInternal(ObjectModel objectModel) { + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) throw new ObjectModelNotSupportedException(); + + Writer reader = base.Accessor.Writer; throw new NotImplementedException(); } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Wavefront/OBJDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Wavefront/OBJDataFormat.cs index 70f48845..9a038d6a 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Wavefront/OBJDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Wavefront/OBJDataFormat.cs @@ -1,23 +1,34 @@ using System; +using UniversalEditor.IO; using UniversalEditor.ObjectModels.Multimedia3D.Model; + namespace UniversalEditor.DataFormats.Multimedia3D.Model.Wavefront { public class OBJDataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("Wavefront object model", new string[] { "*.obj" }); - dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); - return dfr; - } + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } protected override void LoadInternal(ref ObjectModel objectModel) { - throw new NotImplementedException(); + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) throw new ObjectModelNotSupportedException(); + + Reader reader = base.Accessor.Reader; } protected override void SaveInternal(ObjectModel objectModel) { - throw new NotImplementedException(); + ModelObjectModel model = (objectModel as ModelObjectModel); + if (model == null) throw new ObjectModelNotSupportedException(); + + Writer writer = base.Accessor.Writer; } } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Motion/PolygonMovieMaker/VMDMotionDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Motion/PolygonMovieMaker/VMDMotionDataFormat.cs index 5bc6701f..79dae894 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Motion/PolygonMovieMaker/VMDMotionDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Motion/PolygonMovieMaker/VMDMotionDataFormat.cs @@ -9,13 +9,15 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Motion.PolygonMovieMaker /// public class VMDMotionDataFormat : DataFormat { + private static DataFormatReference _dfr = null; protected override DataFormatReference MakeReferenceInternal() { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Capabilities.Add(typeof(MotionObjectModel), DataFormatCapabilities.All); - dfr.Filters.Add("MikuMikuDance v1.30 motion data", new byte?[][] { new byte?[] { (byte)'V', (byte)'o', (byte)'c', (byte)'a', (byte)'l', (byte)'o', (byte)'i', (byte)'d', (byte)' ', (byte)'M', (byte)'o', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)' ', (byte)'D', (byte)'a', (byte)'t', (byte)'a', (byte)' ', (byte)'f', (byte)'i', (byte)'l', (byte)'e' } }, new string[] { "*.vmd" }); - dfr.Filters.Add("Polygon Movie Maker motion data", new byte?[][] { new byte?[] { (byte)'V', (byte)'o', (byte)'c', (byte)'a', (byte)'l', (byte)'o', (byte)'i', (byte)'d', (byte)' ', (byte)'M', (byte)'o', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)' ', (byte)'D', (byte)'a', (byte)'t', (byte)'a', (byte)' ', (byte)'0', (byte)'0', (byte)'0', (byte)'2' } }, new string[] { "*.vmd" }); - return dfr; + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(MotionObjectModel), DataFormatCapabilities.All); + } + return _dfr; } private Version mvarVersion = new Version(1, 0); public Version Version { get { return mvarVersion; } set { mvarVersion = value; } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Pose/PolygonMovieMaker/VPDPoseDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Pose/PolygonMovieMaker/VPDPoseDataFormat.cs index a35d28a0..8db6b51c 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Pose/PolygonMovieMaker/VPDPoseDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Pose/PolygonMovieMaker/VPDPoseDataFormat.cs @@ -9,20 +9,23 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Pose.PolygonMovieMaker { public class VPDPoseDataFormat : DataFormat { + private static DataFormatReference _dfr = null; protected override DataFormatReference MakeReferenceInternal() { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("Polygon Movie Maker pose data", new byte?[][] { new byte?[] { (byte)'V', (byte)'o', (byte)'c', (byte)'a', (byte)'l', (byte)'o', (byte)'i', (byte)'d', (byte)' ', (byte)'P', (byte)'o', (byte)'s', (byte)'e', (byte)' ', (byte)'D', (byte)'a', (byte)'t', (byte)'a', (byte)' ', (byte)'f', (byte)'i', (byte)'l', (byte)'e' } }, new string[] { "*.vpd" }); - dfr.Capabilities.Add(typeof(PoseObjectModel), DataFormatCapabilities.All); - return dfr; + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(PoseObjectModel), DataFormatCapabilities.All); + } + return _dfr; } protected override void LoadInternal(ref ObjectModel objectModel) { PoseObjectModel pose = (objectModel as PoseObjectModel); - if (pose == null) return; + if (pose == null) throw new ObjectModelNotSupportedException(); base.Accessor.DefaultEncoding = Encoding.ShiftJIS; - IO.Reader tr = new IO.Reader(base.Accessor); + Reader tr = base.Accessor.Reader; bool parentFileNameRead = false; bool totalNumberOfBonesRead = false; @@ -161,6 +164,11 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Pose.PolygonMovieMaker } protected override void SaveInternal(ObjectModel objectModel) { + PoseObjectModel pose = (objectModel as PoseObjectModel); + if (pose == null) throw new ObjectModelNotSupportedException(); + + Writer writer = base.Accessor.Writer; + throw new NotImplementedException(); } } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Scene/PolygonMovieMaker/MMDSceneDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Scene/PolygonMovieMaker/MMDSceneDataFormat.cs deleted file mode 100644 index 907f7380..00000000 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Scene/PolygonMovieMaker/MMDSceneDataFormat.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Text; -using UniversalEditor.IO; -using UniversalEditor.ObjectModels.Multimedia3D.Scene; - -namespace UniversalEditor.DataFormats.Multimedia3D.Scene.PolygonMovieMaker -{ - public class MMDSceneDataFormat : DataFormat - { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("Polygon Movie Maker single-model scene data", new byte?[][] { new byte?[] { new byte?(80), new byte?(111), new byte?(108), new byte?(121), new byte?(103), new byte?(111), new byte?(110), new byte?(32), new byte?(77), new byte?(111), new byte?(118), new byte?(105), new byte?(101), new byte?(32), new byte?(109), new byte?(97), new byte?(107), new byte?(101), new byte?(114), new byte?(32), new byte?(48), new byte?(48), new byte?(48), new byte?(49) } }, new string[] { "*.mmd" }); - dfr.Capabilities.Add(typeof(SceneObjectModel), DataFormatCapabilities.All); - return dfr; - } - protected override void LoadInternal(ref ObjectModel objectModel) - { - throw new NotImplementedException(); - } - protected override void SaveInternal(ObjectModel objectModel) - { - throw new NotImplementedException(); - } - } -} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Scene/PolygonMovieMaker/PMMSceneDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Scene/PolygonMovieMaker/PMMSceneDataFormat.cs index ba272c2a..866256b9 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Scene/PolygonMovieMaker/PMMSceneDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Scene/PolygonMovieMaker/PMMSceneDataFormat.cs @@ -6,21 +6,26 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Scene.PolygonMovieMaker { public class PMMSceneDataFormat : DataFormat { - protected override DataFormatReference MakeReferenceInternal() - { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Filters.Add("Polygon Movie Maker multiple-model scene data", new byte?[][] { new byte?[] { new byte?(80), new byte?(111), new byte?(108), new byte?(121), new byte?(103), new byte?(111), new byte?(110), new byte?(32), new byte?(77), new byte?(111), new byte?(118), new byte?(105), new byte?(101), new byte?(32), new byte?(109), new byte?(97), new byte?(107), new byte?(101), new byte?(114), new byte?(32), new byte?(48), new byte?(48), new byte?(48), new byte?(49) } }, new string[] { "*.pmm" }); - dfr.Capabilities.Add(typeof(SceneObjectModel), DataFormatCapabilities.All); - return dfr; - } + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(SceneObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } protected override void LoadInternal(ref ObjectModel objectModel) { SceneObjectModel som = (objectModel as SceneObjectModel); - if (som == null) return; + if (som == null) return; Reader br = base.Accessor.Reader; Encoding encoding = Encoding.ShiftJIS; - string Polygon_Movie_maker_ = br.ReadFixedLengthString(30); + string signature = br.ReadFixedLengthString(30); + if (signature != "Polygon Movie maker 0001") throw new InvalidDataFormatException("File does not begin with 'Polygon Movie maker 0001'"); + som.ImageWidth = br.ReadUInt32(); som.ImageHeight = br.ReadUInt32(); int unknown3 = br.ReadInt32(); @@ -37,66 +42,66 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Scene.PolygonMovieMaker som.Models.Add(pmd); } - byte[] junk1 = br.ReadBytes(21); - for (byte i = 0; i < wModelCount; i++) - { - string modelFileName = br.ReadNullTerminatedString(256); - som.Models[(int)i].FileName = modelFileName; + byte[] junk1 = br.ReadBytes(21); + for (byte i = 0; i < wModelCount; i++) + { + string modelFileName = br.ReadNullTerminatedString(256); + som.Models[(int)i].FileName = modelFileName; - byte[] n = br.ReadBytes(6); - int u0001 = br.ReadInt32(); - int u0002 = br.ReadInt32(); - int u0003 = br.ReadInt32(); - int u0004 = br.ReadInt32(); - int u0005 = br.ReadInt32(); + byte[] n = br.ReadBytes(6); + int u0001 = br.ReadInt32(); + int u0002 = br.ReadInt32(); + int u0003 = br.ReadInt32(); + int u0004 = br.ReadInt32(); + int u0005 = br.ReadInt32(); - byte[] unknown = br.ReadBytes(10225); - } + byte[] unknown = br.ReadBytes(10225); + } - // HACK: ensure we are at the end of the file before continuing - // remove this hack when entire file processing is completed - br.Accessor.Seek(-92, SeekOrigin.End); - som.FPSVisible = br.ReadBoolean(); - som.CoordinateAxisVisible = br.ReadBoolean(); - som.GroundShadowVisible = br.ReadBoolean(); - float fpsLimit = br.ReadSingle(); - if (fpsLimit == 1000) - { - // no limit on the FPS (as exported by MikuMikuDance), so convert it to -1 - som.FPSLimit = -1; - } - else - { - // limit on the FPS, valid values from MMD are 30 or 60, but we'll support others - som.FPSLimit = fpsLimit; - } - som.ScreenCaptureMode = (SceneScreenCaptureMode)br.ReadInt32(); - int u0006 = br.ReadInt32(); + // HACK: ensure we are at the end of the file before continuing + // remove this hack when entire file processing is completed + br.Accessor.Seek(-92, SeekOrigin.End); + som.FPSVisible = br.ReadBoolean(); + som.CoordinateAxisVisible = br.ReadBoolean(); + som.GroundShadowVisible = br.ReadBoolean(); + float fpsLimit = br.ReadSingle(); + if (fpsLimit == 1000) + { + // no limit on the FPS (as exported by MikuMikuDance), so convert it to -1 + som.FPSLimit = -1; + } + else + { + // limit on the FPS, valid values from MMD are 30 or 60, but we'll support others + som.FPSLimit = fpsLimit; + } + som.ScreenCaptureMode = (SceneScreenCaptureMode)br.ReadInt32(); + int u0006 = br.ReadInt32(); - som.GroundShadowBrightness = br.ReadSingle(); - float uuuu = br.ReadSingle(); + som.GroundShadowBrightness = br.ReadSingle(); + float uuuu = br.ReadSingle(); - som.GroundShadowTransparent = br.ReadBoolean(); + som.GroundShadowTransparent = br.ReadBoolean(); - bool flag3 = br.ReadBoolean(); - bool flag4 = br.ReadBoolean(); + bool flag3 = br.ReadBoolean(); + bool flag4 = br.ReadBoolean(); - ScenePhysicalOperationMode physicalOperationMode = (ScenePhysicalOperationMode)br.ReadByte(); - float gravityAcceleration = br.ReadSingle(); - int gravityNoize = br.ReadInt32(); - float gravityDirectionX = br.ReadSingle(); - float gravityDirectionY = br.ReadSingle(); - float gravityDirectionZ = br.ReadSingle(); - bool enableNoize = br.ReadBoolean(); + ScenePhysicalOperationMode physicalOperationMode = (ScenePhysicalOperationMode)br.ReadByte(); + float gravityAcceleration = br.ReadSingle(); + int gravityNoize = br.ReadInt32(); + float gravityDirectionX = br.ReadSingle(); + float gravityDirectionY = br.ReadSingle(); + float gravityDirectionZ = br.ReadSingle(); + bool enableNoize = br.ReadBoolean(); - // 47 bytes skipped - br.Accessor.Seek(47, SeekOrigin.Current); + // 47 bytes skipped + br.Accessor.Seek(47, SeekOrigin.Current); - int edgeLineColorR = br.ReadInt32(); - int edgeLineColorG = br.ReadInt32(); - int edgeLineColorB = br.ReadInt32(); + int edgeLineColorR = br.ReadInt32(); + int edgeLineColorG = br.ReadInt32(); + int edgeLineColorB = br.ReadInt32(); - short u = br.ReadInt16(); + short u = br.ReadInt16(); } protected override void SaveInternal(ObjectModel objectModel) { diff --git a/PHP/Manager/Include/Modules/001-Setup/TenantObjects/000-Script.inc.php b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/000-Script.inc.php new file mode 100644 index 00000000..e6c9607a --- /dev/null +++ b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/000-Script.inc.php @@ -0,0 +1,125 @@ +CreateObject("ScriptLanguage", + array + ( + new TenantStringTableEntry($langEnglish, "Script Language") + ), + array + ( + new TenantStringTableEntry($langEnglish, "A programming language used to write scripts.") + ), + array + ( + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("ContentType", DataType::GetByName("Text")) + )); + + $objClientScriptLanguage = $tenant->CreateObject("ClientScriptLanguage", + array + ( + new TenantStringTableEntry($langEnglish, "Client Script Language") + ), + array + ( + new TenantStringTableEntry($langEnglish, "A programming language used to write scripts to be run on the client.") + ), + array + ( + // property name, data type, default value, value required?, enumeration, require choice from enumeration? + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("ContentType", DataType::GetByName("Text")) + ), $objScriptLanguage, + array + ( + array + ( + new TenantObjectInstancePropertyValue("Name", "JavaScript"), + new TenantObjectInstancePropertyValue("ContentType", "text/javascript") + ), + array + ( + new TenantObjectInstancePropertyValue("Name", "VBScript"), + new TenantObjectInstancePropertyValue("ContentType", "text/vbscript") + ) + )); + $objServerScriptLanguage = $tenant->CreateObject("ServerScriptLanguage", + array + ( + new TenantStringTableEntry($langEnglish, "Server Script Language") + ), + array + ( + new TenantStringTableEntry($langEnglish, "A programming language used to write scripts to be run on the server.") + ), + array + ( + // property name, data type, default value, value required?, enumeration, require choice from enumeration? + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("ContentType", DataType::GetByName("Text")) + ), $objScriptLanguage, array + ( + array + ( + new TenantObjectInstancePropertyValue("Name", "PHP"), + new TenantObjectInstancePropertyValue("ContentType", "application/x-php") + ) + )); + + $objScript = $tenant->CreateObject("Script", + array + ( + new TenantStringTableEntry($langEnglish, "Script") + ), + array + ( + new TenantStringTableEntry($langEnglish, "A code blob that can be used in various scriptable areas.") + ), + array + ( + // property name, data type, default value, value required?, enumeration, require choice from enumeration? + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("Description", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("Language", DataType::GetByName("SingleInstance"), new SingleInstanceProperty(null, array($objScriptLanguage))), + new TenantObjectInstanceProperty("Content", DataType::GetByName("CodeBlob")) + )); + + $objClientScript = $tenant->CreateObject("ClientScript", + array + ( + new TenantStringTableEntry($langEnglish, "Client Script") + ), + array + ( + new TenantStringTableEntry($langEnglish, "A code blob that can be used in various scriptable areas on the client.") + ), + array + ( + // property name, data type, default value, value required?, enumeration, require choice from enumeration? + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("Description", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("Language", DataType::GetByName("SingleInstance"), new SingleInstanceProperty(null, array($objClientScriptLanguage))), + new TenantObjectInstanceProperty("Content", DataType::GetByName("CodeBlob")) + ), $objScript); + + $objServerScript = $tenant->CreateObject("ServerScript", "A code blob that can be used in various scriptable areas on the server.", array + ( + // property name, data type, default value, value required?, enumeration, require choice from enumeration? + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("Description", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("Language", DataType::GetByName("SingleInstance"), new SingleInstanceProperty(null, array($objServerScriptLanguage))), + new TenantObjectInstanceProperty("Content", DataType::GetByName("CodeBlob")) + ), $objScript); +?> \ No newline at end of file diff --git a/PHP/Manager/Include/Modules/001-Setup/TenantObjects/000-User.inc.php b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/000-User.inc.php new file mode 100644 index 00000000..e36b6847 --- /dev/null +++ b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/000-User.inc.php @@ -0,0 +1,155 @@ +CreateEnumeration("UserProfileVisibility", "Specifies the possible values for the ProfileVisibility property on the User object.", + array + ( + new TenantEnumerationChoice("Everyone", "Your profile is visible to everyone inside and outside the site."), + new TenantEnumerationChoice("Sitewide", "Your profile is visible only to other registered users."), + new TenantEnumerationChoice("FriendsExtended", "Your profile is visible to your friends and friends of your friends."), + new TenantEnumerationChoice("Friends", "Your profile is visible only to you and your friends."), + new TenantEnumerationChoice("Private", "Your profile is visible only to you.") + )); + + $enumUserPresenceStatus = $tenant->CreateEnumeration("UserPresenceStatus", "Specifies the possible values for the ProfileVisibility property on the User object.", + array + ( + new TenantEnumerationChoice("Offline", "You are not online."), + new TenantEnumerationChoice("Available", "You are available for other people to chat with."), + new TenantEnumerationChoice("Away", "You are away from your computer at the moment."), + new TenantEnumerationChoice("ExtendedAway", "You are going to be away for an extended period of time."), + new TenantEnumerationChoice("Busy", "You are busy and do not want to be bothered."), + new TenantEnumerationChoice("Hidden", "Your presence status is hidden.") + )); + + $object = $tenant->CreateObject("User", "Contains information about a Objectify user account.", array + ( + // property name, data type, default value, value required?, enumeration, require choice from enumeration? + new TenantObjectInstanceProperty("LoginID"), + new TenantObjectInstanceProperty("URL"), + new TenantObjectInstanceProperty("DisplayName"), + new TenantObjectInstanceProperty("EmailAddress"), + new TenantObjectInstanceProperty("EmailConfirmationCode"), + new TenantObjectInstanceProperty("BirthDate"), + new TenantObjectInstanceProperty("RealName"), + new TenantObjectInstanceProperty("PasswordHash"), + new TenantObjectInstanceProperty("PasswordSalt"), + new TenantObjectInstanceProperty("Theme"), + new TenantObjectInstanceProperty("Language"), + new TenantObjectInstanceProperty("ProfileVisibility", null, null, true, $enumUserProfileVisibility, true), + new TenantObjectInstanceProperty("ConsecutiveLoginCount"), + new TenantObjectInstanceProperty("ConsecutiveLoginFailures"), + new TenantObjectInstanceProperty("LastLoginTimestamp"), + new TenantObjectInstanceProperty("PresenceStatus", null, null, true, $enumUserPresenceStatus, true), + new TenantObjectInstanceProperty("PresenceMessage"), + new TenantObjectInstanceProperty("RegistrationTimestamp"), + new TenantObjectInstanceProperty("RegistrationIPAddress"), + new TenantObjectInstanceProperty("StartPage") + )); + + $object->CreateMethod("SaltPassword", array(), + + // code goes here... you cannot "use" namespaces here; please put them in NamespaceReferences!!! +<<<'EOD' +return \UUID::Generate(); +EOD +, "Generates a Objectify password salt using a Universally Unique Identifier (UUID)."); + + $object->CreateMethod("HashPassword", array + ( + new TenantObjectMethodParameter("input") + ), + + // code goes here... you cannot "use" namespaces here; please put them in NamespaceReferences!!! +<<<'EOD' +return hash("sha512", $input); +EOD +, "Generates a Objectify password hash using the SHA-512 algorithm."); + + $object->CreateMethod("ValidateCredentials", array + ( + new TenantObjectMethodParameter("username"), + new TenantObjectMethodParameter("password") + ), + + // code goes here... you cannot "use" namespaces here; please put them in NamespaceReferences!!! +<<<'EOD' +$tenant = Tenant::GetCurrent(); +$inst = $thisObject->GetInstance(array +( + new TenantQueryParameter("LoginID", $username) +)); + +// if there is no user with this LoginID, return null +if ($inst == null) return null; + +// get the password salt used in the creation of this instance +$salt = $inst->GetPropertyValue($thisObject->GetInstanceProperty("PasswordSalt")); + +// generate the salted password hash by concatenating the salt and the password +$pwhash = hash("sha512", $salt . $password); + +// try to get an instance with the specified login ID and password hash +$user = $thisObject->GetInstance(array +( + new TenantQueryParameter("LoginID", $username), + new TenantQueryParameter("PasswordHash", $pwhash) +)); + +return $user; +EOD +, "Validates the given user name and password against the database and returns an instance of the User if the validation is successful.", array +( + 'Objectify\Objects\Tenant', + 'Objectify\Objects\TenantObjectMethodParameterValue', + 'Objectify\Objects\TenantQueryParameter' +)); + + $object->CreateMethod("GetCurrentUser", array(), + + // code goes here... you cannot "use" namespaces here; please put them in NamespaceReferences!!! +<<<'EOD' +$tenant = Tenant::GetCurrent(); +if (!((isset($_SESSION["CurrentUserName[" . $tenant->ID . "]"])) && (isset($_SESSION["CurrentPassword[" . $tenant->ID . "]"])))) +{ + return null; +} + +$username = $_SESSION["CurrentUserName[" . $tenant->ID . "]"]; +$password = $_SESSION["CurrentPassword[" . $tenant->ID . "]"]; + +$inst = $thisObject->GetInstance(array +( + new TenantQueryParameter("LoginID", $username) +)); + +// if there is no user with this LoginID, return null +if ($inst == null) return null; + +// get the password salt used in the creation of this instance +$salt = $inst->GetPropertyValue($thisObject->GetInstanceProperty("PasswordSalt")); + +// generate the salted password hash by concatenating the salt and the password +$pwhash = hash("sha512", $salt . $password); + +// try to get an instance with the specified login ID and password hash +$user = $thisObject->GetInstance(array +( + new TenantQueryParameter("LoginID", $username), + new TenantQueryParameter("PasswordHash", $pwhash) +)); + +return $user; +EOD +, "Gets the user that is currently logged into Objectify.", array +( + // using statements go here + 'Objectify\Objects\Tenant', + 'Objectify\Objects\TenantQueryParameter' +)); + +?> \ No newline at end of file diff --git a/PHP/Manager/Include/Modules/001-Setup/TenantObjects/001-ResourceBundle.inc.php b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/001-ResourceBundle.inc.php new file mode 100644 index 00000000..9f7c6dfa --- /dev/null +++ b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/001-ResourceBundle.inc.php @@ -0,0 +1,35 @@ +CreateObject("ResourceObject", "Represents a single resource object (StyleSheet, Script, etc.) that is loaded in a ResourceBundle on the Objectify tenant.", array + ( + // property name, data type, default value, value required?, enumeration, require choice from enumeration? + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")) + )); + + $objStyleSheet = $tenant->CreateObject("StyleSheet", "Represents a style sheet resource object, containing a set of rules that determine how particular elements appear in a page.", array + ( + ), $objResourceObject); + + $objScriptResourceObject = $tenant->CreateObject("ScriptResourceObject", "Represents a script resource object, containing a single pointer to a ClientScript (executable code that can be run on the client).", array + ( + new TenantObjectInstanceProperty("ClientScript", DataType::GetByName("SingleInstance"), new SingleInstanceProperty(array(), array($objClientScript))) + ), $objResourceObject); + + $object = $tenant->CreateObject("ResourceBundle", "Contains a bundle of resources (StyleSheets, Scripts, etc.) that are loaded in with the Objectify tenant.", array + ( + // property name, data type, default value, value required?, enumeration, require choice from enumeration? + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")), + new TenantObjectInstanceProperty("ResourceObjects", DataType::GetByName("MultipleInstance"), new MultipleInstanceProperty(array(), array($objResourceObject))) + )); +?> \ No newline at end of file diff --git a/PHP/Manager/Include/Modules/001-Setup/TenantObjects/002-Page.inc.php b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/002-Page.inc.php new file mode 100644 index 00000000..c12265a9 --- /dev/null +++ b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/002-Page.inc.php @@ -0,0 +1,231 @@ +CreateObject("UserAgent", "A User Agent that can determine what browser or client the guest is using to access the Web site.", array + ( + new TenantObjectInstanceProperty("Name"), + new TenantObjectInstanceProperty("Value") + )); + $objUserAgentBehavior = $tenant->CreateObject("UserAgentBehavior", "The behavior to use when determining whether a list of user agents is allowed (whitelist) or denied (blacklist).", array + ( + new TenantObjectInstanceProperty("Name") + )); + + $propUserAgents = new TenantObjectInstanceProperty("UserAgents", DataType::GetByName("MultipleInstance"), new MultipleInstanceProperty(array(), array($objUserAgent))); + $propUserAgents->Description = "If one or more UserAgents are specified in this property, depending on the UserAgentBehavior this PageSection will display ONLY on these UserAgents."; + + $propUserAgentBehavior = new TenantObjectInstanceProperty("UserAgentBehavior", DataType::GetByName("SingleInstance"), new SingleInstanceProperty(array(), array($objUserAgentBehavior))); + + $objPageSection = $tenant->CreateObject("PageSection", "Represents a section of a Page on the tenant. Sections can be assigned to one or more Pages, and can be duplicated within the same Page.", array + ( + new TenantObjectInstanceProperty("Name"), + new TenantObjectInstanceProperty("Content"), + $propUserAgents, + $propUserAgentBehavior + )); + + $object = $tenant->CreateObject("Page", "Represents an individual Page on the tenant. Pages have URLs (such as ~/dashboard or ~/account/login) and host one or more PageSections.", array + ( + // property name, data type, default value, value required?, enumeration, require choice from enumeration? + new TenantObjectInstanceProperty("Name"), + new TenantObjectInstanceProperty("URL"), + new TenantObjectInstanceProperty("Sections", DataType::GetByName("MultipleInstance"), new MultipleInstanceProperty(array(), array($objPageSection))) + )); + + $instSectGuestMainPageDashboardPanel = $objPageSection->CreateInstance(array + ( + new TenantObjectInstancePropertyValue("Name", "GuestMainPageDashboardPanel"), + new TenantObjectInstancePropertyValue("Content", <<<'EOD' +GetObject("GuestMainPageDashboardPost"); + $posts = $objDashboardPost->GetInstances(); + + if (count($posts) == 0) + { +?> +
+
There's nothing here!
+
+ If you are the site administrator, please make sure you have configured your Objectify installation correctly. Log + in to your Administrator Control Panel to set up your installation and add content. +
+
+ + +EOD +) + )); + + $instSectGuestMainPageRegisterPanel = $objPageSection->CreateInstance(array + ( + new TenantObjectInstancePropertyValue("Name", "GuestMainPageRegisterPanel"), + new TenantObjectInstancePropertyValue("Content", <<<'EOD' + +
+
" method="POST" style="width: 100%;"> +
Don't have an account yet?
+
+

Sign up for free right now!

+
+ +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+EOD +) + )); + + $instSectGuestMainPageLoginPanel = $objPageSection->CreateInstance(array + ( + new TenantObjectInstancePropertyValue("Name", "GuestMainPageLoginPanel"), + new TenantObjectInstancePropertyValue("Content", <<<'EOD' + +
" method="POST" style="width: 100%;"> +
+
Already have an account?
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Log In +
+
+
+EOD +) + )); + + $instGuestMainPage = $object->CreateInstance(array + ( + new TenantObjectInstancePropertyValue("Name", "GuestMainPage"), + new TenantObjectInstancePropertyValue("Sections", new MultipleInstanceProperty + ( + array + ( + $instSectGuestMainPageDashboardPanel, + $instSectGuestMainPageLoginPanel, + $instSectGuestMainPageRegisterPanel + ), + array($objPageSection) + )) + )); + + $object->CreateInstanceMethod("GetSections", array(), + + // code goes here... you cannot "use" namespaces here; please put them in NamespaceReferences!!! +<<<'EOD' + $thisTenant = Tenant::GetCurrent(); + $objPageSection = $thisTenant->GetObject("PageSection"); + $insts = $objPageSection->GetInstances(array + ( + new TenantQueryParameter("Page", $thisInstance) + )); +EOD +, "Gets all of the PageSections associated with the current Page.", array( + "Tenant", + "TenantQueryParameter" +)); + +?> \ No newline at end of file diff --git a/PHP/Manager/Include/Modules/001-Setup/TenantObjects/003-DataFormat.inc.php b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/003-DataFormat.inc.php new file mode 100644 index 00000000..7b2dbb6f --- /dev/null +++ b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/003-DataFormat.inc.php @@ -0,0 +1,28 @@ +CreateObject("DataFormat", + array + ( + new TenantStringTableEntry($langEnglish, "Data Format") + ), + array + ( + new TenantStringTableEntry($langEnglish, "A format used to serialize and deserialize documents.") + ), + array + ( + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")) + )); +?> \ No newline at end of file diff --git a/PHP/Manager/Include/Modules/001-Setup/TenantObjects/003-ObjectModel.inc.php b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/003-ObjectModel.inc.php new file mode 100644 index 00000000..f0afefa9 --- /dev/null +++ b/PHP/Manager/Include/Modules/001-Setup/TenantObjects/003-ObjectModel.inc.php @@ -0,0 +1,28 @@ +CreateObject("ObjectModel", + array + ( + new TenantStringTableEntry($langEnglish, "Object Model") + ), + array + ( + new TenantStringTableEntry($langEnglish, "A model that provides the in-memory, DataFormat-agnostic representation of document data.") + ), + array + ( + new TenantObjectInstanceProperty("Name", DataType::GetByName("Text")) + )); +?> \ No newline at end of file