Exemplo n.º 1
0
        public static void DrawPathGizmo(CinemachinePathBase path, Color pathColor)
        {
            // Draw the path
            Color colorOld = Gizmos.color;

            Gizmos.color = pathColor;
            float   step    = 1f / path.m_Resolution;
            Vector3 lastPos = path.EvaluatePosition(path.MinPos);
            Vector3 lastW   = (path.EvaluateOrientation(path.MinPos)
                               * Vector3.right) * path.m_Appearance.width / 2;

            for (float t = path.MinPos + step; t <= path.MaxPos + step / 2; t += step)
            {
                Vector3    p  = path.EvaluatePosition(t);
                Quaternion q  = path.EvaluateOrientation(t);
                Vector3    w  = (q * Vector3.right) * path.m_Appearance.width / 2;
                Vector3    w2 = w * 1.2f;
                Vector3    p0 = p - w2;
                Vector3    p1 = p + w2;
                Gizmos.DrawLine(p0, p1);
                Gizmos.DrawLine(lastPos - lastW, p - w);
                Gizmos.DrawLine(lastPos + lastW, p + w);
#if false
                // Show the normals, for debugging
                Gizmos.color = Color.red;
                Vector3 y = (q * Vector3.up) * path.m_Appearance.width / 2;
                Gizmos.DrawLine(p, p + y);
                Gizmos.color = pathColor;
#endif
                lastPos = p;
                lastW   = w;
            }
            Gizmos.color = colorOld;
        }
        internal static void DrawPathGizmo(CinemachinePathBase path, Color pathColor)
        {
            // Draw the path
            var colorOld = Gizmos.color;

            Gizmos.color = pathColor;
            var step    = 1f / path.m_Resolution;
            var lastPos = path.EvaluatePosition(path.MinPos);
            var lastW   = path.EvaluateOrientation(path.MinPos)
                          * Vector3.right * path.m_Appearance.width / 2;

            for (var t = path.MinPos + step; t <= path.MaxPos + step / 2; t += step)
            {
                var p  = path.EvaluatePosition(t);
                var q  = path.EvaluateOrientation(t);
                var w  = q * Vector3.right * path.m_Appearance.width / 2;
                var w2 = w * 1.2f;
                var p0 = p - w2;
                var p1 = p + w2;
                Gizmos.DrawLine(p0, p1);
                Gizmos.DrawLine(lastPos - lastW, p - w);
                Gizmos.DrawLine(lastPos + lastW, p + w);
#if false
// Show the normals, for debugging
                Gizmos.color = Color.red;
                Vector3 y = (q * Vector3.up) * width / 2;
                Gizmos.DrawLine(p, p + y);
                Gizmos.color = pathColor;
#endif
                lastPos = p;
                lastW   = w;
            }

            Gizmos.color = colorOld;
        }
Exemplo n.º 3
0
            public PathMeshNode(CinemachinePathBase path, float time)
            {
                Vector3    center      = path.EvaluatePosition(time);
                Quaternion orientation = path.EvaluateOrientation(time);

                Normal = orientation * Vector3.up;

                float   halfWidth    = path.m_Appearance.width / 2f;
                Vector3 originOffset = path.transform.position;

                RightPosition  = center + orientation * Vector3.right * halfWidth;
                RightPosition -= originOffset;

                LeftPosition  = center + orientation * Vector3.left * halfWidth;
                LeftPosition -= originOffset;
            }