/// <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); }
/// <summary> /// Motion to add from file /// </summary> /// <param name="filePath">File path</param> /// <param name="ignoreParent">Whether or not to ignore any parent</param> /// <returns>Motion index</returns> public IMotionProvider AddMotionFromFile(string filePath, bool ignoreParent) { // To create a motion provider. Assign the appropriate class in accordance with the extension of the file IMotionProvider motion; var extension = 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("File is incorrect!"); } motion.AttachMotion(this.skinningProvider.Bone); motion.MotionFinished += motion_MotionFinished; this.SubscribedMotionMap.Add(new KeyValuePair <string, IMotionProvider>(filePath, motion)); if (MotionListUpdated != null) { MotionListUpdated(this, new EventArgs()); } return(motion); }
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); }