示例#1
0
        private List <Bone?>?WriteToFile(BonesViewModel bones)
        {
            if (bones == null)
            {
                return(null);
            }

            if (bones.Count <= 0 || bones.Count > 512)
            {
                return(null);
            }

            if (bones.Transforms == null || bones.Transforms.Count != bones.Count)
            {
                throw new Exception("Bone transform array does not match expected size");
            }

            List <Bone?> transforms = new List <Bone?>();

            foreach (TransformViewModel bone in bones.Transforms)
            {
                Transform?trans = bone.Model;

                if (trans == null)
                {
                    continue;
                }

                transforms.Add(new Bone(trans.Value));
            }

            return(transforms);
        }
示例#2
0
        private void ReadFromFile(List <Bone?>?transforms, BonesViewModel bones, Configuration config)
        {
            if (bones == null)
            {
                return;
            }

            if (transforms == null || transforms.Count <= 0)
            {
                return;
            }

            ////if (transforms.Count != bones.Count)
            ////	throw new Exception("Saved pose bone count does not match target skeleton bone count");

            int count = Math.Min(transforms.Count, bones.Count);

            for (int i = 0; i < count; i++)
            {
                Bone?bone = transforms[i];

                if (bone == null)
                {
                    continue;
                }

                if (config.IncludePosition && this.Config.IncludePosition && bone.Position != Vector.Zero)
                {
                    bones.Transforms[i].Position = bone.Position;
                }

                if (config.IncludeRotation && this.Config.IncludeRotation)
                {
                    bones.Transforms[i].Rotation = bone.Rotation;
                }

                if (config.IncludeScale && this.Config.IncludeScale && bone.Scale != Vector.Zero)
                {
                    bones.Transforms[i].Scale = bone.Scale;
                }
            }
        }