Пример #1
0
        public void SaveToStream(BinaryWriter bw)
        {
            VMDString.WriteString(bw, 15, this.BoneName);
            bw.Write(this.FrameNumber);
            this.Translation.WriteToStream(bw);
            this.Rotation.WriteToStream(bw);

            bw.BaseStream.Write(this.Bezier, 0, 64);
        }
Пример #2
0
        public void LoadFromStream(BinaryReader br)
        {
            this.BoneName    = VMDString.ReadString(br, 15);
            this.FrameNumber = br.ReadUInt32();
            this.Translation = PMXVector3.LoadFromStreamStatic(br);
            this.Rotation    = PMXQuaternion.LoadFromStreamStatic(br);

            this.Bezier = new byte[64];
            br.BaseStream.Read(this.Bezier, 0, 64);
        }
Пример #3
0
        public void SaveToStream(Stream s)
        {
            BinaryWriter bw = new BinaryWriter(s);

            VMDString.WriteString(bw, 30, "Vocaloid Motion Data 0002", Encoding.ASCII);

            VMDString.WriteString(bw, 20, this.ModelName);

            bw.Write((uint)this.Bones.Count);
            foreach (VMDBoneFrame vbf in this.Bones)
            {
                vbf.SaveToStream(bw);
            }

            bw.Write((uint)this.Morphs.Count);
            foreach (VMDMorphFrame vmf in this.Morphs)
            {
                vmf.SaveToStream(bw);
            }

            bw.Write((uint)this.Camera.Count);
            foreach (VMDCameraFrame vcf in this.Camera)
            {
                vcf.SaveToStream(bw);
            }

            bw.Write((uint)this.Light.Count);
            foreach (VMDLightFrame vlf in this.Light)
            {
                vlf.SaveToStream(bw);
            }

            bw.Write((uint)this.Shadow.Count);
            foreach (VMDShadowFrame vsf in this.Shadow)
            {
                vsf.SaveToStream(bw);
            }

            bw.Write((uint)this.IK.Count);
            foreach (VMDIKFrame vif in this.IK)
            {
                vif.SaveToStream(bw);
            }
        }
Пример #4
0
 public void SaveToStream(BinaryWriter bw)
 {
     VMDString.WriteString(bw, 15, this.MorphName);
     bw.Write(this.FrameNumber);
     bw.Write(this.Weight);
 }
Пример #5
0
 public void LoadFromStream(BinaryReader br)
 {
     this.MorphName   = VMDString.ReadString(br, 15);
     this.FrameNumber = br.ReadUInt32();
     this.Weight      = br.ReadSingle();
 }
Пример #6
0
 public void SaveToStream(BinaryWriter bw)
 {
     VMDString.WriteString(bw, 20, this.IKName);
     bw.Write((byte)(this.Enable ? 1 : 0));
 }
Пример #7
0
 public void LoadFromStream(BinaryReader br)
 {
     this.IKName = VMDString.ReadString(br, 20);
     this.Enable = (br.ReadByte() == 1);
 }
Пример #8
0
        public static VMDFile LoadFromStream(Stream s)
        {
            BinaryReader br = new BinaryReader(s);

            string head = VMDString.ReadString(br, 30, Encoding.ASCII);

            if (head != "Vocaloid Motion Data 0002")
            {
                br = null;
                return(null);
            }


            VMDFile vf = new VMDFile();

            vf.ModelName = VMDString.ReadString(br, 20);

            uint boneCount = br.ReadUInt32();

            for (int i = 0; i < boneCount; i++)
            {
                VMDBoneFrame vbf = new VMDBoneFrame();
                vbf.LoadFromStream(br);
                vf.Bones.Add(vbf);
            }

            uint morphCount = br.ReadUInt32();

            for (int i = 0; i < morphCount; i++)
            {
                VMDMorphFrame vmf = new VMDMorphFrame();
                vmf.LoadFromStream(br);
                vf.Morphs.Add(vmf);
            }

            uint cameraCount = br.ReadUInt32();

            for (int i = 0; i < cameraCount; i++)
            {
                VMDCameraFrame vcf = new VMDCameraFrame();
                vcf.LoadFromStream(br);
                vf.Camera.Add(vcf);
            }

            uint lightCount = br.ReadUInt32();

            for (int i = 0; i < lightCount; i++)
            {
                VMDLightFrame vlf = new VMDLightFrame();
                vlf.LoadFromStream(br);
                vf.Light.Add(vlf);
            }

            uint shadowCount = br.ReadUInt32();

            for (int i = 0; i < shadowCount; i++)
            {
                VMDShadowFrame vsf = new VMDShadowFrame();
                vsf.LoadFromStream(br);
                vf.Shadow.Add(vsf);
            }

            if (br.BaseStream.Position < br.BaseStream.Length)
            {
                uint ikCount = br.ReadUInt32();
                for (int i = 0; i < ikCount; i++)
                {
                    VMDIKFrame vif = new VMDIKFrame();
                    vif.LoadFromStream(br);
                    vf.IK.Add(vif);
                }
            }

            return(vf);
        }