protected virtual void ShowTwistAngles()
        {
            Handles.color = Color.green;

            int steps = GetStepsPerCurve() * m_splineBase.CurveCount;

            for (int i = 0; i <= steps; i++)
            {
                Vector3 dir   = m_splineBase.GetDirection(i / (float)steps);
                Vector3 point = m_splineBase.GetPoint(i / (float)steps);

                float   t          = i / (float)steps;
                float   twistAngle = m_splineBase.GetTwist(t);
                Vector3 v3;
                Vector3 up = GetUpVector();
                if (Math.Abs(Vector3.Dot(dir, up)) < 1.0f)
                {
                    v3 = Vector3.Cross(dir, up).normalized;
                }
                else
                {
                    v3 = Vector3.Cross(dir, GetSideVector()).normalized;
                }
                if (dir == Vector3.zero)
                {
                    continue;
                }
                Handles.DrawLine(point, point + Quaternion.AngleAxis(twistAngle, dir) * Quaternion.LookRotation(v3, up) * Vector3.forward * TwistAngleScale);
            }
        }
Esempio n. 2
0
 protected override void ShowPointOverride(SplineBase spline, int index, Vector3 point, Quaternion handleRotation, float size)
 {
     if (!spline.Loop)
     {
         if (index == spline.ControlPointCount - 1)
         {
             if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera != null)
             {
                 if ((SceneView.lastActiveSceneView.camera.transform.position - point).magnitude > 4.0f)
                 {
                     if (Handles.Button(point + spline.GetDirection(1.0f) * 1.5f, handleRotation, size * HandleSize, size * PickSize2, (id, p, r, s, e) => CapFunction(size, id, p, m_addButton, e)))
                     {
                         SplineEditor.Append((Spline)spline);
                         Selection.activeGameObject = spline.GetSplineControlPoints().Last().gameObject;
                     }
                 }
             }
         }
         else if (index == 0)
         {
             if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera != null)
             {
                 if ((SceneView.lastActiveSceneView.camera.transform.position - point).magnitude > 4.0f)
                 {
                     if (Handles.Button(point - spline.GetDirection(0.0f) * 1.5f, handleRotation, size * HandleSize, size * PickSize2, (id, p, r, s, e) => CapFunction(size, id, p, m_addButton, e)))
                     {
                         SplineEditor.Prepend((Spline)spline);
                         Selection.activeGameObject = spline.GetSplineControlPoints().First().gameObject;
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
        private void UpdatePosition(float t)
        {
            Vector3 position = m_spline.GetPoint(t);
            Vector3 dir      = m_spline.GetDirection(t);
            float   twist    = m_spline.GetTwist(t);

            transform.position = position;
            transform.LookAt(position + dir);
            transform.RotateAround(position, dir, twist);
        }
Esempio n. 4
0
        private void UpdatePosition(float t)
        {
            Vector3 position = m_spline.GetPoint(t);
            Vector3 dir      = m_spline.GetDirection(t);
            float   twist    = m_spline.GetTwist(t);

            transform.position = position;
            Vector3    direction    = ((position + dir) - transform.position).normalized;
            Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, direction.y, direction.z));

            transform.rotation = Quaternion.RotateTowards(transform.rotation, lookRotation, Time.deltaTime * rotationSpeed);
            //transform.LookAt(position + dir);
            transform.RotateAround(position, dir, twist);
        }