Beispiel #1
0
        /// <summary>
        /// Export Animation
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="skeleton"></param>
        /// <param name="animation"></param>
        public void Export(string filePath, GenericSkeleton skeleton, GenericAnimation animation)
        {
            using (StreamWriter w = new StreamWriter(new FileStream(filePath, FileMode.Create)))
            {
                w.WriteLine("version 1");

                if (skeleton != null)
                {
                    w.WriteLine("nodes");
                    foreach (GenericBone bone in skeleton.Bones)
                    {
                        w.WriteLine($" {skeleton.IndexOf(bone)} \"{bone.Name}\" {bone.ParentIndex}");
                    }
                    w.WriteLine("end");
                    w.WriteLine("skeleton");

                    for (int i = 0; i < animation.FrameCount; i++)
                    {
                        animation.UpdateSkeleton(i, skeleton);
                        w.WriteLine("time " + i);
                        foreach (GenericBone bone in skeleton.Bones)
                        {
                            GenericBone b = new GenericBone();
                            b.Transform = bone.GetTransform(true);
                            w.WriteLine($" {skeleton.IndexOf(bone)} {b.Position.X} {b.Position.Y} {b.Position.Z} {b.Rotation.X} {b.Rotation.Y} {b.Rotation.Z}");
                        }
                    }
                    w.WriteLine("end");
                }
            }
        }
Beispiel #2
0
 private void Awake()
 {
     _animator        = GetComponent <Animator>();
     _attack          = GetComponent <Attack>();
     _characterState  = GetComponent <CharacterState>();
     genericAnimation = GetComponent <GenericAnimation>();
     CreateOrGetGrabBox();
 }
Beispiel #3
0
 private void Awake()
 {
     _collision       = GetComponent <BaseCollision>();
     _characterState  = GetComponent <CharacterState>();
     _knockdown       = GetComponent <KnockDown>();
     _jump            = GetComponent <Jump>();
     _animator        = GetComponent <Animator>();
     genericAnimation = GetComponent <GenericAnimation>();
     random           = new System.Random();
 }
Beispiel #4
0
 /// <summary>
 ///
 /// </summary>
 public void AddAnimation(GenericAnimation animation)
 {
     animationCB.Items.Add(animation);
     animationCB.SelectedItem = animation;
     EnableAnimation();
     if (Model.Skeleton != null)
     {
         animation.UpdateSkeleton(Frame, Model.Skeleton);
     }
     ResetView();
 }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="skeleton"></param>
        /// <param name="animation"></param>
        /// <returns></returns>
        public bool ExportAnimation(GenericSkeleton skeleton, GenericAnimation animation)
        {
            var path = FileTools.GetSaveFile(animation.Name, GetAnimationExportFilter());

            if (path != null && skeleton != null)
            {
                var ext = System.IO.Path.GetExtension(path).ToLower();
                foreach (var v in AnimationExporters)
                {
                    if (v.Extension().Equals(ext))
                    {
                        v.Export(path, skeleton, animation);
                        return(true);
                    }
                }
            }
            return(false);
        }