예제 #1
0
        void CreateSkeleton(Skeleton skeleton, Model.Bone bone, List <Model.Bone> bonesToSkin)
        {
            var joint      = new BoneWrapper(bonesToSkin.IndexOf(bone), bone.Name, bone.GetTransformMatrix(0).ToMatrix4x4());
            var parentName = bone.Parent != null ? bone.Parent.Name : string.Empty;

            skeleton.InsertJoint(parentName, joint);
            foreach (var child in bone.Children)
            {
                CreateSkeleton(skeleton, child, bonesToSkin);
            }
        }
예제 #2
0
        public IJoint DeepCopy()
        {
            BoneWrapper copy = new BoneWrapper(Id, Name, new Matrix4x4(BaseTransform));

            copy.AnimationTransform = new Matrix4x4(AnimationTransform);

            foreach (IJoint child in Children)
            {
                copy.AddChild(child.DeepCopy());
            }

            for (int i = 0; i < 3; i++)
            {
                copy.Constraints[i] = new Vector2D(Constraints[i]);
            }

            return(copy);
        }
예제 #3
0
        private void CreateSkeleton(ref Skeleton skeleton, IEnumerable <Model.Bone> bones)
        {
            int id = 0;

            foreach (var bone in bones)
            {
                var joint = new BoneWrapper(bone);
                joint.Id = id++;

                // Find parent joint (bone can have parent which is not in joint list, so traverse up to root)
                var    parent      = bone.Parent;
                IJoint parentJoint = null;
                while (parent != null && parentJoint == null)
                {
                    skeleton.JointTable.TryGetValue(parent.Name, out parentJoint);
                    parent = parent.Parent;
                }
                skeleton.InsertJoint(parentJoint.Name, joint);
            }
        }