Beispiel #1
0
        public override void Open()
        {
            ISSBH_File SSBHFile;

            if (SSBH.TryParseSSBHFile(AbsolutePath, out SSBHFile))
            {
                if (SSBHFile is SKEL)
                {
                    _skel = (SKEL)SSBHFile;
                }
            }
        }
Beispiel #2
0
        public override void Open(string Path)
        {
            ISSBH_File SSBHFile;

            if (SSBH.TryParseSSBHFile(Path, out SSBHFile))
            {
                if (SSBHFile is SKEL)
                {
                    _skel = (SKEL)SSBHFile;
                }
            }
        }
Beispiel #3
0
        public static void Save(string FileName, SBScene Scene)
        {
            var Skeleton = Scene.Skeleton;

            var skelFile = new SKEL();

            skelFile.MajorVersion = 1;
            skelFile.MinorVersion = 0;

            List <SKEL_BoneEntry> BoneEntries        = new List <SKEL_BoneEntry>();
            List <SKEL_Matrix>    Transforms         = new List <SKEL_Matrix>();
            List <SKEL_Matrix>    InvTransforms      = new List <SKEL_Matrix>();
            List <SKEL_Matrix>    WorldTransforms    = new List <SKEL_Matrix>();
            List <SKEL_Matrix>    InvWorldTransforms = new List <SKEL_Matrix>();

            short index = 0;
            Dictionary <SBBone, short> BoneToIndex = new Dictionary <SBBone, short>();
            var OrderedBones = SortBones(Skeleton.Bones);

            foreach (var bone in OrderedBones)
            {
                BoneToIndex.Add(bone, index);
                var boneentry = new SKEL_BoneEntry();
                boneentry.Name     = bone.Name;
                boneentry.Type     = bone.Type;
                boneentry.ID       = index++;
                boneentry.Type     = 1;
                boneentry.ParentID = -1;
                if (bone.Parent != null)// && BoneToIndex.ContainsKey(bone.Parent))
                {
                    boneentry.ParentID = (short)OrderedBones.IndexOf(bone.Parent);
                }
                BoneEntries.Add(boneentry);

                Transforms.Add(TKMatrix_to_Skel(bone.Transform));
                InvTransforms.Add(TKMatrix_to_Skel(bone.Transform.Inverted()));
                WorldTransforms.Add(TKMatrix_to_Skel(bone.WorldTransform));
                InvWorldTransforms.Add(TKMatrix_to_Skel(bone.InvWorldTransform));
            }

            skelFile.BoneEntries       = BoneEntries.ToArray();
            skelFile.Transform         = Transforms.ToArray();
            skelFile.InvTransform      = InvTransforms.ToArray();
            skelFile.WorldTransform    = WorldTransforms.ToArray();
            skelFile.InvWorldTransform = InvWorldTransforms.ToArray();

            SSBH.TrySaveSSBHFile(FileName, skelFile);
        }