Updated Associations

This commit is contained in:
Michael Becker 2014-12-16 23:11:51 -05:00
parent d34e99c9cc
commit 749a3c096b
34 changed files with 1456 additions and 604 deletions

View File

@ -5,7 +5,7 @@
<Filters>
<Filter Title="DOOM WAD archive">
<FileNameFilters>
<FileNameFilter>*.gd</FileNameFilter>
<FileNameFilter>*.wad</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="id software / Quake engine MD2 model">
<FileNameFilters>
<FileNameFilter>*.md2</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">IDP2</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Quake.MD2DataFormat" />
</DataFormats>
</Association>
<Association>
<Filters>
<Filter Title="id software / Quake engine MD3 model">
<FileNameFilters>
<FileNameFilter>*.md3</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">IDP3</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Quake.MD3DataFormat" />
</DataFormats>
</Association>
<Association>
<Filters>
<Filter Title="id software / Quake engine Ghoul2 model">
<FileNameFilters>
<FileNameFilter>*.glm</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">2LGM</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Quake.GLMDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Binary Space Partitioned 3D scene">
<FileNameFilters>
<FileNameFilter>*.bsp</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">IBSP</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Scene.SceneObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Quake.BSP.BSPMapDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Polygon Movie Maker accessory file">
<FileNameFilters>
<FileNameFilter>*.vac</FileNameFilter>
</FileNameFilters>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Accessory.AccessoryObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Accessory.PolygonMovieMaker.VACAccessoryDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Blender scene">
<FileNameFilters>
<FileNameFilter>*.blend</FileNameFilter>
</FileNameFilters>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Blender.BlenderDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Metasequoia model">
<FileNameFilters>
<FileNameFilter>*.mqo</FileNameFilter>
</FileNameFilters>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Metasequoia.MQOTextDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="3D Studio MAX model">
<FileNameFilters>
<FileNameFilter>*.max</FileNameFilter>
</FileNameFilters>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.ThreeDStudio.ThreeDSMaxDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Wavefront OBJect model">
<FileNameFilters>
<FileNameFilter>*.obj</FileNameFilter>
</FileNameFilters>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Wavefront.OBJDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="MikuMikuDance v1.30 motion data">
<FileNameFilters>
<FileNameFilter>*.vmd</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">Vocaloid Motion Data file</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
<Filter Title="Polygon Movie Maker motion data">
<FileNameFilters>
<FileNameFilter>*.vmd</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">Vocaloid Motion Data 0002</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Motion.MotionObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Motion.PolygonMovieMaker.VMDMotionDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Polygon Movie Maker pose data">
<FileNameFilters>
<FileNameFilter>*.vpd</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">Vocaloid Pose Data file</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Scene.SceneObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Pose.PolygonMovieMaker.VPDPoseDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="CINEMA 4D scene">
<FileNameFilters>
<FileNameFilter>*.c4d</FileNameFilter>
</FileNameFilters>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Cinema4D.Cinema4DDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Polygon Movie Maker single-model scene">
<FileNameFilters>
<FileNameFilter>*.mmd</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">Polygon Movie maker 0001</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
<Filter Title="Polygon Movie Maker multi-model scene">
<FileNameFilters>
<FileNameFilter>*.pmm</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">Polygon Movie maker 0001</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Scene.SceneObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Scene.PolygonMovieMaker.PMMSceneDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -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]);
}
}
}
}

View File

@ -36,7 +36,6 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataFormats\BurikoARCDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\AlienNations\GD\GDDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\ALTools\ALZ\ALZDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\ALTools\EGG\ALZipCompressionMethod.cs" />

View File

@ -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)
{

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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.#"));

View File

@ -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)

View File

@ -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<int> arySurfaceHierarchyOffsets = new System.Collections.Generic.List<int>();
for (int i = 0; i < numSurfaces; i++)
{
int surfaceHierarchyOffset = br.ReadInt32();
arySurfaceHierarchyOffsets.Add(surfaceHierarchyOffset);
}
System.Collections.Generic.List<int> arySurfaceHierarchyOffsets = new System.Collections.Generic.List<int>();
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<int> aryChildIndices = new System.Collections.Generic.List<int>();
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<int> aryChildIndices = new System.Collections.Generic.List<int>();
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<float[]> triangleIndices = new List<float[]>();
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<float[]> triangleIndices = new List<float[]>();
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();
}

View File

@ -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();

View File

@ -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<int[]> triangleIndices = new List<int[]>();
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<int[]> triangleIndices = new List<int[]>();
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<int, ModelStringTableExtension> 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<int, ModelStringTableExtension> kvp in model.StringTable)
{
modelTitle = kvp.Value.Title;
break;
}
}
bw.WriteNullTerminatedString(modelTitle, 64);
bw.Flush();
}

View File

@ -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();
}
}

View File

@ -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;
}
}
}

View File

@ -9,13 +9,15 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Motion.PolygonMovieMaker
/// </summary>
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; } }

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -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)
{

View File

@ -0,0 +1,125 @@
<?php
use Objectify\Objects\DataType;
use Objectify\Objects\MultipleInstanceProperty;
use Objectify\Objects\SingleInstanceProperty;
use Objectify\Objects\TenantObjectProperty;
use Objectify\Objects\TenantObjectInstanceProperty;
use Objectify\Objects\TenantObjectInstancePropertyValue;
use Objectify\Objects\TenantObjectMethodParameter;
use Objectify\Objects\TenantStringTableEntry;
use Objectify\Objects\TenantEnumerationChoice;
$objScriptLanguage = $tenant->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);
?>

View File

@ -0,0 +1,155 @@
<?php
use Objectify\Objects\TenantObjectProperty;
use Objectify\Objects\TenantObjectInstanceProperty;
use Objectify\Objects\TenantObjectMethodParameter;
use Objectify\Objects\TenantEnumerationChoice;
$enumUserProfileVisibility = $tenant->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'
));
?>

View File

@ -0,0 +1,35 @@
<?php
use Objectify\Objects\DataType;
use Objectify\Objects\MultipleInstanceProperty;
use Objectify\Objects\SingleInstanceProperty;
use Objectify\Objects\TenantObjectProperty;
use Objectify\Objects\TenantObjectInstanceProperty;
use Objectify\Objects\TenantObjectInstancePropertyValue;
use Objectify\Objects\TenantObjectMethodParameter;
use Objectify\Objects\TenantEnumerationChoice;
$objResourceObject = $tenant->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)))
));
?>

View File

@ -0,0 +1,231 @@
<?php
use Objectify\Objects\DataType;
use Objectify\Objects\MultipleInstanceProperty;
use Objectify\Objects\SingleInstanceProperty;
use Objectify\Objects\TenantObjectProperty;
use Objectify\Objects\TenantObjectInstanceProperty;
use Objectify\Objects\TenantObjectInstancePropertyValue;
use Objectify\Objects\TenantObjectMethodParameter;
$objUserAgent = $tenant->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'
<?php
use Objectify\Objects\Tenant;
// get the dashboard posts
$tenant = Tenant::GetCurrent();
$objDashboardPost = $tenant->GetObject("GuestMainPageDashboardPost");
$posts = $objDashboardPost->GetInstances();
if (count($posts) == 0)
{
?>
<div class="Card">
<div class="Title">There's nothing here!</div>
<div class="Content">
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.
</div>
</div>
<?php
}
else
{
foreach ($posts as $post)
{
print_r($post);
echo("\n\n");
}
?>
<?php
}
?>
EOD
)
));
$instSectGuestMainPageRegisterPanel = $objPageSection->CreateInstance(array
(
new TenantObjectInstancePropertyValue("Name", "GuestMainPageRegisterPanel"),
new TenantObjectInstancePropertyValue("Content", <<<'EOD'
<?php
use WebFX\System;
?>
<div class="Card">
<form id="frmRegisterDefault" action="<?php echo(System::ExpandRelativePath("~/account/register.page")); ?>" method="POST" style="width: 100%;">
<div class="Title">Don't have an account yet?</div>
<div class="Content">
<h1>Sign up for free right now!</h1>
<div class="Form">
<?php
// Fields required by Objectify (login ID, password, display name, and URL name) come first. After the user
// provides the initial required information, you may follow up with custom Objectify sign-up pages.
?>
<div class="FormItemGroup" style="display: table-row">
<?php
if (System::GetConfigurationValue("Security.Credentials.UserLoginIDIsEmailAddress") == "true")
{
?>
<div class="FormItem" style="display: table-cell">
<div class="FormItemTitle"><label for="txtEmailAddress">E-mail address:</label></div>
<div class="FormItemEntry"><input type="text" id="txtEmailAddress" placeholder="phenix@example.com" /></div>
</div>
<?php
}
else
{
?>
<div class="FormItem" style="display: table-cell">
<div class="FormItemTitle"><label for="txtUserName">Private login ID:</label></div>
<div class="FormItemEntry"><input type="text" id="txtUserName" name="un" placeholder="ph3n1xxx" /></div>
</div>
<?php
}
?>
</div>
<div class="FormItemGroup" style="display: table-row">
<div class="FormItem" style="display: table-cell">
<div class="FormItemTitle"><label for="txtPassword">Private password:</label></div>
<div class="FormItemEntry"><input type="password" id="txtPassword" name="pw" placeholder="S0me*Sup3r/SecRET_passWord!" /></div>
</div>
<div class="FormItem" style="display: table-cell">
<div class="FormItemTitle"><label for="txtPasswordConfirm">Confirm password:</label></div>
<div class="FormItemEntry"><input type="password" id="txtPasswordConfirm" name="pwc" placeholder="" /></div>
</div>
</div>
<div class="FormItemGroup" style="display: table-row">
<div class="FormItem" style="display: table-cell">
<div class="FormItemTitle"><label for="txtDisplayName">Display name:</label></div>
<div class="FormItemEntry"><input type="text" id="txtDisplayName" name="ln" placeholder="Phenix the Great" /></div>
</div>
</div>
<div class="FormItemGroup" style="display: table-row">
<div class="FormItem" style="display: table-cell">
<div class="FormItemTitle"><label for="txtShortURLName">Short URL name:</label></div>
<div class="FormItemEntry"><input type="text" id="txtShortURLName" name="sn" placeholder="phenix" /></div>
</div>
</div>
</div>
</div>
<div class="Actions Horizontal">
<a href="#" onclick="document.getElementById('frmRegisterDefault').submit(); return false;">Register my account</a>
</div>
</form>
</div>
EOD
)
));
$instSectGuestMainPageLoginPanel = $objPageSection->CreateInstance(array
(
new TenantObjectInstancePropertyValue("Name", "GuestMainPageLoginPanel"),
new TenantObjectInstancePropertyValue("Content", <<<'EOD'
<?php
use WebFX\System;
?>
<form id="frmLoginDefault" action="<?php echo(System::ExpandRelativePath("~/account/login.page")); ?>" method="POST" style="width: 100%;">
<div class="Card">
<div class="Title">Already have an account?</div>
<div class="Content">
<div class="FormItemGroup" style="display: table-row">
<?php
if (System::GetConfigurationValue("Security.Credentials.UserLoginIDIsEmailAddress") == "true")
{
?>
<div class="FormItem" style="display: table-cell">
<div class="FormItemEntry"><input type="text" name="member_email" id="txtLoginEmailAddress" placeholder="E-mail address" /></div>
</div>
<?php
}
else
{
?>
<div class="FormItem" style="display: table-cell">
<div class="FormItemEntry"><input type="text" name="member_username" id="txtLoginUserName" placeholder="Private login ID" /></div>
</div>
<?php
}
?>
</div>
<div class="FormItemGroup" style="display: table-row">
<div class="FormItem" style="display: table-cell">
<div class="FormItemEntry"><input type="password" name="member_password" id="txtLoginPassword" placeholder="Password" /></div>
</div>
</div>
</div>
<div class="Actions Horizontal">
<a href="#" onclick="document.getElementById('frmLoginDefault').submit(); return false;">Log In</a>
</div>
</div>
</form>
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"
));
?>

View File

@ -0,0 +1,28 @@
<?php
use Objectify\Objects\DataType;
use Objectify\Objects\MultipleInstanceProperty;
use Objectify\Objects\SingleInstanceProperty;
use Objectify\Objects\TenantObjectProperty;
use Objectify\Objects\TenantObjectInstanceProperty;
use Objectify\Objects\TenantObjectInstancePropertyValue;
use Objectify\Objects\TenantObjectMethodParameter;
use Objectify\Objects\TenantStringTableEntry;
use Objectify\Objects\TenantEnumerationChoice;
$tenant->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"))
));
?>

View File

@ -0,0 +1,28 @@
<?php
use Objectify\Objects\DataType;
use Objectify\Objects\MultipleInstanceProperty;
use Objectify\Objects\SingleInstanceProperty;
use Objectify\Objects\TenantObjectProperty;
use Objectify\Objects\TenantObjectInstanceProperty;
use Objectify\Objects\TenantObjectInstancePropertyValue;
use Objectify\Objects\TenantObjectMethodParameter;
use Objectify\Objects\TenantStringTableEntry;
use Objectify\Objects\TenantEnumerationChoice;
$tenant->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"))
));
?>