Beispiel #1
0
        /// <summary>
        ///     モーションをファイルから追加する
        /// </summary>
        /// <param name="filePath">ファイルパス</param>
        /// <param name="ignoreParent">すべての親を無視するか否か</param>
        /// <returns>モーションのindex</returns>
        public IMotionProvider AddMotionFromFile(string filePath, bool ignoreParent)
        {
            // モーションプロバイダを作成する。ファイルの拡張子に応じて適切なクラスを割り当てる
            IMotionProvider motion;
            var             extension = System.IO.Path.GetExtension(filePath);

            if (String.Compare(extension, ".vmd", true) == 0)
            {
                motion = new MMDMotion(filePath, ignoreParent);
            }
            else if (String.Compare(extension, ".vme", true) == 0)
            {
                motion = new MMDMotionForVME(filePath, ignoreParent);
            }
            else
            {
                throw new Exception("ファイルが不適切です!");
            }

            motion.AttachMotion(skinningProvider.Bone);
            motion.MotionFinished += motion_MotionFinished;
            SubscribedMotionMap.Add(new KeyValuePair <string, IMotionProvider>(filePath, motion));
            if (MotionListUpdated != null)
            {
                MotionListUpdated(this, new EventArgs());
            }
            return(motion);
        }
Beispiel #2
0
        public IMotionProvider AddMotionFromStream(string fileName, Stream stream, bool ignoreParent)
        {
            IMotionProvider motion = new MMDMotion(stream, ignoreParent);

            motion.MotionFinished += motion_MotionFinished;
            SubscribedMotionMap.Add(new KeyValuePair <string, IMotionProvider>(fileName, motion));
            if (MotionListUpdated != null)
            {
                MotionListUpdated(this, new EventArgs());
            }
            return(motion);
        }