public override void Write(MvdDocument document, BinaryWriter bw) { if (this.RawCount > 0) { using (var ms = new MemoryStream()) using (var iw = new BinaryWriter(ms)) { // write the first item to the temp buffer to get the item's size WriteItem(document, iw, 0); this.RawItemSize = (int)ms.Length; // then, write the headers to the real buffer BeforeWriteHeader(document, bw); base.Write(document, bw); // and then, copy the first item's temp buffer to the real one. bw.Write(ms.ToArray()); } for (int i = 1; i < this.RawCount; i++) WriteItem(document, bw, i); } else base.Write(document, bw); }
protected override void Read(MvdDocument document, BinaryReader br) { for (int i = 0; i < this.RawCount; i++) { this.Names.Add(br.ReadInt32(), document.Encoding.GetString(br.ReadSizedBuffer())); } }
protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br) { if (br.GetRemainingLength() >= 4) { this.IKBones = Enumerable.Range(0, br.ReadInt32()).Select(_ => br.ReadInt32()).ToArray(); } }
protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br) { if (br.GetRemainingLength() >= 4) { this.Parameters = Enumerable.Range(0, br.ReadInt32()).Select(_ => MvdEffectParameter.Parse(br)).ToList(); } }
protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw) { bw.Write(this.StageCount); if (this.MinorType >= 2) bw.Write(this.ParentClipId); }
protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br) { if (br.GetRemainingLength() >= 4) { this.StageCount = br.ReadInt32(); } }
public override void Write(MvdDocument document, BinaryWriter bw) { this.MinorType = 0; this.RawCount = this.Frames.Count; base.Write(document, bw); }
public override void Write(MvdDocument document, BinaryWriter bw) { if (this.RawCount > 0) { using (var ms = new MemoryStream()) using (var iw = new BinaryWriter(ms)) { // write the first item to the temp buffer to get the item's size WriteItem(document, iw, 0); this.RawItemSize = (int)ms.Length; // then, write the headers to the real buffer BeforeWriteHeader(document, bw); base.Write(document, bw); // and then, copy the first item's temp buffer to the real one. bw.Write(ms.ToArray()); } for (int i = 1; i < this.RawCount; i++) { WriteItem(document, bw, i); } } else { base.Write(document, bw); } }
public static MvdDocument Parse(Stream stream) { var rt = new MvdDocument(); var systemEncoding = Encoding.GetEncoding(932); // leave open var br = new BinaryReader(stream); var header = ReadMvdString(br, 30, systemEncoding); if (header != DisplayName) throw new InvalidOperationException("invalid format"); rt.Version = br.ReadSingle(); if (rt.Version >= 2) throw new NotSupportedException("specified format version not supported"); switch (br.ReadByte()) { case 0: rt.Encoding = Encoding.Unicode; break; case 1: default: rt.Encoding = Encoding.UTF8; break; } while (br.GetRemainingLength() > 1) rt.Objects.Add(MvdObject.Parse(rt, br)); return rt; }
public static MvdSection Parse(MvdDocument document, BinaryReader br) { var tag = (MvdTag)br.ReadByte(); MvdSection rt = null; switch (tag) { case MvdTag.NameList: rt = new MvdNameList(); break; case MvdTag.Bone: rt = new MvdBoneData(); break; case MvdTag.Morph: rt = new MvdMorphData(); break; case MvdTag.ModelProperty: rt = new MvdModelPropertyData(); break; case MvdTag.AccessoryProperty: rt = new MvdAccessoryPropertyData(); break; case MvdTag.EffectProperty: rt = new MvdEffectPropertyData(); break; case MvdTag.Camera: rt = new MvdCameraData(); break; case MvdTag.Light: rt = new MvdLightData(); break; case MvdTag.Project: rt = new MvdProjectData(); break; case MvdTag.Eof: return null; } rt.MinorType = br.ReadByte(); rt.RawKey = br.ReadInt32(); rt.RawItemSize = br.ReadInt32(); rt.RawCount = br.ReadInt32(); using (var exr = br.CreateSizedBufferReader()) rt.ReadExtensionRegion(document, exr); rt.Read(document, br); return rt; }
protected override void Read(MvdDocument document, MvdObject obj, BinaryReader br) { // フォーマットバグ対策 if (this.MinorType == 0) this.RawItemSize -= 4; base.Read(document, obj, br); }
protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw) { bw.Write(this.IKBones.Length); this.IKBones.ForEach(bw.Write); if (this.MinorType >= 3) bw.Write(this.ModelRelationCount); }
protected override void ReadExtensionRegion(MvdDocument document, MvdObject obj, BinaryReader br) { if (br.GetRemainingLength() >= 4) this.IKBones = Enumerable.Range(0, br.ReadInt32()).Select(_ => br.ReadInt32()).ToArray(); if (this.MinorType >= 3) this.ModelRelationCount = br.ReadInt32(); }
protected override void ReadExtensionRegion(MvdDocument document, MvdObject obj, BinaryReader br) { if (br.GetRemainingLength() >= 4) this.StageCount = br.ReadInt32(); if (this.MinorType >= 2) this.ParentClipId = br.ReadInt32(); }
protected override void Read(MvdDocument document, BinaryReader br) { // フォーマットバグ対策 if (this.MinorType == 1) this.RawItemSize += 4; base.Read(document, br); }
protected override void BeforeWriteHeader(MvdDocument document, BinaryWriter bw) { // フォーマットバグ対策 if (this.MinorType == 1) { this.RawItemSize -= 4; } }
protected override void Read(MvdDocument document, MvdObject obj, BinaryReader br) { if (this.RawItemSize <= 0) throw new InvalidOperationException("RawItemSize must be greater than 0."); for (int i = 0; i < this.RawCount; i++) using (var ir = new BinaryReader(new MemoryStream(br.ReadBytes(this.RawItemSize)))) ReadItem(document, obj, ir); }
protected override void Read(MvdDocument document, BinaryReader br) { // フォーマットバグ対策 if (this.MinorType == 1) { this.RawItemSize += 4; } base.Read(document, br); }
public static MvdDocument Parse(Stream stream) { var rt = new MvdDocument(); var systemEncoding = Encoding.GetEncoding(932); // leave open var br = new BinaryReader(stream); var header = ReadMvdString(br, 30, systemEncoding); if (header != DisplayName) { throw new InvalidOperationException("invalid format"); } rt.Version = br.ReadSingle(); if (rt.Version >= 2) { throw new NotSupportedException("specified format version not supported"); } switch (br.ReadByte()) { case 0: rt.Encoding = Encoding.Unicode; break; case 1: default: rt.Encoding = Encoding.UTF8; break; } rt.ObjectName = rt.Encoding.GetString(br.ReadSizedBuffer()); br.ReadSizedBuffer(); // objectNameSize2 / objectName2 rt.KeyFps = br.ReadSingle(); br.ReadSizedBuffer(); // reservedSize / reserved while (br.GetRemainingLength() > 1) { var section = MvdSection.Parse(rt, br); if (section == null) { break; } rt.Sections.Add(section); } return(rt); }
protected override void Read(MvdDocument document, BinaryReader br) { if (this.RawItemSize <= 0) { throw new InvalidOperationException("RawItemSize must be greater than 0."); } for (int i = 0; i < this.RawCount; i++) { using (var ir = new BinaryReader(new MemoryStream(br.ReadBytes(this.RawItemSize)))) ReadItem(document, ir); } }
public void Write(MvdDocument document, BinaryWriter bw) { bw.WriteSizedBuffer(document.Encoding.GetBytes(this.ObjectName)); bw.WriteSizedBuffer(document.Encoding.GetBytes(this.EnglishObjectName)); bw.Write(this.KeyFps); bw.WriteSizedBuffer(new byte[0]); foreach (var i in this.Sections) i.Write(document, bw); bw.Write((byte)MvdTag.Eof); bw.Write((byte)0); }
protected override void ReadItem(MvdDocument document, MvdObject obj, BinaryReader br) { MvdCameraPropertyFrame cpf; this.Frames.Add(MvdCameraFrame.Parse(this, br, out cpf)); if (cpf != null) { var cpd = obj.Sections.OfType<MvdCameraPropertyData>().FirstOrDefault(); if (cpd == null) obj.Sections.Add(cpd = new MvdCameraPropertyData()); cpd.Frames.Add(cpf); } }
public virtual void Write(MvdDocument document, BinaryWriter bw) { bw.Write((byte)this.Tag); bw.Write(this.MinorType); bw.Write(this.RawKey); bw.Write(this.RawItemSize); bw.Write(this.RawCount); using (var ms = new MemoryStream()) { using (var exw = new BinaryWriter(ms)) WriteExtensionRegion(document, exw); bw.WriteSizedBuffer(ms.ToArray()); } }
public override void Write(MvdDocument document, BinaryWriter bw) { this.MinorType = 0; this.RawCount = this.Names.Count; base.Write(document, bw); foreach (var i in this.Names) { var buf = document.Encoding.GetBytes(i.Value); bw.Write(i.Key); bw.Write(buf.Length); bw.Write(buf); } }
public static MvdDocument Parse(Stream stream) { var rt = new MvdDocument(); var systemEncoding = Encoding.GetEncoding(932); // leave open var br = new BinaryReader(stream); var header = ReadMvdString(br, 30, systemEncoding); if (header != DisplayName) throw new InvalidOperationException("invalid format"); rt.Version = br.ReadSingle(); if (rt.Version >= 2) throw new NotSupportedException("specified format version not supported"); switch (br.ReadByte()) { case 0: rt.Encoding = Encoding.Unicode; break; case 1: default: rt.Encoding = Encoding.UTF8; break; } rt.ObjectName = rt.Encoding.GetString(br.ReadSizedBuffer()); br.ReadSizedBuffer(); // objectNameSize2 / objectName2 rt.KeyFps = br.ReadSingle(); br.ReadSizedBuffer(); // reservedSize / reserved while (br.GetRemainingLength() > 1) { var section = MvdSection.Parse(rt, br); if (section == null) break; rt.Sections.Add(section); } return rt; }
public static MvdObject Parse(MvdDocument document, BinaryReader br) { var rt = new MvdObject(); rt.ObjectName = document.Encoding.GetString(br.ReadSizedBuffer()); rt.EnglishObjectName = document.Encoding.GetString(br.ReadSizedBuffer()); rt.KeyFps = br.ReadSingle(); br.ReadSizedBuffer(); // reservedSize / reserved while (br.GetRemainingLength() > 1) { var section = MvdSection.Parse(document, rt, br); if (section == null) break; rt.Sections.Add(section); } return rt; }
protected override void ReadItem(MvdDocument document, MvdObject obj, BinaryReader br) { this.Frames.Add(MvdAccessoryPropertyFrame.Parse(br)); }
protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw) { bw.Write(this.Parameters.Count); this.Parameters.ForEach(_ => _.Write(bw)); }
protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw) { bw.Write(this.ToneCurveControlPointCount); }
protected override void ReadExtensionRegion(MvdDocument document, MvdObject obj, BinaryReader br) { this.ToneCurveControlPointCount = br.ReadInt32(); }
protected override void ReadItem(MvdDocument document, BinaryReader br) { this.Frames.Add(MvdAccessoryPropertyFrame.Parse(br)); }
protected virtual void ReadExtensionRegion(MvdDocument document, BinaryReader br) { }
protected override void ReadItem(MvdDocument document, MvdObject obj, BinaryReader br) { this.MotionBlendLink = MvdMotionBlendLink.Parse(br); }
protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw) { bw.Write(this.StageCount); }
public static MvdSection Parse(MvdDocument document, BinaryReader br) { var tag = (MvdTag)br.ReadByte(); MvdSection rt = null; switch (tag) { case MvdTag.NameList: rt = new MvdNameList(); break; case MvdTag.Bone: rt = new MvdBoneData(); break; case MvdTag.Morph: rt = new MvdMorphData(); break; case MvdTag.ModelProperty: rt = new MvdModelPropertyData(); break; case MvdTag.AccessoryProperty: rt = new MvdAccessoryPropertyData(); break; case MvdTag.EffectProperty: rt = new MvdEffectPropertyData(); break; case MvdTag.Camera: rt = new MvdCameraData(); break; case MvdTag.Light: rt = new MvdLightData(); break; case MvdTag.Project: rt = new MvdProjectData(); break; case MvdTag.Eof: return(null); } rt.MinorType = br.ReadByte(); rt.RawKey = br.ReadInt32(); rt.RawItemSize = br.ReadInt32(); rt.RawCount = br.ReadInt32(); using (var exr = br.CreateSizedBufferReader()) rt.ReadExtensionRegion(document, exr); rt.Read(document, br); return(rt); }
protected virtual void BeforeWriteHeader(MvdDocument document, BinaryWriter bw) { }
protected override void ReadItem(MvdDocument document, MvdObject obj, BinaryReader br) { this.Frames.Add(MvdLightFrame.Parse(br)); }
protected override void Read(MvdDocument document, MvdObject obj, BinaryReader br) { for (int i = 0; i < this.RawCount; i++) this.Names.Add(br.ReadInt32(), document.Encoding.GetString(br.ReadSizedBuffer())); }
protected override void WriteItem(MvdDocument document, BinaryWriter bw, int index) { this.MotionBlendLink.Write(bw); }
protected override void ReadItem(MvdDocument document, BinaryReader br) { this.Frames.Add(MvdCameraFrame.Parse(br)); }
protected override void ReadItem(MvdDocument document, BinaryReader br) { this.Frames.Add(MvdEffectPropertyFrame.Parse(this, br)); }
protected override void BeforeWriteHeader(MvdDocument document, BinaryWriter bw) { // フォーマットバグ対策 if (this.MinorType == 1) this.RawItemSize -= 4; }
protected abstract void Read(MvdDocument document, BinaryReader br);
protected override void WriteItem(MvdDocument document, BinaryWriter bw, int index) { this.Frames[index].Write(bw); }
protected virtual void WriteExtensionRegion(MvdDocument document, BinaryWriter bw) { }
protected override void ReadExtensionRegion(MvdDocument document, MvdObject obj, BinaryReader br) { this.ParentClipId = br.ReadInt32(); }
protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br) { if (br.GetRemainingLength() >= 4) this.IKBones = Enumerable.Range(0, br.ReadInt32()).Select(_ => br.ReadInt32()).ToArray(); }
protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw) { bw.Write(this.ParentClipId); }
protected override void ReadItem(MvdDocument document, BinaryReader br) { this.Frames.Add(MvdModelPropertyFrame.Parse(this, br)); }
protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw) { bw.Write(this.IKBones.Length); this.IKBones.ForEach(bw.Write); }
protected abstract void WriteItem(MvdDocument document, BinaryWriter bw, int index);