コード例 #1
0
        public override void ReadData(BinaryReader stream, IDictionary <object, object> userdata, int totalSize)
        {
            Positions  = ReadStructArray <Vector4>(stream);
            UnusedVec3 = ReadStructArray <Vector4>(stream);
            Vertices   = ReadStructArray <Vertex>(stream);
            Faces      = ReadStructArray <Face>(stream);
            int num = stream.ReadInt32();

            MorphFrames.Clear();
            MorphFrames.Capacity = num;
            for (int i = 0; i < num; i++)
            {
                var frame = new VertexFrame();
                frame.Time = stream.ReadInt32();
                MorphFrames.Add(frame);
            }

            for (int i = 0; i < num; i++)
            {
                var frame = MorphFrames[i];
                frame.Positions = ReadStructArray <Vector4>(stream);
                frame.Normals   = ReadStructArray <Vector4>(stream);
            }
            Bones = ReadStructArray <Bone>(stream);
            FaceSmoothingGroupMasks = ReadStructArray <int>(stream);
        }
コード例 #2
0
        public List <string> GetKeyNames(params GetKeyIgnoring[] opt)
        {
            var names = new List <string>();
            IEnumerable <IGrouping <string, VmdMotionFrameData> > motions = MotionFrames.GroupBy(f => f.Name.Trim('\0'));;
            IEnumerable <IGrouping <string, VmdMorphFrameData> >  morphs  = MorphFrames.GroupBy(f => f.Name.Trim('\0'));

            if (opt.Contains(GetKeyIgnoring.ZeroValue))
            {
                motions = motions.Where(g => g.Where(f => (f.Pos != Vector3.Zero) || (f.Rot != Quaternion.Identity)).Count() != 0);
                morphs  = morphs.Where(g => g.Where(f => f.Weigth != 0).Count() != 0);
            }

            if (opt.Contains(GetKeyIgnoring.FirstFrame))
            {
                //フレームタイムが0でないvmdを持つグループのみを抽出
                motions = motions.Where(g => g.Where(f => f.FrameTime != 0).Count() != 0);
                morphs  = morphs.Where(g => g.Where(f => f.FrameTime != 0).Count() != 0);
            }

            if (!opt.Contains(GetKeyIgnoring.Motion))
            {
                names.AddRange(motions.Select(g => g.Key));
                names.Sort(new Utilities.BoneNameComparer());
            }

            if (!opt.Contains(GetKeyIgnoring.Morph))
            {
                names.AddRange(morphs.Select(g => g.Key));
            }

            return(names);
        }
コード例 #3
0
 public void Merge(VocaloidMotionData data)
 {
     if (data.MotionFrames != null)
     {
         MotionFrames.AddRange(data.MotionFrames);
     }
     if (data.MorphFrames != null)
     {
         MorphFrames.AddRange(data.MorphFrames);
     }
     if (data.CameraFrames != null)
     {
         CameraFrames.AddRange(data.CameraFrames);
     }
     if (data.LightFrames != null)
     {
         LightFrames.AddRange(data.LightFrames);
     }
     if (data.ShadowFrames != null)
     {
         ShadowFrames.AddRange(data.ShadowFrames);
     }
     if (data.PropertyFrames != null)
     {
         PropertyFrames.AddRange(data.PropertyFrames);
     }
 }
コード例 #4
0
        /// <summary>
        /// VMDを読み込む
        /// </summary>
        /// <returns>EndOfStreamExceptionが発生した場合 true を返す</returns>
        public bool Read(BinaryReader reader)
        {
            try
            {
                byte[] bChar = reader.ReadBytes(HEADER_LENGTH);
                header = new string(Encoding.GetChars(bChar));
                int eosPos = header.IndexOf('\0');
                if (eosPos >= 0)
                {
                    header = header.Remove(eosPos);
                }

                bChar     = reader.ReadBytes(MODEL_NAME_LENGTH);
                ModelName = new string(Encoding.GetChars(bChar));
                eosPos    = ModelName.IndexOf('\0');
                if (eosPos >= 0)
                {
                    ModelName = ModelName.Remove(eosPos);
                }

                uint len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    MotionFrames.Add(new VmdMotionFrameData(reader));
                }

                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    MorphFrames.Add(new VmdMorphFrameData(reader));
                }

                //camera
                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    CameraFrames.Add(new VmdCameraFrameData(reader));
                }

                //light
                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    LightFrames.Add(new VmdLightFrameData(reader));
                }

                //self shadow
                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    ShadowFrames.Add(new VmdShadowFrameData(reader));
                }

                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    PropertyFrames.Add(new VmdPropertyFrameData(reader));
                }
                return(false);
            }
            catch (EndOfStreamException)
            {
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }