Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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()));
     }
 }
Exemplo n.º 3
0
 protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br)
 {
     if (br.GetRemainingLength() >= 4)
     {
         this.IKBones = Enumerable.Range(0, br.ReadInt32()).Select(_ => br.ReadInt32()).ToArray();
     }
 }
Exemplo n.º 4
0
 protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br)
 {
     if (br.GetRemainingLength() >= 4)
     {
         this.Parameters = Enumerable.Range(0, br.ReadInt32()).Select(_ => MvdEffectParameter.Parse(br)).ToList();
     }
 }
Exemplo n.º 5
0
        protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw)
        {
            bw.Write(this.StageCount);

            if (this.MinorType >= 2)
                bw.Write(this.ParentClipId);
        }
Exemplo n.º 6
0
 protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br)
 {
     if (br.GetRemainingLength() >= 4)
     {
         this.StageCount = br.ReadInt32();
     }
 }
Exemplo n.º 7
0
        public override void Write(MvdDocument document, BinaryWriter bw)
        {
            this.MinorType = 0;
            this.RawCount  = this.Frames.Count;

            base.Write(document, bw);
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        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;
        }
Exemplo n.º 10
0
        public override void Write(MvdDocument document, BinaryWriter bw)
        {
            this.MinorType = 0;
            this.RawCount = this.Frames.Count;

            base.Write(document, bw);
        }
Exemplo n.º 11
0
        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;
        }
Exemplo n.º 12
0
        protected override void Read(MvdDocument document, MvdObject obj, BinaryReader br)
        {
            // フォーマットバグ対策
            if (this.MinorType == 0)
                this.RawItemSize -= 4;

            base.Read(document, obj, br);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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();
        }
Exemplo n.º 15
0
        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();
        }
Exemplo n.º 16
0
        protected override void Read(MvdDocument document, BinaryReader br)
        {
            // フォーマットバグ対策
            if (this.MinorType == 1)
                this.RawItemSize += 4;

            base.Read(document, br);
        }
Exemplo n.º 17
0
 protected override void BeforeWriteHeader(MvdDocument document, BinaryWriter bw)
 {
     // フォーマットバグ対策
     if (this.MinorType == 1)
     {
         this.RawItemSize -= 4;
     }
 }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        protected override void Read(MvdDocument document, BinaryReader br)
        {
            // フォーマットバグ対策
            if (this.MinorType == 1)
            {
                this.RawItemSize += 4;
            }

            base.Read(document, br);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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);
            }
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
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);
            }
        }
Exemplo n.º 24
0
        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());
            }
        }
Exemplo n.º 25
0
        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);
            }
        }
Exemplo n.º 26
0
        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);
            }
        }
Exemplo n.º 27
0
        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;
        }
Exemplo n.º 28
0
        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;
        }
Exemplo n.º 29
0
 protected override void ReadItem(MvdDocument document, MvdObject obj, BinaryReader br)
 {
     this.Frames.Add(MvdAccessoryPropertyFrame.Parse(br));
 }
Exemplo n.º 30
0
 protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw)
 {
     bw.Write(this.Parameters.Count);
     this.Parameters.ForEach(_ => _.Write(bw));
 }
Exemplo n.º 31
0
 protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw)
 {
     bw.Write(this.ToneCurveControlPointCount);
 }
Exemplo n.º 32
0
 protected override void ReadExtensionRegion(MvdDocument document, MvdObject obj, BinaryReader br)
 {
     this.ToneCurveControlPointCount = br.ReadInt32();
 }
Exemplo n.º 33
0
 protected override void ReadItem(MvdDocument document, BinaryReader br)
 {
     this.Frames.Add(MvdAccessoryPropertyFrame.Parse(br));
 }
Exemplo n.º 34
0
 protected virtual void ReadExtensionRegion(MvdDocument document, BinaryReader br)
 {
 }
Exemplo n.º 35
0
 protected override void ReadItem(MvdDocument document, MvdObject obj, BinaryReader br)
 {
     this.MotionBlendLink = MvdMotionBlendLink.Parse(br);
 }
Exemplo n.º 36
0
 protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw)
 {
     bw.Write(this.StageCount);
 }
Exemplo n.º 37
0
        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);
        }
Exemplo n.º 38
0
 protected virtual void BeforeWriteHeader(MvdDocument document, BinaryWriter bw)
 {
 }
Exemplo n.º 39
0
 protected override void ReadItem(MvdDocument document, MvdObject obj, BinaryReader br)
 {
     this.Frames.Add(MvdLightFrame.Parse(br));
 }
Exemplo n.º 40
0
 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()));
 }
Exemplo n.º 41
0
 protected override void WriteItem(MvdDocument document, BinaryWriter bw, int index)
 {
     this.MotionBlendLink.Write(bw);
 }
Exemplo n.º 42
0
 protected override void ReadItem(MvdDocument document, BinaryReader br)
 {
     this.Frames.Add(MvdCameraFrame.Parse(br));
 }
Exemplo n.º 43
0
 protected override void ReadItem(MvdDocument document, BinaryReader br)
 {
     this.Frames.Add(MvdEffectPropertyFrame.Parse(this, br));
 }
Exemplo n.º 44
0
 protected override void BeforeWriteHeader(MvdDocument document, BinaryWriter bw)
 {
     // フォーマットバグ対策
     if (this.MinorType == 1)
         this.RawItemSize -= 4;
 }
Exemplo n.º 45
0
 protected abstract void Read(MvdDocument document, BinaryReader br);
Exemplo n.º 46
0
 protected override void WriteItem(MvdDocument document, BinaryWriter bw, int index)
 {
     this.Frames[index].Write(bw);
 }
Exemplo n.º 47
0
 protected virtual void WriteExtensionRegion(MvdDocument document, BinaryWriter bw)
 {
 }
Exemplo n.º 48
0
 protected override void ReadExtensionRegion(MvdDocument document, MvdObject obj, BinaryReader br)
 {
     this.ParentClipId = br.ReadInt32();
 }
Exemplo n.º 49
0
 protected override void ReadExtensionRegion(MvdDocument document, BinaryReader br)
 {
     if (br.GetRemainingLength() >= 4)
         this.IKBones = Enumerable.Range(0, br.ReadInt32()).Select(_ => br.ReadInt32()).ToArray();
 }
Exemplo n.º 50
0
 protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw)
 {
     bw.Write(this.ParentClipId);
 }
Exemplo n.º 51
0
 protected override void ReadItem(MvdDocument document, BinaryReader br)
 {
     this.Frames.Add(MvdModelPropertyFrame.Parse(this, br));
 }
Exemplo n.º 52
0
 protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw)
 {
     bw.Write(this.IKBones.Length);
     this.IKBones.ForEach(bw.Write);
 }
Exemplo n.º 53
0
 protected override void WriteExtensionRegion(MvdDocument document, BinaryWriter bw)
 {
     bw.Write(this.IKBones.Length);
     this.IKBones.ForEach(bw.Write);
 }
Exemplo n.º 54
0
 protected override void WriteItem(MvdDocument document, BinaryWriter bw, int index)
 {
     this.Frames[index].Write(bw);
 }
Exemplo n.º 55
0
 protected abstract void WriteItem(MvdDocument document, BinaryWriter bw, int index);