Exemple #1
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;
        }
Exemple #2
0
        public string GetName(MvdNameList names, MvdBoneData boneData)
        {
            if (this.StageId == 0)
            {
                return(names.Names[boneData.Key]);
            }
            else
            {
                var key = boneData.Key * -1000 - this.StageId;

                return(names.Names.ContainsKey(key)
                                        ? names.Names[key]
                                        : this.StageId.ToString("000"));
            }
        }
Exemple #3
0
        public static MvdBoneFrame Parse(MvdBoneData bd, BinaryReader br)
        {
            var rt = new MvdBoneFrame
            {
                StageId = br.ReadInt32(),
                FrameTime = br.ReadInt64(),
                Position = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle() },
                Quaternion = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle() },
                XInterpolation = new[] { MvdInterpolationPoint.Parse(br), MvdInterpolationPoint.Parse(br) },
                YInterpolation = new[] { MvdInterpolationPoint.Parse(br), MvdInterpolationPoint.Parse(br) },
                ZInterpolation = new[] { MvdInterpolationPoint.Parse(br), MvdInterpolationPoint.Parse(br) },
                RotationInterpolation = new[] { MvdInterpolationPoint.Parse(br), MvdInterpolationPoint.Parse(br) },
            };

            if (bd.MinorType >= 1)
            {
                rt.Spline = br.ReadBoolean();
                br.ReadBytes(3);
            }

            return rt;
        }
Exemple #4
0
        public string GetName(MvdNameList names, MvdBoneData boneData)
        {
            if (this.StageId == 0)
                return names.Names[boneData.Key];
            else
            {
                var key = boneData.Key * -1000 - this.StageId;

                return names.Names.ContainsKey(key)
                    ? names.Names[key]
                    : this.StageId.ToString("000");
            }
        }
Exemple #5
0
        public void Write(MvdBoneData bd, BinaryWriter bw)
        {
            bw.Write(this.StageId);
            bw.Write(this.FrameTime);
            this.Position.ForEach(bw.Write);
            this.Quaternion.ForEach(bw.Write);
            this.XInterpolation.ForEach(_ => _.Write(bw));
            this.YInterpolation.ForEach(_ => _.Write(bw));
            this.ZInterpolation.ForEach(_ => _.Write(bw));
            this.RotationInterpolation.ForEach(_ => _.Write(bw));

            if (bd.MinorType >= 1)
            {
                bw.Write(this.Spline);
                bw.Write(new byte[] { 0, 0, 0 });
            }
        }
Exemple #6
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);
        }