예제 #1
0
        public Matrix4x4 MatrixAtFrame(int frame)
        {
            if (null == Animation)
            {
                Animation = GlobalState.Animation.GetObjectAnimation(this.gameObject);
            }
            if (null == Animation)
            {
                return(Matrix4x4.identity);
            }

            AnimationSet rootAnimation = GlobalState.Animation.GetObjectAnimation(RootController.gameObject);
            Matrix4x4    trsMatrix     = RootController.transform.parent.localToWorldMatrix;

            if (null != rootAnimation)
            {
                trsMatrix = trsMatrix * rootAnimation.GetTRSMatrix(frame);
            }
            else
            {
                trsMatrix = trsMatrix * Matrix4x4.TRS(RootController.transform.localPosition, RootController.transform.localRotation, RootController.transform.localScale);
            }

            if (PathToRoot.Count > 1)
            {
                for (int i = 0; i < PathToRoot.Count; i++)
                {
                    trsMatrix = trsMatrix * AnimToRoot[i].GetTRSMatrix(frame);
                }
            }
            trsMatrix = trsMatrix * Animation.GetTRSMatrix(frame);
            return(trsMatrix);
        }
예제 #2
0
        public Vector3 FramePosition(int frame)
        {
            if (null == Animation)
            {
                Animation = GlobalState.Animation.GetObjectAnimation(this.gameObject);
            }
            if (null == Animation)
            {
                return(Vector3.zero);
            }

            AnimationSet rootAnimation = GlobalState.Animation.GetObjectAnimation(RootController.gameObject);
            Matrix4x4    trsMatrix     = RootController.transform.parent.localToWorldMatrix;

            if (null != rootAnimation)
            {
                trsMatrix = trsMatrix * rootAnimation.GetTRSMatrix(frame);
            }
            else
            {
                trsMatrix = trsMatrix * Matrix4x4.TRS(RootController.transform.localPosition, RootController.transform.localRotation, RootController.transform.localScale);
            }

            if (PathToRoot.Count > 1)
            {
                for (int i = 0; i < PathToRoot.Count; i++)
                {
                    if (null != AnimToRoot[i])
                    {
                        trsMatrix = trsMatrix * AnimToRoot[i].GetTRSMatrix(frame);
                    }
                }
            }
            trsMatrix = trsMatrix * Animation.GetTRSMatrix(frame);

            Maths.DecomposeMatrix(trsMatrix, out Vector3 parentPosition, out Quaternion quaternion, out Vector3 scale);
            return(parentPosition);
        }
예제 #3
0
            public Node(GameObject targetObject, int frame, Transform parentNode, Matrix4x4 parentMatrix, float scale = 1f)
            {
                Target          = targetObject;
                Frame           = frame;
                ObjectAnimation = GlobalState.Animation.GetObjectAnimation(Target);
                Childrens       = new List <Node>();
                if (null == ObjectAnimation)
                {
                    return;
                }
                Matrix4x4 objectMatrix = parentMatrix * ObjectAnimation.GetTRSMatrix(frame);

                Maths.DecomposeMatrix(objectMatrix, out worldPosition, out Quaternion objectRotation, out Vector3 objectScale);

                if (Target.TryGetComponent <RigGoalController>(out RigGoalController controller) && controller.IsGoal)
                {
                    Sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    controller.CheckAnimations();
                }