public static Quaternion Twist(ISpline core, float t_core, ISpline guide, float t_guide)
        {
            Vector3 corePoint     = core.Evaluate(t_core);
            Vector3 rotationPoint = guide.Evaluate(t_guide);

            Vector3 tangentBasis = core.Tangent(t_core);

            tangentBasis = tangentBasis.normalized;

            Vector3 normalBasis = Vector3.Cross(tangentBasis, rotationPoint - corePoint);

            normalBasis = normalBasis.normalized;

            #region Uncomment this region to debug all Twist invocations

            /*
             * //Vector3 binormalBasis = Vector3.Cross(normalBasis, tangentBasis);
             * //binormalBasis = binormalBasis.normalized;
             *
             * //Debug.DrawLine(corePoint, corePoint + tangentBasis, Color.blue);
             * //Debug.DrawLine(corePoint, corePoint + normalBasis, Color.green);
             * //Debug.DrawLine(corePoint, corePoint + binormalBasis, Color.red);
             */

            #endregion Uncomment this region to debug all Twist invocations

            return(Quaternion.LookRotation(tangentBasis, normalBasis));
        }
Beispiel #2
0
        public static void DrawTestInterpolate(ISpline worldSpline, float t)
        {
            Vector3 targetPoint = worldSpline.Evaluate(t);
            float   sphereSize  = PathEditorUtility.Nice3DHandleSize(targetPoint);

            Handles.color = GetTColor(t);
            Handles.SphereCap(0, targetPoint, Quaternion.identity, sphereSize);

            Handles.color = Color.cyan;
            Handles.DrawAAPolyLine(targetPoint, targetPoint + worldSpline.Tangent(t).normalized);
        }
Beispiel #3
0
        public Vector3 GetTangent(float t)
        {
            ISpline sp = Spline;

            if (sp == null)
            {
                Dbg.LogErr("BaseSplineBehaviour.GetTangent: not set spline yet");
                return(Vector3.zero);
            }

            Dbg.Assert(0 <= t && t <= 1, "BaseSplineBehaviour.GetTangent: t beyond range: {0}", t);

            Vector3 tan = sp.Tangent(t);

            return(tan);
        }