public void addCameraDolly()
    {
        if (dollyRail == null)
        {
            GameObject go    = new GameObject("Dolly");
            Dc2dDolly  dolly = go.AddComponent <Dc2dDolly>();

            Dc2dWaypoint wp1 = new Dc2dWaypoint();
            wp1.position = new Vector3(0, 0, 0);

            Dc2dWaypoint wp2 = new Dc2dWaypoint();
            wp2.position = new Vector3(1, 0, 0);

            Dc2dWaypoint[] dc2dwaypoints = new Dc2dWaypoint[2];
            dc2dwaypoints[0] = wp1;
            dc2dwaypoints[1] = wp2;
            wp1.endPosition  = wp2.position;

            dolly.allWaypoints = dc2dwaypoints;

            this.dollyRail = dolly;

            /*Selection.activeGameObject = go;
             * SceneView.FrameLastActiveSceneView();*/
        }
    }
Esempio n. 2
0
    public float FastArcLength(Dc2dWaypoint wp)
    {
        float arcLength = 0.0f;

        Dc2dUtils.ArcLengthUtil(wp.position, wp.position + wp.tanOne, wp.endPosition + wp.tanTwo, wp.endPosition, 5, ref arcLength);
        return(arcLength);
    }
Esempio n. 3
0
    public void addWaypointToEnd()
    {
        Dc2dWaypoint[] tempPoints = new Dc2dWaypoint[allWaypoints.Length + 1];

        for (int i = 0; i < allWaypoints.Length; i++)
        {
            tempPoints[i] = allWaypoints[i];
        }

        Dc2dWaypoint newpoint = new Dc2dWaypoint();

        newpoint.position = tempPoints[tempPoints.Length - 2].getPostSpawn();
        tempPoints[tempPoints.Length - 2].endPosition = newpoint.position;
        tempPoints[tempPoints.Length - 1]             = newpoint;
        allWaypoints = tempPoints;
    }
Esempio n. 4
0
    protected virtual void OnSceneGUI()
    {
        float zoom = HandleUtility.GetHandleSize(new Vector3(0, 0, 0)); // basically gets a scene view zoom level

        //create post waypoint button
        Handles.color = dolly.tangentGuideColor;


        for (int i = 0; i < dolly.allWaypoints.Length; i++)
        {
            Dc2dWaypoint wp = dolly.allWaypoints[i];

            // position handle
            Handles.color = dolly.waypointColor;
            wp.position   = Handles.Slider2D(wp.position, Vector3.forward, Vector3.right, Vector3.up, wpSize * zoom, Handles.CircleHandleCap, 0.01f);


            if (i < dolly.allWaypoints.Length - 1)   // not last
            // calc legnth
            {
                wp.arclength = dolly.FastArcLength(wp);

                // show handles to adjust time to next waypoint  (Pro Only)

                //show length to next
                if (dolly.showLength)
                {
                    Handles.Label(wp.position + (Vector3.up + Vector3.right * 2), "Length:" + dolly.FastArcLength(wp).ToString());
                }

                //show timeToNext
                if (dolly.showTimes)
                {
                    Handles.Label(wp.position + (Vector3.right * 2), "Next:" + wp.timeToNextWaypoint.ToString());
                }

                // tan1 handle
                Handles.color = dolly.tangentHandleColor;
                Vector3 tempt1 = Handles.Slider2D(wp.tanOne + wp.position, Vector3.forward, Vector3.right, Vector3.up, buttonSize * zoom, Handles.DotHandleCap, 0.01f) - wp.position;

                // constant Speed  (Pro Only)
                wp.tanOne = tempt1;


                if (wp.tanOne.x < 0)
                {
                    wp.tanOne.x = 0;
                }
                Handles.color = dolly.tangentGuideColor;
                Handles.DrawDottedLine(wp.position, wp.tanOne + wp.position, 4.0f);

                // tan2 handle
                Handles.color = dolly.tangentHandleColor;
                Vector3 tempt2 = Handles.Slider2D(wp.tanTwo + wp.endPosition, Vector3.forward, Vector3.right, Vector3.up, buttonSize * zoom, Handles.DotHandleCap, 0.01f) - wp.endPosition;

                //constant Speed  (Pro Only)
                wp.tanTwo = tempt2;


                if (wp.tanTwo.x > 0)
                {
                    wp.tanTwo.x = 0;
                }
                Handles.color = dolly.tangentGuideColor;
                Handles.DrawDottedLine(wp.endPosition, wp.tanTwo + wp.endPosition, 4.0f);

                // draw da curve
                Handles.DrawBezier(wp.position, wp.endPosition, wp.position + wp.tanOne, wp.endPosition + wp.tanTwo, dolly.dollyTrackColor, null, 5f);
            }
            if (i > 0)   // not first
            // update position of previous
            {
                dolly.allWaypoints[i - 1].endPosition = wp.position;

                if (wp.position.x < dolly.allWaypoints[i - 1].position.x)
                {
                    wp.position.x = dolly.allWaypoints[i - 1].position.x; // no going past previous point
                }
            }
        }
    }
Esempio n. 5
0
 public void smoothWaypoint(Dc2dWaypoint first, Dc2dWaypoint second)
 {
     // pro only
 }
Esempio n. 6
0
 public void straightenWaypoint(Dc2dWaypoint first, Dc2dWaypoint second)
 {
     // pro only
 }