Example #1
0
    private void OnSceneGUI()
    {
        spline          = target as CameraTrack_Spline;
        handleTransform = spline.transform;
        handleRotation  = Tools.pivotRotation == PivotRotation.Local ?
                          handleTransform.rotation : Quaternion.identity;

        Vector3 p0 = ShowPoint(0);

        for (int i = 1; i < spline.ControlPointCount; i += 3)
        {
            Vector3 p1 = ShowPoint(i);
            Vector3 p2 = ShowPoint(i + 1);
            Vector3 p3 = ShowPoint(i + 2);

            Handles.color = Color.gray;
            Handles.DrawLine(p0, p1);
            Handles.DrawLine(p2, p3);

            Color lineColour = Color.grey;
            int   groupIndex = spline.GetPointGroup(i);

            if (groupIndex != spline.GetPointGroup(i + 1))
            {
                lineColour = Color.gray;
            }
            else if (groupIndex == 0)
            {
                lineColour = Color.blue;
            }
            else if (groupIndex == 1)
            {
                lineColour = Color.green;
            }
            else if (groupIndex == 2)
            {
                lineColour = Color.magenta;
            }
            else if (groupIndex == 3)
            {
                lineColour = Color.yellow;
            }
            else if (groupIndex == 4)
            {
                lineColour = Color.red;
            }
            else if (groupIndex > 4)
            {
                lineColour = Color.cyan;
            }


            Handles.DrawBezier(p0, p3, p1, p2, lineColour, null, 2f);

            p0 = p3;
        }

        //	ShowDistanceToVector ();
    }
Example #2
0
    //Due to group transistions, this method jump around when the target posistion that was 0 becomes 1
    Vector3 lerpPoint(Transform target, CameraTrack_Spline spline, int currentGroup, ref float currentPoint, float targetPoint, float damping)  // make this genral - to place all features by a inputed(float placment, float damping, CameraTrack_Spline spline)
    {
        int StartPoint = currentLine;
        int EndPoint   = currentLine;

        spline.GetGroupRange(currentGroup, ref StartPoint, ref EndPoint);

        targetPoint  = spline.GetPointWithinGroupFull(targetPoint, (float)StartPoint, (float)EndPoint);
        currentPoint = Mathf.Lerp(currentPoint, targetPoint, damping * Time.deltaTime);
        Debug.DrawRay(spline.GetPointWithinGroup(targetPoint, StartPoint, EndPoint), transform.up * 2, Color.white);
        //	Debug.DrawRay (spline.GetPointWithinGroup (currentPoint, StartPoint, EndPoint), transform.up, Color.green);
        //return spline.GetPoint (currentPoint, StartPoint, EndPoint);
        return(spline.GetPoint(currentPoint));
    }
Example #3
0
    // Update is called once per frame
    void Start()
    {
        if (GetComponent <CameraModifier_SplineTracker> ())
        {
            modifier = GetComponent <CameraModifier_SplineTracker> ();
        }

        if (lookAtSpline == null)
        {
            lookAtSpline = playerSpline;
        }

        if (!playerRefreance)
        {
            playerRefreance = gameObject.transform;
        }
    }
Example #4
0
    public override void OnInspectorGUI()
    {
        spline = target as CameraTrack_Spline;
        EditorGUI.BeginChangeCheck();
        bool loop = EditorGUILayout.Toggle("Loop", spline.Loop);

        //	targetPos = EditorGUILayout.Vector3Field ("TargetPos",targetPos);
        //	EditorGUILayout.FloatField ("Distance", distance);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Toggle Loop");
            EditorUtility.SetDirty(spline);
            spline.Loop = loop;
        }
        if (selectedIndex >= 0 && selectedIndex < spline.ControlPointCount)
        {
            DrawSelectedPointInspector();
        }

        EditorGUILayout.LabelField("Curve Editing");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Insert Curve"))
        {
            Undo.RecordObject(spline, "Add Curve At Point");
            spline.AddCurveAtPoint(ref selectedIndex);
            EditorUtility.SetDirty(spline);
        }
        EditorGUI.BeginDisabledGroup(spline.points.Length == 4);
        if (GUILayout.Button("Remove Curve"))
        {
            Undo.RecordObject(spline, "Add Curve At Point");
            spline.removeCurveAtPoint(ref selectedIndex);
            EditorUtility.SetDirty(spline);
        }
        EditorGUI.EndDisabledGroup();
        GUILayout.EndHorizontal();
        GUILayout.Space(5);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Curve Start"))
        {
            Undo.RecordObject(spline, "Add Curve Start");
            spline.AddCurve(false);
            selectedIndex = 0;
            EditorUtility.SetDirty(spline);
        }
        if (GUILayout.Button("Add Curve End"))
        {
            Undo.RecordObject(spline, "Add Curve End");
            spline.AddCurve(true);
            selectedIndex = spline.points.Length - 1;
            EditorUtility.SetDirty(spline);
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Group Editing");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Start New Group"))
        {
            Undo.RecordObject(spline, "Add Spline Group");
            spline.AddGroup(selectedIndex);
            EditorUtility.SetDirty(spline);
        }
        if (GUILayout.Button("Merge Current Group"))
        {
            Undo.RecordObject(spline, "Merge Spline Group");
            spline.MergeGroup(selectedIndex);
            EditorUtility.SetDirty(spline);
        }
        GUILayout.EndHorizontal();
        if (GUILayout.Button("Erase Group"))
        {
            Undo.RecordObject(spline, "Erase Current Group");
            spline.RemoveGroupAndPoints(selectedIndex);
            EditorUtility.SetDirty(spline);
        }
        if (GUILayout.Button("Check Groups"))
        {
            Undo.RecordObject(spline, "Check All Groups");
            spline.CheckGroup();
            EditorUtility.SetDirty(spline);
        }
    }