public static void MoveJoints(this SkeletonCache skeleton, BoneCache[] bones, Vector3 deltaPosition)
        {
            Debug.Assert(skeleton != null);

            foreach (var bone in bones)
            {
                Debug.Assert(bone != null);
                Debug.Assert(skeleton.Contains(bone));

                var childrenWorldPose = bone.GetChildrenWoldPose();
                var endPosition       = bone.endPosition;

                bone.position += deltaPosition;

                if (bone.localLength > 0f)
                {
                    bone.endPosition = endPosition;
                }

                if (bone.parentBone != null && bone.parentBone.chainedChild == bone)
                {
                    bone.parentBone.OrientToChainedChild(true);
                }

                bone.SetChildrenWorldPose(childrenWorldPose);

                if (bone.chainedChild != null)
                {
                    bone.OrientToChainedChild(true);
                }
            }
        }
 public static void AddBones(this SkeletonCache skeleton, BoneCache[] bones, bool worldPositionStays)
 {
     foreach (var bone in bones)
     {
         skeleton.AddBone(bone, worldPositionStays);
     }
 }
        public static void FreeMoveBones(this SkeletonCache skeleton, BoneCache[] bones, Vector3 deltaPosition)
        {
            Debug.Assert(skeleton != null);

            foreach (var bone in bones)
            {
                Debug.Assert(bone != null);
                Debug.Assert(skeleton.Contains(bone));

                var childrenWorldPose = bone.GetChildrenWoldPose();

                if (bone.chainedChild != null && ArrayUtility.Contains(bones, bone.chainedChild) == false)
                {
                    bone.chainedChild = null;
                }

                if (bone.parentBone != null && bone.parentBone.chainedChild == bone && ArrayUtility.Contains(bones, bone.parentBone) == false)
                {
                    bone.parentBone.chainedChild = null;
                }

                bone.position += deltaPosition;

                bone.SetChildrenWorldPose(childrenWorldPose);
            }
        }
 private void OnSkeletonTopologyChanged(SkeletonCache skeleton)
 {
     if (m_Model.view.visible)
     {
         m_Model.view.OnSkeletonChanged();
     }
 }
        public static BoneCache CreateBone(this SkeletonCache skeleton, BoneCache parentBone, Vector3 position, Vector3 endPosition, bool isChained, string name)
        {
            Debug.Assert(skeleton != null);

            if (parentBone != null)
            {
                Debug.Assert(skeleton.Contains(parentBone));
            }

            var bone = skeleton.skinningCache.CreateCache <BoneCache>();

            bone.SetParent(parentBone);
            bone.name          = name;
            bone.bindPoseColor = ModuleUtility.CalculateNiceColor(skeleton.BoneCount, 6);
            bone.position      = position;
            bone.endPosition   = endPosition;

            if (isChained && parentBone != null)
            {
                parentBone.chainedChild = bone;
            }

            skeleton.AddBone(bone);


            return(bone);
        }
示例#6
0
 void OnSkeletonPreviewPoseChanged(SkeletonCache skeleton)
 {
     SetAnimationEvent(new AnimationEvent()
     {
         sub_type = AnimationEventType.SkeletonPreviewPoseChanged,
         data     = ""
     });
 }
示例#7
0
 void OnSkeletonTopologyChanged(SkeletonCache skeleton)
 {
     SetAnimationEvent(new AnimationEvent()
     {
         sub_type = AnimationEventType.SkeletonTopologyChanged,
         data     = ""
     });
 }
示例#8
0
 public static void SetAllBoneVisibility(SkeletonCache skeleton, bool visibility)
 {
     if (skeleton != null)
     {
         foreach (var bone in skeleton.bones)
             bone.isVisible = visibility;
     }
 }
 private void SetSkeleton(SkeletonCache newSkeleton)
 {
     if (skeleton != newSkeleton)
     {
         m_Skeleton = newSkeleton;
         Reset();
     }
 }
示例#10
0
        //TODO: Bring this to a better place, maybe CharacterController
        private void SkeletonPreviewPoseChanged(SkeletonCache skeleton)
        {
            var character = skinningCache.character;

            if (character != null && character.skeleton == skeleton)
            {
                skinningCache.SyncSpriteSheetSkeletons();
            }
        }
示例#11
0
        private void SkeletonBindPoseChanged(SkeletonCache skeleton)
        {
            var character = skinningCache.character;

            if (character != null && character.skeleton == skeleton)
            {
                skinningCache.SyncSpriteSheetSkeletons();
            }
            DataModified();
        }
示例#12
0
        private void SetupSkeleton(SkeletonCache sk)
        {
            m_RectBoneSelector.bones = null;
            skeleton = sk;

            if (skeleton != null)
            {
                m_RectBoneSelector.bones = skeleton.bones;
            }
        }
        public static void SetEndPosition(this SkeletonCache skeleton, BoneCache bone, Vector3 endPosition)
        {
            Debug.Assert(skeleton != null);
            Debug.Assert(bone != null);
            Debug.Assert(skeleton.Contains(bone));

            var childrenStorage = bone.GetChildrenWoldPose();

            bone.endPosition = endPosition;
            bone.SetChildrenWorldPose(childrenStorage);
        }
        public static void DestroyBones(this SkeletonCache skeleton, BoneCache[] bones)
        {
            Debug.Assert(skeleton != null);

            foreach (var bone in bones)
            {
                Debug.Assert(bone != null);
                Debug.Assert(skeleton.Contains(bone));

                skeleton.DestroyBone(bone);
            }
        }
        public static void RotateBones(this SkeletonCache skeleton, BoneCache[] bones, float deltaAngle)
        {
            Debug.Assert(skeleton != null);

            foreach (var bone in bones)
            {
                Debug.Assert(bone != null);
                Debug.Assert(skeleton.Contains(bone));

                bone.localRotation *= Quaternion.AngleAxis(deltaAngle, Vector3.forward);
            }
        }
        public static void MoveBones(this SkeletonCache skeleton, BoneCache[] bones, Vector3 deltaPosition)
        {
            Debug.Assert(skeleton != null);

            foreach (var bone in bones)
            {
                Debug.Assert(bone != null);
                Debug.Assert(skeleton.Contains(bone));

                bone.position += deltaPosition;

                if (bone.parentBone != null && bone.parentBone.chainedChild == bone)
                {
                    bone.parentBone.OrientToChainedChild(false);
                }
            }
        }
示例#17
0
        private void SkeletonTopologyChanged(SkeletonCache skeleton)
        {
            var character = skinningCache.character;

            if (character == null)
            {
                var sprite = FindSpriteFromSkeleton(skeleton);

                Debug.Assert(sprite != null);

                sprite.UpdateMesh(skeleton.bones);

                DataModified();
            }
            else if (character.skeleton == skeleton)
            {
                skinningCache.CreateSpriteSheetSkeletons();
                DataModified();
            }
        }
        public static BoneCache SplitBone(this SkeletonCache skeleton, BoneCache boneToSplit, float splitLength, string name)
        {
            Debug.Assert(skeleton.Contains(boneToSplit));
            Debug.Assert(boneToSplit.length > splitLength);

            var endPosition   = boneToSplit.endPosition;
            var chainedChild  = boneToSplit.chainedChild;
            var splitPosition = boneToSplit.position + boneToSplit.right * splitLength;

            boneToSplit.length = splitLength;

            var bone = skeleton.CreateBone(boneToSplit, splitPosition, endPosition, true, name);

            if (chainedChild != null)
            {
                chainedChild.SetParent(bone);
                bone.chainedChild = chainedChild;
            }

            return(bone);
        }
        public DefaultPoseScope(SkeletonCache skeleton, bool useLocalPose = true)
        {
            Debug.Assert(skeleton != null);

            m_Skeleton     = skeleton;
            m_UseLocalPose = useLocalPose;

            if (m_Skeleton.isPosePreview)
            {
                m_DoRestorePose = true;

                if (useLocalPose)
                {
                    m_Pose = m_Skeleton.GetLocalPose();
                }
                else
                {
                    m_Pose = m_Skeleton.GetWorldPose();
                }

                m_Skeleton.RestoreDefaultPose();
            }
        }
示例#20
0
 public void OnSelectionChange(SkeletonCache skeleton)
 {
     ((BoneTreeView)m_TreeView).SetupHierarchy();
 }
 public void OnSelectionChange(SkeletonCache skeleton)
 {
     ((IBoneVisibilityToolView)toolView).OnSelectionChange(skeleton);
 }
 private void SkeletonChanged(SkeletonCache skeleton)
 {
     DirtySkinningAll();
 }
示例#23
0
 private string[] GetUniqueBoneNames(BoneCache[] bones, SkeletonCache skeleton)
 {
     return(Array.ConvertAll(bones, b => skeleton.GetUniqueName(b)));
 }
示例#24
0
 public virtual void SetAllVisibility(SkeletonCache skeleton, bool visibility)
 {
     m_Data.allVisibility = visibility;
     SetAllBoneVisibility(skeleton, visibility);
 }
示例#25
0
 private void SkeletonTopologyChanged(SkeletonCache skeleton)
 {
     m_Model.view.OnSelectionChange(skeleton);
 }
 public static void SetBones(this SkeletonCache skeleton, BoneCache[] bones, bool worldPositionStays)
 {
     skeleton.Clear();
     skeleton.AddBones(bones, worldPositionStays);
     skeleton.SetDefaultPose();
 }
示例#27
0
        private SpriteCache FindSpriteFromSkeleton(SkeletonCache skeleton)
        {
            var sprites = skinningCache.GetSprites();

            return(sprites.FirstOrDefault(sprite => sprite.GetSkeleton() == skeleton));
        }
 public static void AddBones(this SkeletonCache skeleton, BoneCache[] bones)
 {
     skeleton.AddBones(bones, true);
 }