Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bone"></param>
        /// <param name="joint"></param>
        /// <param name="animation"></param>
        private void EncodeAnimJoint(SBBone bone, HSD_AnimJoint joint, SBAnimation animation)
        {
            var node = animation.TransformNodes.Find(e => e.Name == bone.Name);

            if (node != null)
            {
                // encode tracks
                joint.Flags         = 1;
                joint.AOBJ          = new HSD_AOBJ();
                joint.AOBJ.EndFrame = animation.FrameCount;
                joint.AOBJ.Flags    = AOBJ_Flags.ANIM_LOOP;

                if (!HSDSettings.LoopAnimation)
                {
                    joint.AOBJ.Flags = AOBJ_Flags.FIRST_PLAY;
                }

                if (node.Tracks.Count == 0)
                {
                    joint.AOBJ.Flags = AOBJ_Flags.NO_ANIM;
                }

                var prev = new HSD_FOBJDesc();

                foreach (var track in node.Tracks)
                {
                    var fobjdesc = new HSD_FOBJDesc();
                    fobjdesc.FromFOBJ(EncodeFOBJ(track));
                    fobjdesc.DataLength = fobjdesc.ToFOBJ().Buffer.Length;

                    if (joint.AOBJ.FObjDesc == null)
                    {
                        joint.AOBJ.FObjDesc = fobjdesc;
                    }
                    else
                    {
                        prev.Next = fobjdesc;
                    }

                    prev = fobjdesc;
                }
            }

            // continue adding children
            var prevChild = new HSD_AnimJoint();

            foreach (var c in bone.Children)
            {
                HSD_AnimJoint child = new HSD_AnimJoint();
                EncodeAnimJoint(c, child, animation);
                if (joint.Child == null)
                {
                    joint.Child = child;
                }
                else
                {
                    prevChild.Next = child;
                }
                prevChild = child;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="desc"></param>
 /// <param name="lines"></param>
 public static void ImportKeys(HSD_FOBJDesc desc, string[] lines)
 {
     desc.FromFOBJ(ImportKeys(desc.ToFOBJ(), lines));
 }