Exemple #1
0
        public static void SaveSkeleton(FSKL fskl, List <STBone> Bones)
        {
            fskl.node.SkeletonU.Bones.Clear();
            fskl.node.SkeletonU.MatrixToBoneList     = new List <ushort>();
            fskl.node.SkeletonU.InverseModelMatrices = new List <Syroot.Maths.Matrix3x4>();

            fskl.node.Nodes.Clear();

            ushort SmoothIndex = 0;

            foreach (STBone genericBone in Bones)
            {
                genericBone.BillboardIndex = ushort.MaxValue;

                //Clone a generic bone with the generic data
                BfresBone bn = new BfresBone(fskl);
                bn.CloneBaseInstance(genericBone);

                //Set the bfres bone data
                if (bn.BoneU == null)
                {
                    bn.BoneU = new Bone();
                }
                bn.GenericToBfresBone();

                if (bn.SmoothMatrixIndex != short.MaxValue)
                {
                    fskl.node.SkeletonU.MatrixToBoneList.Add(SmoothIndex++);
                }

                fskl.node.SkeletonU.InverseModelMatrices.Add(Syroot.Maths.Matrix3x4.Zero);

                fskl.bones.Add(bn);
            }

            foreach (BfresBone wrapper in fskl.bones)
            {
                //Check duplicated names
                List <string> names = fskl.bones.Select(o => o.Text).ToList();
                wrapper.Text = Utils.RenameDuplicateString(names, wrapper.Text);

                wrapper.BoneU.Name = wrapper.Text;
                fskl.node.SkeletonU.Bones.Add(wrapper.Text, wrapper.BoneU);

                //Add bones to tree
                if (wrapper.Parent == null)
                {
                    fskl.node.Nodes.Add(wrapper);
                }
            }

            fskl.Node_Array = new int[fskl.node.SkeletonU.MatrixToBoneList.Count];
            int nodes = 0;

            foreach (ushort node in fskl.node.SkeletonU.MatrixToBoneList)
            {
                fskl.Node_Array[nodes] = node;
                nodes++;
            }
        }
Exemple #2
0
        public static void SaveSkeleton(FSKL fskl, List <STBone> Bones)
        {
            if (fskl.node.SkeletonU == null)
            {
                fskl.node.SkeletonU = new Skeleton();
            }

            fskl.node.SkeletonU.Bones.Clear();
            fskl.node.SkeletonU.InverseModelMatrices = new List <Syroot.Maths.Matrix3x4>();

            fskl.node.Nodes.Clear();

            ushort SmoothIndex = 0;

            foreach (STBone genericBone in Bones)
            {
                genericBone.BillboardIndex = -1;

                //Clone a generic bone with the generic data
                BfresBone bn = new BfresBone(fskl);
                bn.CloneBaseInstance(genericBone);

                //Set the bfres bone data
                if (bn.BoneU == null)
                {
                    bn.BoneU = new Bone();
                }
                bn.GenericToBfresBone();

                //Check duplicated names
                List <string> names = fskl.bones.Select(o => o.Text).ToList();
                bn.Text = Utils.RenameDuplicateString(names, bn.Text);

                fskl.node.SkeletonU.InverseModelMatrices.Add(Syroot.Maths.Matrix3x4.Zero);
                fskl.bones.Add(bn);

                bn.BoneU.Name = bn.Text;
                fskl.node.SkeletonU.Bones.Add(bn.Text, bn.BoneU);

                //Add bones to tree
                if (bn.Parent == null)
                {
                    fskl.node.Nodes.Add(bn);
                }
            }


            fskl.update();
            fskl.reset();
        }