public static void Push(Vector3 position, Vector3 vtPosition, LookatData.BoneConfig data)
        {
            var forward = vtPosition - position;
            var ri      = new RotateInfo()
            {
                position   = position,
                vtPosition = vtPosition,
                forward    = forward,
                data       = data,
            };

            info.Add(ri);
        }
Esempio n. 2
0
        private void IterateTarget(int i, LookatData.BoneConfig firstBoneConfig, Bone firstBone,
                                   out Vector3 forwardDirection, out Vector3 lookatDirection)
        {
            //每次计算结束后直接赋值,初始位置坐标对应改变
            var firstBonePosition = firstBone.transform.position;
            var length            = Vector3.Distance(lookatPosition, firstBonePosition);
            var vtPosition        = firstBonePosition +
                                    firstBoneConfig.forward.GetDirection(firstBone.transform) * length;

            var nextBone         = boneArray[i + 1];
            var nextData         = lookatData.boneConfig[i + 1];
            var nextBonePosition = nextBone.transform.position;
            var vtDirection      = vtPosition - nextBonePosition;
            var finalDirection   = lookatPosition - nextBonePosition;

            forwardDirection = nextData.forward.GetDirection(nextBone.transform);
            lookatDirection  = Quaternion.FromToRotation(vtDirection, finalDirection)
                               * forwardDirection;
#if UNITY_EDITOR
            LookatDrawer.Push(nextBonePosition, vtPosition, nextData);
#endif
        }